组件:BackgroundAudioManager
基础库:2.27.2
代码:
let t=this;
t.backmusic=wx.getBackgroundAudioManager();
t.backmusic.src='https://m.ai-rili.com/static/web/indexCalendar/dazuo_bgm/9-1.mp3;
t.backmusic.title='方圆图-'+t.Select.musicName;
t.backmusic.coverImgUrl='https://m.ai-rili.com/static/xcximg/touxiangmoren.png';
t.backmusic.play();
报错:
(1)setBackgroundAudioState:fail jsapi has no permission, event=setBackgroundAudioState, runningState=background, permissionMsg=permission got, detail=jsapi permission required playing audio but current not playing audio in background state
涉及机型:iPhone 13、HUAWEI DUB-AL00、HONOR OXF-AN10、iPhone 12、HUAWEI FLA-TL10、iPhone 11、iPhone 12 Pro、NZONE SP200、HUAWEI+LYA-AL00(这里列出的仅仅是12h内用小程序音频的,如果拓宽时间线,人数机型肯定更多)
(2)"errMsg": "playerErrCode:3, systemErrCode:560557684, domain:ASCII OSStatus:!int, description:未能完成操作。(ASCII OSStatus:!int错误560557684。)",
"errCode": 10001,
"src": "https://m.ai-rili.com/static/web/indexCalendar/dazuo_bgm/9-1.mp3"
涉及机型:iPhone 13 Pro Max、iPhone 11、iPhone 12(12h内)
(3)播放过程中直接没音乐然后报错
"src": "https://m.ai-rili.com/static/web/indexCalendar/dazuo_bgm/9-1.mp3",
"errCode": 10001,
"errMsg": "errCode:67, err:decode audio fail"
涉及机型:Xiaomi Mi Note 2、HONOR+ELZ-AN10(12h内)
调用接口测试BackgroundAudioManager正常,建议自查代码
const app = getApp()
const bgMr = wx.getBackgroundAudioManager();
Page({
data: {
audioList: [
],
audioIndex: 0,
},
onLoad() {
},
onShow() {
const _this = this;
bgMr.onEnded(()=>{
console.log('监听播放完')
setTimeout(() => {
_this.onEndNext();
}, 500);
})
},
playTap(e) {
const {audioList} = this.data;
bgMr.src=audioList[0];
bgMr.title = '测试音频';
bgMr.epname = '测试副标题';
},
seekTap(e) {
const seek = bgMr.duration * 0.9;
console.log('seek: ' + seek);
bgMr.seek(seek);
},
onEndNext(e) {
const {audioList, audioIndex} = this.data;
bgMr.src = audioList[audioIndex+1];
bgMr.title = '测试音频';
bgMr.epname = '测试副标题';
this.setData({audioIndex: audioIndex+1});
},
})
问题就是用户用的时候中间音乐停止并且报错
最近鸿蒙最新的版本都是这样,所有小程序在后台播放音频,自动播放到下一首的时候就报错了。不知道是不是系统权限问题
代码很简单,我都写在描述中了,希望不要跟我要复现啥的