audio.oncamplaythrough不适用于互联网探索



我有一个要求,On Api响应更新嘟嘟声应该触发。我使用的解决方案适用于Chrome和Firefox浏览器,但不适用于Internet Explorer。

if ($scope.totalQueueList) {
var audio = new Audio();
audio.src = 'rest/assets/images/beep.mp3';              
audio.oncanplaythrough = (event) => {
var playedPromise = audio.play();
if (playedPromise) {
playedPromise.catch((e) => {
console.log(e)
if (e.name === 'NotAllowedError' || e.name === 'NotSupportedError') {
console.log(e.name);
}
}).then(() => {
});
}
}
}

所以有人能帮我了解一下它是如何在互联网上探索的吗?

根据https://caniuse.comIE中不支持onplaythrough属性。

但是,您可以将EventListener添加到元素中,在元素中播放事件(没有"on"(。

最新更新