| | |
| | | |
| | | // uni-app 播放音频封装 |
| | | playSound(e) { |
| | | console.log(e); |
| | | const innerAudioContext = uni.createInnerAudioContext(); |
| | | if (e == 1) { |
| | | innerAudioContext.src = '/static/success.wav'; |
| | |
| | | innerAudioContext.src = '/static/jingbao.wav'; |
| | | } |
| | | innerAudioContext.play(); // 播放音频 |
| | | |
| | | innerAudioContext.onPlay(() => { |
| | | console.log('开始播放'); |
| | | }); |
| | | innerAudioContext.onError((res) => { |
| | | console.log(res.errMsg); |
| | | console.log(res.errCode); |
| | | }); |
| | | innerAudioContext.onPause(function(){ |
| | | console.log('播放出现错误,销毁'); |
| | | innerAudioContext.destroy(); |
| | | }) |
| | | } |
| | | |
| | | replaceWithFunction(str, handler) { |