< innerAudioContext = wx.createInnerAudioContext(); let zhTime; let enTime; innerAudioContext.src = zhurl; innerAudioContext.onPlay(() => { console.log('开始播放中文') }) innerAudioContext.play(); innerAudioContext.onCanplay(() => { setTimeout(() => { innerAudioContext.currentTime //必须写,否则获取时间为0 innerAudioContext.onTimeUpdate(() => { zhTime = innerAudioContext.duration }) }, 100) }) innerAudioContext.onEnded(() => { console.log('中文播放完毕'); //播放停止,销毁该实例 innerAudioContext.destroy(); innerAudioContext = wx.createInnerAudioContext(); innerAudioContext.src = enurl; innerAudioContext.play(); innerAudioContext.onPlay(() => { console.log('开始播放英文') }) innerAudioContext.onEnded(() => { console.log('英文播放完毕') innerAudioContext.stop(); //播放停止,销毁该实例 innerAudioContext.destroy(); }) innerAudioContext.onCanplay(() => { setTimeout(() => { innerAudioContext.currentTime innerAudioContext.onTimeUpdate(() => { enTime = innerAudioContext.duration; let num = (zhTime + enTime).toFixed(3); let allTime = num * 1000 + 1500; this.setData({ allTime, }) }) }, 100) }) })
|
此处要实现功能为当播放完一段音频后,继续播放第二段音频。监听一段音频播放完毕使用onEnded()方法,在开发者工具中调试没有任何问题,而在手机上调试时,onEnded()方法中所写的代码play()方法,时而执行,时而不执行,怎么解决啊?急急急!!!!
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)