"operateAudio:fail jsapi has no permission, event=operateAudio, runningState=background, permissionMsg=permission got, detail=jsapi has no permission"
app.json包含如下配置:
"requiredBackgroundModes": [
"location",
"audio"
],
const innerAudioContext = wx.createInnerAudioContext({
useWebAudioImplement: true
})
if (wx.setInnerAudioOption) {
wx.setInnerAudioOption({
mixWithOther: true,
obeyMuteSwitch: false,
autoplay: true
})
} else {
innerAudioContext.obeyMuteSwitch = false;
innerAudioContext.autoplay = true;
}
innerAudioContext.onCanplay(() => {
console.log('可以播放');
innerAudioContext.play();
});
innerAudioContext.onPlay(() => {
console.log('监听到音频开始播放');
});
innerAudioContext.onEnded(() => {
console.log('音频自然播放结束事件');
innerAudioContext.src = 'nomusic'
});
innerAudioContext.onStop(() => {
console.log('音频停止事件');
});
innerAudioContext.onError((res) => {
console.log("播放失败", res);
});
innerAudioContext.onWaiting((res) => {
console.log('音频加载中事件,当音频因为数据不足,需要停下来加载时会触发')
});
innerAudioContext.src="http://xxxx"
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。