setMusicMonitor() {
let that = this
let node = this .data.nodes.find(x => x.id === that.data.audioId)
const backgroundAudioManager = app.globalData.backgroundAudioManager
wx.onBackgroundAudioPlay(e => {
console.log( 'playing...' )
app.globalData.g_isBackgroundAudioManagerPaused = false
node && !node.isPlayingMusic ? that.onMusicTap({
currentTarget: node
}) : null
})
wx.onBackgroundAudioPause(e => {
console.log( 'pausing...' )
app.globalData.g_isBackgroundAudioManagerPaused = true
node && node.isPlayingMusic ? that.onMusicTap({
currentTarget: node
}) : null
})
wx.onBackgroundAudioStop(e => {
console.log( 'stopping...' )
let node = that.data.nodes.find(x => x.id === that.data.audioId)
if (node) {
course.putCourseDuration( this .data.courseid, node.id, 1000 * convertTimeToSeconds(node.duration), 1000 * convertTimeToSeconds(node.duration), )
}
that.setData({
nodes: that.data.nodes.map(x => {
if (x.id === that.data.audioId) {
x.isPlayingMusic = false
x.listened = processTotalDuration(0)
x.percent = 0
}
return x
})
})
let nexAudio = that.data.nodes[that.data.nextAudioIndex]
that.onMusicTap({
currentTarget: nexAudio
})
})
},
|
楼主解决了吗???
求解,
还有是怎么控制系统的上一首下一首呢
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题