Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set html5 video to specific frame

I am trying to set a html5 embedded video to the first frame of the video once it is out of view. I know I can call play() and pause() on the element to have it pause and play but can I set the video back to the first frame with javascript?

like image 844
ReganPerkins Avatar asked Sep 13 '25 02:09

ReganPerkins


1 Answers

I don't believe you can set it to a specific frame but you can set it to a specific second of the video. ex.

var vid = document.getElementById("myVideo");
vid.currentTime = 5;

OR

if you mean you just want it to go back to the beginning once it ends you can just set it to loop via JS

var vid = document.getElementById("myVideo");
vid.loop = true;

OR by just adding the loop attribute to the video tag like

<video loop>
like image 147
naw103 Avatar answered Sep 14 '25 16:09

naw103