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) }, }); }, |
把音频放在回调里面 播放不了
请问解决了吗
不是一个很好的处理方法 把异步处理用同步处理(scan+http)的方法做(Promise),在 onShow里面调用语音播放