voice: function (event){
var that = this ;
clearInterval(that.data.times)
var arr = [ '../../image/voice_001.png' , '../../image/voice_011.png' , '../../image/voice_01.png' ]
const backgroundAudioManager = wx.getBackgroundAudioManager()
backgroundAudioManager.stop()
backgroundAudioManager.onStop( function (){
clearInterval(that.data.times)
that.setData({
bigPic: arr[2]
})
console.log( "播放停止" );
})
backgroundAudioManager.src = event.target.dataset.url
backgroundAudioManager.onPlay( function (){
console.log( "开始播放" )
util.play(arr, "bigPic" , function (i, time) {
that.setData({
bigPic: arr[i],
times: time
})
})
})
backgroundAudioManager.onEnded( function (){
clearInterval(that.data.times)
that.setData({
bigPic: arr[2]
})
console.log( "播放完成" );
})
}
|
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
})
}
})
}
现在是多加了一个音频路径,在播放其中一个时,如果再次点击,就播放另一个音频。这样才能实现打断之前的播放并且立即重新播放的功能
请问有别的办法么 音频文件很多 不可能都一个备份出来哇