Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wuyanan
2024-10-10 18:41:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
41163fcbc94f277296e917c295df23ef79b7ff0e
41163fcb
1 parent
c4a73d93
fix |> 修复点击播放早晚报音频时,播控中心显示有延迟问题
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
sight_harmony/features/wdComponent/src/main/ets/viewmodel/AudioSuspensionModel.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/BackgroundAudioController.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/AudioSuspensionModel.ets
View file @
41163fc
...
...
@@ -46,6 +46,7 @@ export class AudioSuspensionModel {
// BackgroundAudioController.sharedController().startContinuousTask()
BackgroundAudioController.sharedController().listenPlayEvents()
await BackgroundAudioController.sharedController().setSessionMetaData(srcContentId ?? "", srcTitle, $r("app.media.system_audio_icon_bk_center"), srcSource ?? "")
BackgroundAudioController.sharedController().activateSession()
BackgroundAudioController.sharedController().stopUseFeatures()
if (this.playerController.get().getUrl() === url) {
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/BackgroundAudioController.ets
View file @
41163fc
...
...
@@ -53,13 +53,18 @@ export class BackgroundAudioController {
}
// 激活接口要在元数据、控制命令注册完成之后再执行
await this.lastSession?.activate();
//
await this.lastSession?.activate();
Logger.debug(TAG, `session create done : sessionId : ${this.lastSession?.sessionId}`);
this.lastProgress = 0
this.hasSetupProgress = false
}
async activateSession() {
await this.lastSession?.activate();
Logger.debug(TAG, `session activate done : sessionId : ${this.lastSession?.sessionId}`);
}
destorySession() {
if (this.lastSession) {
this.lastSession.deactivate();
...
...
@@ -74,6 +79,21 @@ export class BackgroundAudioController {
this.lastItemTitle = title || ""
this.lastItemMediaImage = mediaImage
this.lastItemArtist = artist || ""
let metadata: AVSessionManager.AVMetadata = {
assetId: assetId.length > 0 ? assetId : "fake-asset-id",
title: title.length > 0 ? title : " ",
mediaImage: "https://cdnjdphoto.aikan.pdnews.cn/WapApi/800/launcher_icon.png" ,//pixelMapImage ?? ("file://" + mediaImage.id),
artist: artist.length > 0 ? artist : "人日日报"
// duration: duration
};
try {
await this.lastSession?.setAVMetadata(metadata)
Logger.debug(TAG, `SetAVMetadata successfully`);
} catch (err) {
Logger.error(TAG, `Failed to set AVMetadata. Code: ${err.code}, message: ${err.message}`);
} finally {}
}
async setSessionMetaDataWithDuration(assetId: string, title: string, mediaImage: Resource, artist: string, duration: number) {
...
...
Please
register
or
login
to post a comment