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">取消监听onPause</button>
</view>
</view>解释:取消监听 onPause 事件
方法参数
Function callback
示例
图片示例
代码示例
<view class="wrap">
<view class="card-area">
<button type="primary" bindtap="pause">pause</button>
<button type="primary" bindtap="offPause">取消监听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: '取消监听成功'
});
this.innerAudioContext.offPause();
}
});
以上内容是否对您有帮助:
更多建议: