InnerAudioContext.onError
解释:音频播放错误事件
方法参数
Function callback
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
<view class="container"> <view class="card-area"> 此页面遇到音频播放错误事件会弹窗提示 </view></view>
-
Page({ onLoad() { const innerAudioContext = swan.createInnerAudioContext(); innerAudioContext.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3'; innerAudioContext.autoplay = false; innerAudioContext.onPlay(res => { swan.showToast({ title: 'onplay', icon: 'none' }); }); innerAudioContext.onError(err => { swan.showModal({ title: 'onError', content: JSON.stringify(err) }); console.log('onError', res); }); innerAudioContext.play(); this.innerAudioContext = innerAudioContext; }});
