ReganPerkins
ReganPerkins

Reputation: 1665

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?

Upvotes: 4

Views: 5549

Answers (1)

naw103
naw103

Reputation: 1903

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>

Upvotes: 3

Related Questions