pauseVoice() {
innerAudioContext.pause()
this.voiceShow = false
console.log('暂停');
},
playVoice() {
innerAudioContext.src = https:
innerAudioContext.play()
console.log('播放地址',innerAudioContext.src);
innerAudioContext.onPlay(() => {
console.log('开始播放')
this.voiceShow = true
})
innerAudioContext.onCanplay(() => {
innerAudioContext.duration
})
innerAudioContext.onTimeUpdate(() => {
this.audioForm.times = innerAudioContext.duration.toFixed(0)
console.log('音频时长', this.audioForm.times);
this.audioForm.duration = this.audioForm.times - innerAudioContext.currentTime.toFixed(0)
console.log('播放中', this.audioForm.duration);
})
innerAudioContext.onPause(()=>{
console.log('暂停事件');
})
innerAudioContext.onEnded(() => {
console.log('结束');
this.voiceShow = false
})
},
真机调试,uni.createInnerAudioContext 音频设置的背景音乐
loop=true
sessionCategory = "ambient",
在 当前页面一段时间后突然停止了音乐的播放是什么因为什么呀?
真机调试 点击播放 然后再暂停 继续播放 有时候会触发到innerAudioContext.onPause暂停事件 就播放不了了