收藏
回答

InnerAudioContext.offTimeUpdate报错

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug InnerAudioContext.offTimeUpdate 工具 7.0.3 2.6.1

- 当前 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
                })
            })
        }
    },



回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容