InnerAudioContext.onEnded
解释:音频自然播放结束事件
方法参数
Function callback
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
<view class="wrap"> <button type="primary" bindtap="seekEnded">点击到音频末尾</button> <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 => { console.log('onPlay', res); }); innerAudioContext.onEnded(res => { swan.showModal({ title: 'onEnded', content: JSON.stringify(res) }); }); this.innerAudioContext = innerAudioContext; this.innerAudioContext.play(); }, seekEnded() { this.innerAudioContext.onTimeUpdate(res => { this.innerAudioContext.seek(res.data.duration) }); }});
