小程序是否支持多个音频同时播放
index.wxml
|
index.js
data: { file: 'http://stor.weixinhost.com/3/wxhost-files/30bd8a0448f55afccaceae543ef9850a63604d99.mp3' , bmg: 'http://stor.weixinhost.com/3/wxhost-files/4523ea1d7dd6068e2a15b43bcb143df67c281aef.mp3'
this .bmgAudio = wx.createInnerAudioContext()
this .bmgAudio.src = this .data.bmg
setTimeout(() => { this .fileAudio.play() }, 1500)
this .fileAudio.onEnded(() => { setTimeout(() => { this .bmgAudio.stop() }, 1500)
this .fileAudio.onStop(() => { setTimeout(() => { this .bmgAudio.stop() }, 1500) })
onHide () { this .bmgAudio = null this .fileAudio = null
// 试听 audioPlay () { this .bmgAudio.play()
// 暂停 audioStop () { this .fileAudio.stop() } }) |
上述代码在安卓和开发者工具中可以同时播放,在IOS中不可以
但是用 组件audio 可以同时播放2个音频
|