const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.autoplay = true
//这两句话话一定要在一起,不然ios手机上会有时间放不出声音
innerAudioContext.src = 'audio/start.mp3'
innerAudioContext.onPlay(() => {
console.log('开始播放')
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
本文介绍了一种在微信小程序中实现音频自动播放的方法,强调了内联音频上下文的创建与配置对于确保iOS设备上音频正常播放的重要性。通过设置autoplay属性为true,并正确加载音频源,可以实现在多种设备上的稳定播放。
1511

被折叠的 条评论
为什么被折叠?



