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
is there anyway to solve that?