wx.playBackgroundAudio问题?
在onShow里面,播放音乐,playBackgroundAudio函数里调用的wx.playBackgroundAudio
onShow: function () { let that = this if (this.data.isMusicOn) { this.playBackgroundAudio() } wx.onBackgroundAudioStop(function (res) { console.log(res) that.playBackgroundAudio() }) }, |
playBackgroundAudio: function() { wx.playBackgroundAudio({ dataUrl: '', title: '', coverImgUrl: '', success: function (res) { console.log(res) }, fail: function (res) { console.log(res) } }) }, |
在onHide里,暂停播放。
onHide: function () { wx.pauseBackgroundAudio() }, |
当退出小程序,音乐会暂停,进入微信聊天界面(一切正常)。
关键来了!
这时,你和别人微信语音聊天(你发起或对方发起),当挂断后,小程序的音乐会响起!!
