backgroundAudioManager
发布于 5 年前 作者 panxiuying 1906 次浏览 来自 问答

在真机调试的时候,播放背景音乐,如果在背景音乐播放中 返回退出小程序,那么程序是正常的。

如果在背景音乐不再播放的过程中 退出小程序,那么息屏之后不会播放音乐,会出现如下错误。

  • 当前 Bug 的表现(可附上截图)
onLaunch: function () {
 
  this.playAudio();
  setInterval(() => {
    this.playAudio();
  }, 10000)
 
},
playAudio() {
  console.log(this);
  this.globalData.backgroundAudioManager && this.globalData.backgroundAudioManager.onStop();
  const backgroundAudioManager = wx.getBackgroundAudioManager()
  backgroundAudioManager.title = '订单提醒' // 设置了 src 之后会自动播放
  backgroundAudioManager.src = 'http://dazezb.oss-cn-zhangjiakou.aliyuncs.com/xiaodian/demo.mp3';
  this.globalData.backgroundAudioManager = backgroundAudioManager;
}
1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部