抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台

InnerAudioContext.offCanplay
收藏
我的收藏

基础库 1.0.0 开始支持本方法,这是一个同步方法。

取消 监听 canplay 事件。

前提条件无
业务背景无
使用限制无
注意事项无
相关教程无

语法

InnerAudioContext.offCanplay(callback)

参数说明

callback

类型默认值必填说明最低支持版本
function是

取消回调的方法

1.0.0

返回值

无

错误码

errNoerrMsg说明最低支持版本
20000internal error
小游戏框架内部错误,有需要请创建工单咨询
1.0.0

扫码体验

请使用字节宿主APP扫码

代码示例

开发者工具中预览

音频可以播放时没有弹窗提示。

const dataUrl = "https://someaudiourl"; // 合法的音频资源地址 const innerAudioContext = tt.createInnerAudioContext(); innerAudioContext.autoplay = true; innerAudioContext.src = dataUrl; innerAudioContext.onError((error) => { tt.showModal({ title: "播放出错", content: `详细错误信息:${error.errMsg}`, }); console.log("播放出错", error); }); function oncanplay() { tt.showToast({ title: "可以播放了" }); } innerAudioContext.onCanplay(oncanplay); innerAudioContext.offCanplay(oncanplay);