gpt4 book ai didi

javascript - chrome addEventListener 无法处理通知声音

转载 作者:行者123 更新时间:2023-11-30 19:41:17 25 4
gpt4 key购买 nike

我正在尝试在 chrome 上添加音频加载通知。下面是我的 Js 代码。它在 firefox 上运行良好,但有时在 chrome 上无法运行 m

错误

Uncaught (in promise) DOMException

audio_notice = new Audio('http://www.sousound.com/music/healing/healing_01.mp3');
audio_notice.autoplay = true;
audio_notice.addEventListener('ended', function () {
try {
this.currentTime = 0;
this.play();
} catch (e) {
}
}, false);
audio_notice.addEventListener('load', function () {
try {
this.play();
} catch (e) {
}
}, true);

## LIve example ##

最佳答案

我认为事件“加载”不正确,它不在 list of compatible events 中.

您可以改用loadeddata

audio_notice.addEventListener('loadeddata', function () {
try {
this.play();
} catch (e) {
}
}, true);

关于javascript - chrome addEventListener 无法处理通知声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55374797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com