let innerAudioContext = uni.createInnerAudioContext()
innerAudioContext.src = 路径
innerAudioContext.onPlay((e) => {
console.log('开始播放',e)
})
innerAudioContext.onError((res) => {
// 播放音频失败的回调
uni.showModal({
title: '错误',
content: JSON.stringify(res)
})
console.log('错误', res)
})
innerAudioContext.play()
安卓正常播放 ios就出现了错误
{ "errMsg" : "operateAudio:fail audioInstance is notset" "errCode":-1}
这个api有兼容性问题,之前整过一个文章,可以看下https://developers.weixin.qq.com/community/develop/article/doc/00004265ab0740ad9bddacb5a51813