I have a youtube video open on my browser. How to go to specific time stamp using javascript? I want to use this in chrome extension. I can give the t query in url but it reloads the whole page. I don't want to reload the whole page. Help me with this. Thanks
Asked
Active
Viewed 267 times
0
-
Write a [content script](https://developer.chrome.com/extensions/content_scripts) that finds the `video` element and sets its `currentTime`. – wOxxOm Apr 20 '21 at 12:36
1 Answers
2
Try the player.seekTo(seconds:Number, allowSeekAhead:Boolean) function:
document.getElementById("movie_player").seekTo(seconds,true);
Resources :https://developers.google.com/youtube/iframe_api_reference?csw=1#Playback_controls
credit to this answer for getting the player element
ATP
- 2,025
- 2
- 9
- 24
-
We can even use document.getElementById("movie_player").Currentime=seconds – sandeysh May 04 '21 at 07:31
-
@sandeysh Nope. it doesn't work. it only changes the variable Currentime it doesn't update the UI – ATP May 04 '21 at 15:56