// 音乐监听函数 var that = this; wx.onBackgroundAudioPlay(function () { that.setData({ isPlayingMusic: true }) }); wx.onBackgroundAudioPause(function () { that.setData({ isPlayingMusic: false }) }); // 音乐播放 onMusicTap: function (event) { var CurrentPostId = this.data.CurrentPostId; var postData = postsData.postList[CurrentPostId]; var isPlayingMusic = this.data.isPlayingMusic; if (isPlayingMusic) { wx.pauseBackgroundAudio(); this.setData({ isPlayingMusic : false }) } else { wx.playBackgroundAudio({ dataUrl: postData.music.url, title: postData.music.title, coverImgUrl: postData.music.coverImg, }) this.setData({ isPlayingMusic : true }) } },
4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!
了解课程