Javascript 未能加载,因为找不到支持的源
看着这张照片,我开始有了重新播放声音的想法:Javascript 未能加载,因为找不到支持的源,javascript,html,audio,Javascript,Html,Audio,看着这张照片,我开始有了重新播放声音的想法: soundBG.pause(); soundBG.currentTime = 0; var soundPromise = soundBG.play(); if (soundPromise !== undefined) { soundPromise.then(function() { console.log('Sound!'); }).catch(function(error) { console.er
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);
});
}
但它仍然不起作用,当声音不起作用时,我不断得到错误:
DomeException:未能加载,因为找不到支持的源
有没有办法解决这个问题?我在使用音频类型文件时遇到了同样的错误
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.');
});
}
找不到任何答案,这就是我在这里提问的原因。记录在案,chrome和firefox似乎不支持.m4a文件。