l***@126.com
l***@126.com
  • 发布:2023-09-18 17:56
  • 更新:2023-09-18 17:56
  • 阅读:839

音频组件uni.createInnerAudioContext(),android播放声音,来回切换10+次就没有声音了

分类:uni小程序sdk

连续点播放10+以上就没有声音了,原来是创建的实例没有销毁的问题
var innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = '..//souds/waitpay.mp3';

innerAudioContext.onPlay(() => {
console.log('开始播放');
});

innerAudioContext.onError((res) => {
console.log('播放出错');
console.log(res.errMsg);
console.log(res.errCode);
innerAudioContext.destroy();
});

innerAudioContext.onPause((res) => {
console.log('播放完成');
innerAudioContext.destroy();//这句话
innerAudioContext.src = '';
});

0 关注 分享

要回复文章请先登录注册