I know how to start and stop a video with play() and pause(), but how do I put a video back to the start in HTML5 using javascript? is there a way to move the pointer back to the start?
Asked
Active
Viewed 5.4k times
3 Answers
52
Set the currentTime property back to 0.
Quentin
- 857,932
- 118
- 1,152
- 1,264
-
3Got it! Thanks for the answer. $('#mov1').get(0).currentTime = 0; – rom Dec 06 '11 at 15:24
-
1I guess this is outdated now – Lipis Jan 09 '14 at 14:21
-
@startupthekid — Nobody suggested trying to use it on a jQuery object and it isn't a function/method, it's a property holding a number. – Quentin Jan 08 '16 at 09:11
28
To have a proper stop functionality you could do the following:
var video = document.getElementById('vidId');
// or video = $('.video-selector')[0];
video.pause();
video.currentTime = 0;
video.load();
Note: This is the only version that worked for me in chrome using nodejs (meteorjs) in the backend, serving webm, mp4, ogg files
Matyas
- 12,935
- 3
- 59
- 71
-
player.load(); was the only solution which worked! Thanks for the answer! – Numb3rs Feb 10 '21 at 11:39