javascript - HTML5 AudioPlayer Event Action 'Ended' is being call more than One time -
i working html5 audio player. implementing playlist. using 'ended' event action play next audio media file. but, @ end of media file, 'ended' event fired more 1 time. (as message log appears more 1 time.) this event listener: //event listener function addplayerlistener() { console.log("recording index: "+combinedsessionindex); var audio = document.getelementbyid("playarea"); audio.addeventlistener('ended', function () { sessionstoplay = $("#audio_files").val().split(','); console.log ("in recording end event listener...!!!"+combinedsessionindex); //it shows length '1' not '0' if (sessionstoplay.length == 1) { console.log("returned due session play length..!!!") return; } //as combinedsessionindex starts 1 if (combinedsessionindex == sessionstoplay.length) { console.log(...