后台播放功能backgroundAudioManager在IOS下没有声音
发布于 5 年前 作者 liangxiulan 15098 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

backgroundAudioManager.src设置后,在安卓手机上能正常播放mp3,在苹果手机IOS系统下播放mp3没有声音。也没有报错

  • 预期表现

backgroundAudioManager.src设置后,在苹果手机上也一样可以后台播放mp3

  • 复现路径
  • 提供一个最简复现 Demo代码片段如下:bofang.jsbofang:function(e){

const backgroundAudioManager = wx.getBackgroundAudioManager()

    backgroundAudioManager.title = ‘稳行’

   backgroundAudioManager.epname = ‘阅读’

    backgroundAudioManager.singer = ‘’

    backgroundAudioManager.coverImgUrl = https://www.xingdaoren.top/music/logo_wenxing.png

    backgroundAudioManager.src = https://www.xingdaoren.top/music/1.mp3

    backgroundAudioManager.play() }

app.json

“requiredBackgroundModes”: [“audio”]

2 回复

从微信客户端6.7.2版本开始,若需要在小程序切后台后继续播放音频,需要在 app.json 中配置 requiredBackgroundModes 属性。开发版和体验版上可以直接生效,正式版还需通过审核。https://developers.weixin.qq.com/miniprogram/dev/api/wx.getBackgroundAudioManager.html

苹果下播放有问题的原因找到了,是因为播放的文件有中文,全部改成英文字符后ok了,感谢大家关注。

回到顶部