Play and pause the latest version of the API applet background music

      
   const backgroundAudioManager = wx.getBackgroundAudioManager();
        var isPlay = this.data.isPlay; // defined in data isPlay = false
        if (isPlay) {
            backgroundAudioManager.pause (); // Pause
        
this.setData({
             isPlay = false
           })
        } else {
            backgroundAudioManager.title = 'moment';
            // backgroundAudioManager.epname = 'moment';
            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;
        }
 
 
Play music may not link fails;

Guess you like

Origin www.cnblogs.com/duokexiao/p/12061700.html