InnerAudioContext.onWaiting收藏我的收藏
收藏
我的收藏基础库 1.0.0 开始支持本方法,这是一个同步方法。
监听音频加载中事件,当音频因为数据不足,需要停下来加载时会触发。
语法
InnerAudioContext.onWaiting(callback)
参数说明
callback
类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
function | | 是 | 监听音频加载中的回调 | 1.0.0 |
返回值
无
扫码体验
代码示例
<view> <button bindtap="play">play</button> <button bindtap="pause">pause</button> <button bindtap="stop">stop</button> <button bindtap="seek">seek</button> </view>
Page({ data: { innerAudioCtx: undefined, }, onLoad() { const innerAudioCtx = tt.createInnerAudioContext() innerAudioCtx.src = "https://sf1-cdn-tos.douyinstatic.com/obj/microapp/frontend/sdk/0000-0001.mp3" innerAudioCtx.obeyMuteSwitch = false this.innerAudioCtx = innerAudioCtx innerAudioCtx.onCanplay(() => { console.log("onCanplay") }) innerAudioCtx.onPlay(() => { console.log("onPlay") }) innerAudioCtx.onPause(() => { console.log("onPause") }) innerAudioCtx.onStop(() => { console.log("onStop") }) innerAudioCtx.onError((res) => { console.log(res) }) innerAudioCtx.onEnded(() => { console.log("onEnded") }) innerAudioCtx.onWaiting(() => { console.log("onWaiting") }) innerAudioCtx.onSeeking(() => { console.log("onSeeking") }) innerAudioCtx.onSeeked(() => { console.log("onSeeked") }) innerAudioCtx.onTimeUpdate(() => { console.log("onTimeUpdate") }) }, onUnload() { const innerAudioCtx = this.innerAudioCtx if (innerAudioCtx) { innerAudioCtx.offCanplay() innerAudioCtx.offPlay() innerAudioCtx.offPause() innerAudioCtx.offStop() innerAudioCtx.offError() innerAudioCtx.offEnded() innerAudioCtx.offWaiting() innerAudioCtx.offSeeking() innerAudioCtx.offSeeked() innerAudioCtx.offTimeUpdate() innerAudioCtx.destroy() } }, play() { this.innerAudioCtx.play() }, pause() { this.innerAudioCtx.pause() }, stop() { this.innerAudioCtx.stop() }, seek() { this.innerAudioCtx.seek(3) }, })
Bug & Tip
无