[英]Failed to load because no supported source was found
Looking at previous answer I became with the idea of retrying to play sound: 查看先前的答案,我想到了重试播放声音的想法:
soundBG.pause();
soundBG.currentTime = 0;
var soundPromise = soundBG.play();
if (soundPromise !== undefined) {
soundPromise.then(function() {
console.log('Sound!');
}).catch(function(error) {
console.error('Failed to start your sound, retrying.');
setTimeout(function(){
soundEffects();
}, 2000);
});
}
but its still not working and when the sound is not working I keep getting the error: 但是它仍然不起作用,并且当声音不起作用时,我不断收到错误消息:
DOMException: Failed to load because no supported source was found
DOMException:无法加载,因为找不到支持的源
is there anyway to solve that? 反正有解决办法吗?
I had the same error with an Audio type file and used it 我对音频类型文件有相同的错误并使用了它
var url = document.querySelector('audio').src;
var audio = new Audio();
audio.src = url;
var playPromise = audio.play();
if (playPromise !== undefined) {
playPromise.then(function() {
audio.addEventListener('timeupdate',function() {
console.log(audio.currentTime, audio.duration);
}, true);
}).catch(function(error) {
console.error('Failed to start your sound, retrying.');
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.