智慧画屏客户端
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

3 years ago
  1. const bgm = uni.createInnerAudioContext();
  2. bgm.src = 'https://qiniu.aiyxlib.com/yuekan-BGM20-Chinap.mp3'
  3. bgm.loop = true;
  4. var music = {
  5. //mute 表示是否是静音,,默认不静音
  6. playBgm({mute=false}){
  7. if (!bgm) return;
  8. if(mute){
  9. bgm.pause()
  10. }else{
  11. bgm.play()
  12. }
  13. bgm.onPause(()=>{
  14. console.log('暂停背景音乐');
  15. })
  16. bgm.onPlay(() => {
  17. console.log('开始播放音乐#######');
  18. })
  19. bgm.onError((res) => {
  20. console.log(res)
  21. })
  22. }
  23. }
  24. module.exports = music