Skip to content Skip to sidebar Skip to footer

Is There An Oncomplete Event For Html5 Audio?

Is there an oncomplete event for HTML5 audio? I could not find anything on this. I am trying to play a sound after it completes. Well, specifically I am trying to play through an a

Solution 1:

There is the ended event . . .

http://dev.w3.org/html5/spec/Overview.html#event-media-ended

Example:

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

audioElement.addEventListener('ended', function() {
    // Audio has ended when this function is executed.
},false);

Solution 2:

The correct way to to this is using the addEventListener function:

audio.addEventListener('ended', PlayNext);

Post a Comment for "Is There An Oncomplete Event For Html5 Audio?"