Reputation: 2546
I know there are start and end url query params when you share the link for a youtube video so the video starts and ends at those seconds.
I want to do the same with javascript using the Youtube Iframe Player API. I know there is the method player.getCurrentTime() that returns the elapsed time in seconds since the video started playing.
There is no event fired when the current time changes.
Upvotes: 1
Views: 1767
Reputation: 438
Not sure what kind of answer you need,
But here is two examples:
Simple IFrame from youtube share
https://www.youtube.com/embed/YourVideoID?start=startSeconds&end=EndSeconds
IFrame API: you can check out IFrame API Docs here: https://developers.google.com/youtube/iframe_api_reference
From there you can see that you can load video from id using Argument Syntax or Object syntax
I prefer using objects. But here is both:
Argument Syntax
player.loadVideoById(videoId: String,
startSeconds: Number): Void
Object Syntax
player.loadVideoById({ videoId: String,
startSeconds: Number,
endSeconds: Number}): Void
You can also try it out from the example tab: https://developers.google.com/youtube/youtube_player_demo
Your question is not really clear so if something is missing please reply and I will be happy to edit my answer.
Upvotes: 1