In my snake game i have an audio tag which plays sfx. When a peice of food gets eaten, it will play the "Food" sound below. It will then spawn a new food and if its one worth 200 points, it will make a sound called "Food 200". Problem is, as it spawns instantly after, the "Food200" audio will load while the "Food" audio is still playing/ loading giving this error
if (Audio == "Food") {
var audio = document.getElementById('SFX');
audio.src = 'audio/Food.mp3';
audio.load();
audio.play();
}
if (Audio == "Food200") {
var audio = document.getElementById('SFX');
audio.src = 'audio/Food200.mp3';
audio.load();
audio.play();
}
I have tried to "$("SFX").remove();" on my audio tag and also tried pause it but that doesnt work im still getting the error, is there a better way to do this?