抖音开放平台Logo
控制台

InnerAudioContext.offPlay
收藏
我的收藏

取消监听 play 事件。

语法

InnerAudioContext.offPlay(callback)

参数说明

Function callback

代码示例

预期表现:音频开始播放时没有弹窗提示。

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 onplay() {
  tt.showToast({ title: "开始播放" });
}
innerAudioContext.onPlay(onplay);
innerAudioContext.offPlay(onplay);

Bug & Tip

暂无。

文档评论

登录后可参与评论