- InnerAudioContext.play在wx.scanCode成功回调中 无法播放
https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.play.html 本问题针对ios 安卓系统没问题 InnerAudioContext.play() 在 wx.scanCode 在失败回调中可以正常播放 但在成功回调中 无法播放 也监听不到错误 onShow () { this.innerAudioContext = wx.createInnerAudioContext() this.innerAudioContext.src = "http://downsc.chinaz.net/Files/DownLoad/sound1/201707/8986.mp3" this.innerAudioContext.onPlay(() => { console.log('开始播放') }) this.innerAudioContext.onError((res) => { console.log(res.errMsg) console.log(res.errCode) }) this.scanCode() }, scanCode () { wx.scanCode({ scanType: ['barCode'], success: res=> { console.log('scancode succ',this.innerAudioContext) this.innerAudioContext.play() }, fail:res=> { console.log('scancode fail',this.innerAudioContext) this.innerAudioContext.play() } }) }
2020-04-20 - wx.scanCode,扫码后无法正常使用InnerAudioContext.play()?
scan() { wx.scanCode({ success: res => { app.playScanVoice() } }) }, playScanVoice() { this.audioContext = wx.createInnerAudioContext() this.audioContext.autoplay = true this.audioContext.src = '/office/assets/scan-voice.mp3' this.audioContext.onCanplay(() => { this.audioContext.play() }) } 请问大家,上面的代码需要怎么修改?我的需求是,客户扫码条形码,如果找到了商品,则播放一个提示音。 上面的代码经常行不通,有时候只播放一次,后面都不播放了;有时候一次声音都不播放。
2023-05-16