iphonex 背景音乐视频 出错?
发布于 5 年前 作者 gjin 12815 次浏览 来自 问答

如题:

iphone播放背景音频报错,onError监听返回报错如上图信息,iphone11,安卓均没有问题

 observers: {
    'audioInfo': function(newVal, oldVal) {
      if(newVal){
        if(this.data.interVal){
          console.log('clear111');
          clearInterval(this.data.interVal);
        }
        this.setData({
          audioState:'play',
          'this_audioInfo.title':newVal.courseName,
          'this_audioInfo.courseTime':newVal.courseTime,
          'this_audioInfo.watchTime':newVal.watchTime,
           sliderValue:newVal.watchTime?newVal.watchTime:0,
          'this_audioInfo.id':newVal.id?newVal.id:'',
          'this_audioInfo.isEnd':newVal.isEnd,
          'this_audioInfo.fileUrl':newVal.fileUrl
        })
        this.setData({
          current_process:this.format(this.data.sliderValue),
          showMax:this.format(this.data.this_audioInfo.courseTime),
        })
        if(newVal.fileUrl){
          BackAudio.src=newVal.fileUrl;
          BackAudio.title=newVal.courseName
          console.log(this.data.this_audioInfo.fileUrl)
          if(this.data.sliderValue && this.data.sliderValue!=0){
            if(this.data.this_audioInfo.watchTime && this.data.this_audioInfo.courseTime && (Number(this.data.this_audioInfo.courseTime) - Number(this.data.this_audioInfo.watchTime)<=5)){
              // wx.showToast({
              //   title: '重头开始'
              // })
              this.setData({
                sliderValue:0,
              })
            }else{
              // wx.showToast({
              //   title: '播放到'+this.data.sliderValue
              // })
            }
          }
          this.setData({
            interVal:setInterval(()=>{
              console.log('inter')
              this.savePlayTimes();
            },2000)
          })
        }
      }
    }
  },
lifetimes:{
  BackAudio.onError((error) => {
        console.log(error)
        wx.showToast({
          title: '音频文件错误,请联系管理员',
          icon:'none'
        })
        this.setData({
          audioState:false,
        })
        BackAudio.stop();
      })
      BackAudio.onCanplay(()=>{
        //BackAudio.seek()
        wx.seekBackgroundAudio({
          position: Number(this.data.sliderValue),
          success:res=>{
            this.setData({
              showAudio:true
            })
            // wx.showToast({
            //   title: '我跳转了',
            //   icon:'none'
            // })
            BackAudio.play();
          }
        })
      }) }
1 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部