InnerAudioContext.offPause

2020-08-26 16:28 更新

代碼示例

  • SWAN
  • JS

<view class="wrap">
    <view class="card-area">
        <button type="primary" bindtap="pause">pause</button>
        <button type="primary" bindtap="offPause">取消監(jiān)聽onPause</button>
    </view> 

</view>解釋:取消監(jiān)聽 onPause 事件

方法參數(shù)

Function callback

示例 

在開發(fā)者工具中打開


圖片示例

代碼示例

<view class="wrap">
    <view class="card-area">
        <button type="primary" bindtap="pause">pause</button>
        <button type="primary" bindtap="offPause">取消監(jiān)聽onPause</button>
    </view>
</view>
Page({
    onLoad() {
        const innerAudioContext = swan.createInnerAudioContext();
        innerAudioContext.src = 'https://b.bdstatic.com/miniapp/images/yanyuan.mp3';
        innerAudioContext.autoplay = false;
        innerAudioContext.onPlay(res => {
            swan.showModal({
                title: 'onplay',
                content: JSON.stringify(res)
            });
            console.log('onPlay', res);
        });
        innerAudioContext.onPause(res => {
            swan.showModal({
                title: 'onPause',
                content: JSON.stringify(res)
            });
            console.log('onPause', res);
        });
        innerAudioContext.play();
        this.innerAudioContext = innerAudioContext;
    },
    pause() {
        this.innerAudioContext.pause();
    },
    offPause() {
        swan.showModal({
            title: 'offPause',
            content: '取消監(jiān)聽成功'
        });
        this.innerAudioContext.offPause();
    }
});


以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號