Skip to content Skip to sidebar Skip to footer

Determine When Html5 Audio Is Paused Or Track Is Finished Using Jquery

I am working on an HTML5 audio tag and I want to trigger an event when the song is finished. Is this possible with jQuery? My jQuery code is: $(document).ready(function(){ v

Solution 1:

Use HTML 5 onended event handler

<audiosrc="sample.mp3"onended="yourFunction()"></audio>

For jQuery bind ended event handler

 $(music).bind("ended", function(){ ... });

Solution 2:

.bind("ended", function(){ });

Or

 music.addEventListener("ended", function() { });

Solution 3:

<audio class="ah-audio-player" preload="auto">
  <sourcetype="audio/mpeg" src="sound.mp3">
</audio>

-

var audio_player = $('.ah-audio-player');
audio_player.on('ended', function () {
    alert('end');
});

Post a Comment for "Determine When Html5 Audio Is Paused Or Track Is Finished Using Jquery"