Detecting when audio is finished playing using javascript.?


(Vikrant Arya) #1

I am playing audio file using javascript,How will I check audio complete.?
I wrote js function but it is not working.

var myAudio = document.getElementById("myAudio");
	myAudio.play();

 myAudio.addEventListener('ended', function() {
this.currentTime = 0;
alert("ended");

}, false);

Please help me,How will I check.?


#2

Do you have more information? or a document because the code looks ok.


(Vikrant Arya) #3

Thank You Dbear,
There was some error in my code,Javascript code is working…