扫码回调结果中,调用音频播放,音频无效
发布于 6 年前 作者 gang41 1945 次浏览 来自 问答

const innerAudioContext = wx.createInnerAudioContext();

onReady:function(e){
    this.scan();
  },
 
  scan:function(){
    let that = this;
    wx.scanCode({
      onlyFromCamera: true,
      success: function (res) {
        console.log(res.result);
        innerAudioContext.autoplay = true;
 
        innerAudioContext.src = 'data/a.mp3';
        innerAudioContext.onPlay(() => {
          console.log('开始播放')
        })
        innerAudioContext.onError((res) => {
          console.log(res.errMsg)
          console.log(res.errCode)
        })
        innerAudioContext.onEnded((res) => {
          console.log('play2播放结束')
        })
        console.log(innerAudioContext)
      },
    });
  },

把音频放在回调里面 播放不了

1 回复

请问解决了吗

回到顶部