小程序背景音乐 的播放和暂停 最新版API

      
   const backgroundAudioManager = wx.getBackgroundAudioManager();
        var isPlay = this.data.isPlay;//在data中定义isPlay=false
        if (isPlay) {
            backgroundAudioManager.pause();//暂停
        
this.setData({
             isPlay = false
           })
        } else {
            backgroundAudioManager.title = '此时此刻';
            // backgroundAudioManager.epname = '此时此刻';
            backgroundAudioManager.singer = '许巍';
            backgroundAudioManager.coverImgUrl = 'https://p3fx.kgimg.com/stdmusic/20160909/20160909064838685290.jpg';
            backgroundAudioManager.src = 'https://win-web-nf01-sycdn.kuwo.cn/6482b5ee33641f36180011298801d00e/5dfa09e9/resource/n1/70/9/2628586107.mp3';
            this.data.isPlay = true;
        }
 
 
播放不了可能是音乐链接失效了;
posted @ 2019-12-18 19:40  吃鸡小能手  阅读(529)  评论(0编辑  收藏  举报