onShow: function() {
/* 背景音 */
this.promptTone = setTimeout(() => {
this.backgroundSound()
}, 3000)
},
onHide: function() {
console.log('App Hide')
clearInterval(this.promptTone);
},
methods: {
backgroundSound() {
let music = uni.createInnerAudioContext(); //创建播放器对象
music.src =
'./static/music.mp3';
music.play((red) => {
console.log("播放成功", red);
}); //执行播放
music.onError((res) => {
console.log("播放失败", res);
music.destroy();
})
music.onEnded(function() {
console.log('ended');
music.destroy(); //这里是播放结束后,销毁实例
});
}
},
jstomato
- 发布:2022-03-25 15:15
- 更新:2022-03-28 19:46
- 阅读:1666
uni.createInnerAudioContext()用本地的音频无法播放,报错-5
分类:HBuilderX