- 当前 Bug 的表现(可附上截图)
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
playAudio: function (r){ let that = this let myAudioObj = that.data.myAudioObj utils.consoleLog(r.target.id) let id = r.target.id-1 var innerAudioContext = utils.isNull(myAudioObj[id])?wx.createInnerAudioContext():myAudioObj[id] myAudioObj[id] = innerAudioContext // 判断有无上一段音频播放状态,如果有则进行停止重置(非暂停哦) if (that.data.audioId>0 && myAudioObj[that.data.audioId-1] && !myAudioObj[that.data.audioId-1].paused){ myAudioObj[that.data.audioId-1].stop() } let audioData = that.data.audioData innerAudioContext.src = audioData[id].site innerAudioContext.play(); innerAudioContext.onPlay(() => { that.setData({ audioId:r.target.id }) innerAudioContext.onTimeUpdate(() => { that.setData({ audioNow:innerAudioContext.currentTime, audioTime:innerAudioContext.duration }) }) }) }, pauseAudio: function (r){ let that = this let id = r.target.id-1 let myAudioObj = that.data.myAudioObj if (!utils.isNull(myAudioObj[id])){ let innerAudioContext = myAudioObj[id] innerAudioContext.pause() } }, stopAudio: function (r){ let that = this let id = r.target.id-1 let myAudioObj = that.data.myAudioObj if (!utils.isNull(myAudioObj[id])){ var innerAudioContext = myAudioObj[id] innerAudioContext.stop() innerAudioContext.offTimeUpdate(() => { that.setData({ audioNow:0, audioTime:0 }) }) innerAudioContext.onStop(() => { that.setData({ audioId:0 }) }) } }, |
@nickname, 根本无法使用这个api....
麻烦提供出现问题的机型和微信版本,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)