背景音乐触发ended事件后会重置src属性

发布于 7 年前作者 rye4054 次浏览最后编辑 7 年前来自 ask

用getBackgroundAudioManager()创建的audioContext触发onEnded 时会重置src属性,这是有意设计的吗?

另外Ended事件之后还会触发一次onTimeUpdate(可能是因为重置src引起的)。

4 回复
chaodeng
chaodeng1 楼6 年前

另外,在微信的正在播放音乐条中暂停小程序的背景音乐,之后再打开小程序调用play()无法重新播放背景音乐。

azou
azou2 楼6 年前

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码示例。

lifu
lifu3 楼6 年前

另外,开发者工具设置audioContext的title,epname,singer,coverImgUrl,webUrl等属性无效,真机没问题。

updateAudio: function () {
    console.log('update audio', this.data.item)
    const audioContext = wx.getBackgroundAudioManager()
    audioContext.title = this.data.item.name
    audioContext.epname = this.data.item.parentName || '专辑名'
    audioContext.singer = this.data.item.authorName
    audioContext.coverImgUrl = this.data.item.cover
    audioContext.webUrl = this.data.item.url
    audioContext.src = this.data.item.src
    console.log(audioContext, audioContext.coverImgUrl, audioContext.title)
  },

这些属性在开发者工具里始终为"",在真机上可以正确显示。

zhaofang
zhaofang4 楼5 年前

另外,在开发者工具中,背景音乐暂停(paused 为 true)时调用seek无法更改currentTime。真机没问题。