InnerAudioContext.offTimeUpdate

解释:取消监听 onTimeUpdate 事件

方法参数

Function callback

示例

在开发者工具中预览效果

扫码体验

请使用百度APP扫码

图片示例

代码示例

-

  1. <view class="wrap"> <view class="card-area"> <view class="description"> 正在播放《演员》 </view> <view class="description"> {{currentTime}} / {{duration}} </view> </view> <button type="primary" bindtap="offTimeUpdate">点击取消监听</button></view>

-

  1. Page({ data: { currentTime: '', duration: '0' }, onLoad() { const innerAudioContext = swan.createInnerAudioContext(); innerAudioContext.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3'; innerAudioContext.autoplay = false; this.innerAudioContext = innerAudioContext; this.innerAudioContext.play(); this.innerAudioContext.onTimeUpdate(res => { this.setData('currentTime', res.data.currentTime); this.setData('duration', res.data.duration); }); }, offTimeUpdate() { this.innerAudioContext.offTimeUpdate() }});