Make html5 video in the first frame when it ends?

I have a simple html5 tag for a video attached to an event with completion:

$('#video').show().trigger("play").bind('ended', function () { 
//code
}

Since I β€œshow” and β€œhide” it with the click of a button, I would like to return it to the first frame of this last function, so it will start from the very beginning the next time it appears (now it starts from the end, and this causes an unpleasant flicker, when it goes from the last to the first frame).

Is this possible with jQuery?

Thanks in advance!

+5
source share
1 answer

You can use something like

$('#video').show().trigger("play").bind('ended', function () { 
    this.currentTime = 0;
}

You can only set the current time if a loaded metadata event has passed.

+11

All Articles