How to detect an audio has finished playing in a web page?

If you are using the html5 audio tag, there is the “onended” event handler. I don´t know if the browsers support it yet.

Something like:

<audio src="https://stackoverflow.com/questions/4619917/xpto.mp3" onended="DoSomething();"></audio>

In the last case you can use a swf that can play the sound, and alert your javascript when it reaches the end.

Leave a Comment