扫码回调结果中,调用音频播放,音频无效
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) }, }); }, |
把音频放在回调里面 播放不了