当前有两个audio,一个是Renderjs控制html的audio,一个是uni.createInnerAudioContext()创建的音频。现在先播放html的audio,再播放uni.createInnerAudioContext()音频的时候,html的audio会被自动暂停,并且能监听到对应的onPause事件。有没有办法,防止原生的uni.createInnerAudioContext()把html的audio中断?
原生的audio:
var soundManager = uni.createInnerAudioContext()
soundManager.volume = 1
// soundManager.sessionCategory = "ambient",这个方法对html的audio不管用
renderJs的audio:
<view v-html="audioHtml"></view>
<script>
export default{
data(){
return{
audioHtml:''
}
},
created() {
this.audioHtml = `<audio
id="audioId"
controls="false"
style="width:0;height:0;display:none">
</audio>
`
}
}
</script>
<script module="haudio" lang="renderjs">
export default{
data(){
return{
audio:null
}
},
mounted() {
this.audio = document.getElementById('audioId');
this.audio.addEventListener('pause', () => {
console.log('onPause')
})
}
}
</script>
0 个回复