You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
613 B
26 lines
613 B
const bgm = uni.createInnerAudioContext();
|
|
bgm.src = 'https://qiniu.aiyxlib.com/yuekan-BGM20-Chinap.mp3'
|
|
bgm.loop = true;
|
|
|
|
var music = {
|
|
//mute 表示是否是静音,,默认不静音
|
|
playBgm({mute=false}){
|
|
if (!bgm) return;
|
|
if(mute){
|
|
bgm.pause()
|
|
}else{
|
|
bgm.play()
|
|
}
|
|
bgm.onPause(()=>{
|
|
console.log('暂停背景音乐');
|
|
})
|
|
bgm.onPlay(() => {
|
|
console.log('开始播放音乐#######');
|
|
})
|
|
bgm.onError((res) => {
|
|
console.log(res)
|
|
})
|
|
}
|
|
}
|
|
module.exports = music
|
|
|