playSound(result) {
let fail = '/static/sounds/fail.wav';
let succes = '/static/sounds/succes.wav'
//实例化声音
const Audio = uni.createInnerAudioContext();
Audio.autoplay = true;
if (result.indexOf('成功') < 0) {
Audio.src = fail;
} else {
Audio.src = succes;
}
Audio.onError((res) => {
Audio.destroy(); //发生错误后,销毁实例
});
Audio.onPause(() => {
Audio.destroy(); //这里是播放暂停后,销毁实例
});
Audio.onStop(() => {
Audio.destroy(); //这里是播放停止后,销毁实例
});
Audio.onEnded(() => {
Audio.destroy(); //这里是播放结束后,销毁实例
})
},
//多次调用之后出现闪退问题
dadadad
- 发布:2020-12-23 10:47
- 更新:2020-12-23 14:38
- 阅读:756
dadadad (作者)
pad手持终端 安卓7
2020-12-24 16:55