IOS 出现,退出小程序音乐继续播放问题,而Android不会(IOS唯一解决办法只能将微信杀掉大退,音乐才会停止播放),实在是有些烦躁,老板总是问怎么回事,怎么回事,每次都这么麻烦,才能把音乐关掉....希望早日解决此BUG !!!
代码片段:
innerAudioContext.autoplay = true;
innerAudioContext.loop = true;
innerAudioContext.src = “https://dfsn.china-tengyun.com/group1/M00/01/4D/cH5Z71tV2MyAbpluAAdpRGO7DU0650.mp3”;
that.funtimeupdate();
//暂停播放
audioPause: function() {
innerAudioContext.pause();
innerAudioContext.onPause(() => {
console.log(‘暂停播放’)
clearInterval(interval);
})
this.setData({
musDis: true,
nomusDis: false
});
},
// 继续播放
audioPlay: function() {
var that = this;
innerAudioContext.play();
innerAudioContext.onPlay(() => {
console.log(‘开始播放’);
that.funtimeupdate();
})
that.setData({
musDis: false,
nomusDis: true
});
//播放语音时保持屏幕常亮
wx.setKeepScreenOn({
keepScreenOn: true
})
},
funtimeupdate: function() {
var that = this;
interval = setInterval((function timer() {
var totalTime = innerAudioContext.duration;
var thisTime = innerAudioContext.currentTime;
var progress = parseInt((thisTime / totalTime) * 100)
that.setData({
thisTime: util.formatSeconds(thisTime),
totalTime: util.formatSeconds(totalTime),
progress: progress
});
return timer;
})(), 100);
},
})