InnerAudioContext.onCanplay收藏我的收藏
收藏
我的收藏基础库 1.0.0 开始支持本方法。
监听音频进入可以播放状态,但不保证后面可以流畅播放。
语法
InnerAudioContext.onCanplay(callback)
参数说明
Function callback
代码示例
const dataUrl = "https://someaudiourl"; // 合法的音频资源地址
const innerAudioContext = tt.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = dataUrl;
innerAudioContext.onCanplay(() => tt.showToast({ title: "音频可以播放了" }));
innerAudioContext.onError((error) => {
tt.showModal({
title: "播放出错",
content: `详细错误信息:${error.errMsg}`,
});
console.log("播放出错", error);
});
Bug & Tip
暂无。