HarmonyOS AvSession设置AVPlaybackState成功,但是通知栏直接不展示?

设置代码如下,但是播控中心展示时间异常,看日志状态设置成功了的SetAVPlaybackState successfully。

this.getAvSession(context).then(result => {
  // 简单设置一个播放状态 - 暂停 未收藏
  let playbackState: AVSessionManager.AVPlaybackState = {
    state: state,
    position: {
      elapsedTime: current, // 已经播放的位置,以ms为单位
      updateTime: new Date().getTime(), // 应用更新当前位置的时间戳,以ms为单位
    },
    duration: total, // 资源的时长,以ms为单位
  };
  console.info(`SetAVPlaybackState2 successfully_` + state);
  this.currentAVSession!!.setAVPlaybackState(playbackState, (err) => {
    if (err) {
      console.error(`Failed to set AVPlaybackState. Code: ${err.code}, message: ${err.message}`);
    } else {
      console.info(`SetAVPlaybackState successfully_` + state);
    }
  });
})
阅读 568
1 个回答

需要在设置setAVMetadata传duration,更新状态传无效。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进