InnerAudioContext.onPause

解释:音频暂停事件

# 方法参数

Function callback

# 示例

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

# 图片示例

# 代码示例

    <view class="wrap">
        <view class="card-area">
            <button type="primary" bindtap="play">play</button>
            <button type="primary" bindtap="pause">pause</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: '开始播放',
                    content: JSON.stringify(res)
                });
                console.log('onPlay', res);
            });
            innerAudioContext.onPause(res => {
                swan.showModal({
                    title: '暂停播放',
                    content: JSON.stringify(res)
                });
                console.log('onPause', res);
            });
            this.innerAudioContext = innerAudioContext;
        },
        play() {
            this.innerAudioContext.play();
        },
        pause() {
            this.innerAudioContext.pause();
        }
    });