InnerAudioContext.offWaiting

解释:取消监听 onWaiting 事件

# 方法参数

Function callback

# 示例

在开发者工具中预览效果

# 扫码体验

请使用百度APP扫码

# 图片示例

# 代码示例

  • 在 swan 文件中
<view class="container">
    <view class="card-area">
        <button type="primary" bindtap="offWaiting">offWaiting</button>
    </view>
</view>
  • 在 js 文件中
Page({
    onLoad() {
        const innerAudioContext = swan.createInnerAudioContext();
        innerAudioContext.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3';
        innerAudioContext.autoplay = false;
        innerAudioContext.onWaiting(res => {
            swan.showModal({
                title: 'onWaiting',
                content: '正在加载,请耐心等待'
            });
            console.log('onWaiting', res);
        });
        innerAudioContext.onEnded(res => {
            innerAudioContext.offWaiting();
        });
        this.innerAudioContext = innerAudioContext;
        this.innerAudioContext.play();
    },
    offWaiting(){
        swan.showModal({
            title: 'offWaiting',
            content: '取消监听成功'
        });
        this.innerAudioContext.offWaiting();
    }
});