简体   繁体   English

加载失败,因为找不到支持的源

[英]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.

相关问题 DOMException:加载失败,因为未找到支持的源 - DOMException: Failed to load because no supported source was found 无法加载音频 - DOMException:无法加载,因为找不到支持的源 - Cant load Audio - DOMException: Failed to load because no supported source was found Phonegap视频“由于找不到支持的来源而无法加载” - Phonegap Video “Failed to load because no supported source was found” Chrome:未捕获(承诺)DOMException:无法加载,因为找不到支持的源 - Chrome: Uncaught (in promise) DOMException: Failed to load because no supported source was found 在 Vue 中播放声音 onClick 事件返回 Uncaught (in promise) DOMException: Failed to load because no supported source was found - playing sound onClick event in Vue returns Uncaught (in promise) DOMException: Failed to load because no supported source was found 播放带有特殊字符的音频时,“(未承诺)DOMException:未能加载,因为找不到支持的源” - “Uncaught (in promise) DOMException: Failed to load because no supported source was found” when playing an audio with special characters Android:URL.createObjectURL无法正常工作(由于找不到受支持的源而无法加载。) - Android: URL.createObjectURL does not work properly (Failed to load because no supported source was found.) Android Chrome:未捕获(承诺)DOMException:由于找不到受支持的源而无法加载 - Android Chrome : Uncaught (in promise) DOMException: Failed to load because no supported source was found 为 WebGL 纹理加载图像,但由于 CORS 而失败 - Load an image for WebGL texture but failed because of CORS Jquery将无法加载,因为无法找到它 - Jquery will not load because it can't be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM