Detecting when HTML5 audio is finished playing (more than once)?

Posted by user386911 on Stack Overflow See other posts from Stack Overflow or by user386911
Published on 2012-06-19T14:50:25Z Indexed on 2012/06/19 15:16 UTC
Read the original article Hit count: 129

Filed under:
|
|
|

I am having a problem detecting when an tag is finished playing an mp3. When I do something like this:

     myAudio.addEventListener("ended", function() 
     {
          alert("ended");
     });

It only occurs the first time the audi is played. When I play the audio again, nothing happens. The same thing occurs when I use the onended=doThis(); method. I've heard maybe there is a way to do it in jquery, but I haven't been able to get it to work. I've also heard there might be a way to fix it by changing the audio div id everytime the mp3 is played, but this doesn't work for me because I need the id to stay the same.

Anyone got any ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery