时间:2019-05-06 来源:小程序工厂
张***: play:function(){
var that = this
const backgroundAudioManager = wx.getBackgroundAudioManager()
backgroundAudioManager.title = '此时此刻'
if(that.data.fg == 1){
backgroundAudioManager.src = 'https://cos-bi-ppt-1252899312.cos.ap-shanghai.myqcloud.com/word/ci/1.mp3'
}else{
backgroundAudioManager.src = 'https://cos-bi-ppt-1252899312.cos.ap-shanghai.myqcloud.com/word/ci/2.mp3'
}
backgroundAudioManager.onStop(function(){
console.log("停止")
})
backgroundAudioManager.onPlay(function(){
console.log("开始")
if (that.data.fg == 1){
that.setData({
fg: 2
})
}else{
that.setData({
fg: 1
})
}
})
backgroundAudioManager.onEnded(function(){
if (that.data.fg == 1) {
that.setData({
fg: 2
})
} else {
that.setData({
fg: 1
})
}
})
}
现在是多加了一个音频路径,在播放其中一个时,如果再次点击,就播放另一个音频。这样才能实现打断之前的播放并且立即重新播放的功能