getBackgroundAudioManager ios 没有声音?
发布于 3 年前 作者 cqiao 11078 次浏览 来自 问答
const backgroundAudioManager = wx.getBackgroundAudioManager();
play(e){
    this.backmusic()
    let id = e.currentTarget.dataset.id;
    let src = e.currentTarget.dataset.src;
    this.audioCtx = wx.createAudioContext(e.currentTarget.dataset.name)
    if(this.data.nowid == id && this.data.nowflog == true){
      backgroundAudioManager.pause()
        this.setData({
          nowflog:false,
          nowid:null,
        })
    }else if(this.data.nowid != id){
      if(this.data.nowname != null){
        this.audioCtx1 = wx.createAudioContext(this.data.nowname);
        backgroundAudioManager.pause()
      }
      console.log(this.audioCtx);
      
      backgroundAudioManager.title = e.currentTarget.dataset.name
      backgroundAudioManager.src = src
      this.setData({
        nowid:id,
        nowurl:src,
        nowname:e.currentTarget.dataset.name,
        nowflog:true
      })
    }
  },
app.json 已经配置
回到顶部