还有个问题,如何播放音频的src相同,不会重新播放,而会被当成相同的实例,也是相当无语拉这个控件
创建多个InnerAudioContext实例分别对应不同音频,点击事件播放音频总是播放最后一个?用wx.createInnerAudioContext()创建了多个实例,每个实例src对应不同的音频文件,不同的点击事件播放对应的音频,开发者工具模拟器和安卓手机测试都正常, iPhone和iPad上测试却是无论点击哪个按钮都是播放最后一个实例的音频,请问这是写法问题还是bug,有没有什么解决方案实现点击不同按钮播放对应音频? 代码如下: index.js const app = getApp() const innerAudioContext_1 = wx.createInnerAudioContext(); const innerAudioContext_2 = wx.createInnerAudioContext(); const innerAudioContext_3 = wx.createInnerAudioContext(); const innerAudioContext_4 = wx.createInnerAudioContext(); const innerAudioContext_5 = wx.createInnerAudioContext(); innerAudioContext_1.src = '/audio/voice_01.mp3' innerAudioContext_2.src = '/audio/voice_02.mp3' innerAudioContext_3.src = '/audio/voice_03.mp3' innerAudioContext_4.src = '/audio/voice_04.mp3' innerAudioContext_5.src = '/audio/voice_05.mp3' Page({ data: { }, tapevent_01(){ innerAudioContext_1.play(); }, tapevent_02(){ innerAudioContext_2.play(); }, tapevent_03(){ innerAudioContext_3.play(); }, tapevent_04(){ innerAudioContext_4.play(); }, tapevent_05(){ innerAudioContext_5.play(); }, }) index.wxml <button type="primary" bindtap="tapevent_01">播放1</button> <button type="primary" bindtap="tapevent_02">播放2</button> <button type="primary" bindtap="tapevent_03">播放3</button> <button type="primary" bindtap="tapevent_04">播放4</button> <button type="primary" bindtap="tapevent_05">播放5</button> 代码片段:https://developers.weixin.qq.com/s/JsEeA5mt7iCf
2023-05-06