InnerAudioContext.offStop

解释:取消监听 onStop 事件

# 方法参数

Function callback

# 示例

扫码体验
重新加载
请使用百度APP扫码

# 图片示例

# 代码示例

    <view class="wrap">
        <view class="card-area">
            <button type="primary" bindtap="onStop">stop</button>
            <button type="primary" bindtap="offStop">取消监听onStop</button>
        </view>
    </view>
    
    Page({
        onLoad() {
            const innerAudioContext = swan.createInnerAudioContext();
            innerAudioContext.src = 'https://b.bdstatic.com/miniapp/images/yanyuan.mp3';
            innerAudioContext.autoplay = false;
            innerAudioContext.onStop(res => {
                swan.showModal({
                    title: 'onStop',
                    content: JSON.stringify(res)
                });
                console.log('onStop', res);
            });
            innerAudioContext.onEnded(res => {
                innerAudioContext.offStop();
            });
            this.innerAudioContext = innerAudioContext;
            this.innerAudioContext.play();
        },
        onStop() {
            this.innerAudioContext.stop();
        },
        offStop() {
            swan.showModal({
                title: 'offStop',
                content: '取消监听成功'
            });
            this.innerAudioContext.offStop();
        }
    });