3

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

sandeysh
  • 61
  • 1
  • 6
  • 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
  • Does this answer your question? [Change the current YouTube video time without using YouTube API](https://stackoverflow.com/questions/69919978/change-the-current-youtube-video-time-without-using-youtube-api) – Stéphane Bruckert Feb 16 '23 at 11:17

1 Answers1

3

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,939
  • 4
  • 13
  • 34