公司要在小程序做自动播报的一个东西 wx.createInnerAudioContext()创建的audio 使用的是onplay方法在安卓机器可以自动播放 ios不行,项目是uniapp构建的,addEventListener监听用户触摸屏幕行为好像用不了,还有一种方法是WeixinJSBridgeReady事件不过好像也不管用 怎么使用的 有没有大佬指点一下?
公司要在小程序做自动播报的一个东西 wx.createInnerAudioContext()创建的audio 使用的是onplay方法在安卓机器可以自动播放 ios不行,项目是uniapp构建的,addEventListener监听用户触摸屏幕行为好像用不了,还有一种方法是WeixinJSBridgeReady事件不过好像也不管用 怎么使用的 有没有大佬指点一下?
1 个回答
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = "https://file.tuanhuohuo.net/gfire/团小猪提示音-1.mp3" //音频路径
innerAudioContext.onPlay(() => {
console.log(’开始播放‘)
});
innerAudioContext.onError(res => {
console.log(rees.errCode)
console.log(res.errMsg)
});