收藏
回答

ios14pro在播放音频时,手动触发暂停后再次开始播放音频,出现音频空白的现象

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.createInnerAudioContext 微信iOS客户端 8.0.61 3.8.10

 audioPlay(boolean) {

         

            if (this.startTime === Math.floor(this.audioDuration)) {

                this.startTime = 0

                this.audioCurrent = 0

            }

  // 播放

            if (boolean) {

                this.audioCtx.seek(this.audioCurrent)

                wx.setInnerAudioOption({

                    obeyMuteSwitch:false

                })

                this.audioCtx.play()

                this.currentTime = Date.now();

                this.timer = setInterval(() => {

                    // const audioInfo = this.audioCtx

                    if(this.startTime > this.audioDuration) clearInterval(this.timer)

                    const now = Date.now();

                    const delta = (now - this.currentTime) / 1000;

                    this.currentTime = now;

                    this.startTime = Math.max(0, this.startTime + delta);

                    console.log(this.startTime,this.audioCtx.currentTime,this.audioDuration)        

                 

                    // console.log(this.currentTime,this.startTime)

                    this.percent = this.startTime / this.audioDuration * 100

                }, 100)


            }else {

// 暂停

                this.audioCtx.pause()

                // this.currentTime = +(this.currentTime + 0.1).toFixed(1)

                // timerInterval.pause()

                this.audioCurrent = this.audioCtx.currentTime

                this.currentTime = Date.now()

                clearInterval(this.timer)

            }

            this.audioStatus = !boolean

        },

ios14pro在播放音频时,手动触发暂停后再次开始播放音频,出现音频空白的现象,打印音频当前的播放进度可以发现在触发开始播放的0.2-0.3秒内处于相同的进度不会更新,请问是什么原因呢

回答关注问题邀请回答
收藏
登录 后发表内容