InnerAudioContext.offError
取消监听音频播放错误事件。
语法
InnerAudioContext.offError(callback)
参数说明
Function callback
扫码体验
请使用字节宿主APP扫码
代码示例
<!-- index.ttml -->
<button type="primary" bindtap="play">播放</button>
<button type="primary" bindtap="offError">取消监听音频播放错误事件</button>
<!-- 点击“取消监听音频播放错误事件” 后,点击播放无错误提示弹窗 -->
// index.js
let dataUrl = "https://sf1-"; // example: error url
Page({
onShow: function () {
let iac = tt.createInnerAudioContext();
iac.src = dataUrl;
iac.autoplay = false;
iac.loop = false;
iac.obeyMuteSwitch = false;
iac.onPlay(() => {
tt.showToast({ title: "开始播放" });
});
iac.onError((err) => {
tt.showModal({
title: "播放出错",
content: err.errMsg,
showCancel: false,
});
});
this.innerAudioContext = iac;
},
onUnload() {
this.innerAudioContext && this.innerAudioContext.destroy();
},
play() {
this.innerAudioContext.play();
},
offError() {
if (this.innerAudioContext) {
this.innerAudioContext.offError();
tt.showToast({ title: "取消监听" });
}
},
});
Bug & Tip
暂无
点击纠错
评价此篇文档