I'm having trouble with this javascript function
function playaudio(p){
sound.pause();
$("#audiovoix")[0].currentTime = 0;
$("#audiovoix").attr("src", "fiches_visite/"+id+"/audio/"+p+"_FR.mp3");
console.log("fiches_visite/"+id+"/audio/"+p+"_FR.mp3");
sound.load();
sound.play();
sound.onerror = function() {
console.log("fichier introuvable");
itvl = setTimeout(function() {
$('#slider_suivant').trigger('click'); }, tempo);
};
}
This function is called within a picture slider, and p is an identifier int. It changes the audio tag src, plays it, or trigger a click if an error is returned (i don't use ajax to check if file exists on purpose).
Problem is, if the file does not actually exists, it fetches another file in the folder and plays it. It should just return an error but it does not... Why an other file i didn't ask for is played ? How to avoid this ?
My audio folder is something like : 1_FR.mp3, 3_FR.mp3, etc.
Thanks