Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restart html video with javascript

I have a tag in my html code with a locally stored video in it (not a link from youtube). I know there is a way to play/pause the video from javascript by using .pause() and .play(). Lets say I have a button that I would like to reset the video (skip to beginning). Is there a function for that in javascript/ jquery? If not then how can I achieve this?

Thanks to everyone in advance.

like image 534
John Smith Avatar asked Aug 23 '16 10:08

John Smith


People also ask

How do I reset my react video?

Right now when the video has finished playing you have to manually drag the control for the position of the video back to zero and then press play to have the video restart.


1 Answers

You can use currentTime property as follow

var vid = document.getElementById("myVideo");
vid.currentTime = 0;
like image 117
Divyesh Savaliya Avatar answered Sep 24 '22 11:09

Divyesh Savaliya