HTML代码:
<view class="bubble voice" bindtap="playVoice('https://learn-english-number.ifcode.com/gameover.mp3')">
<view class="icon other-voice"></view>
</view>
JS代码:
playVoice: function(url,index) {
const context = wx.createInnerAudioContext()
context.autoplay = true
context.src = url
context.onPlay(() => {
console.log('play', url)
})
context.onError((res) => {
console.error('play.error',res)
})
context.onEnded(() => {
console.log('end')
})
}
请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html