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
<audio src="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">
<source type="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"