I have the next code and I can't call ShowMedalMessage() function
var totalsounds = 3;
var currentsound = 1;
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'notify.wav');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.addEventListener('ended', function() {
if (currentsound < totalsounds) {
this.currentTime = 0;
this.play();
currentsound = currentsound + 1;
}
ShowMedalMessage(1);
}, false);
If the call to the function is before to audioElement.addEventListener, it calls properly, but if the line ShowMedalMessage(1); is inside, it doesn't work :(
Thanks!