收藏
回答

InnerAudioContext.offTimeUpdate报错

问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
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
                })
            })
        }
    },



最后一次编辑于  03-18  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

2 个回答