InnerAudioContext.onTimeUpdate
2020-08-26 16:28 更新
解释:音频进度更新事件
方法参数
Function callback
示例
图片示例
代码示例
<view class="wrap">
<view class="card-area">
<view class="description">
正在播放《演员》
</view>
<view class="description">
{{currentTime}} / {{duration}}
</view>
</view>
</view>
Page({
data: {
currentTime: 0,
duration: 0
},
onLoad() {
const innerAudioContext = swan.createInnerAudioContext();
innerAudioContext.src = 'https://b.bdstatic.com/miniapp/images/yanyuan.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);
});
}
});
以上内容是否对您有帮助:
更多建议: