LoadVideoById () in a regular YouTube player (not colorless)

I have a YouTube player on a webpage. I need to change the video that this player plays dynamically.

This is (relatively) easy with a YouTube player without a chronicle. It has a loadVideoById() method that works fine. The problem is that the player without chrome has no controls (play / pause, etc.). an ordinary YouTube player has it all, but it does not have the loadVideoById() method.

Is there a way to include controls of an ordinary player in a player without chrome or implement the loadVideoById() method in an ordinary player?

Thanks.

+6
javascript api youtube
source share
4 answers

You cannot do this because calls in the “regular YouTube player” have the VideoID in the URL instead as a parameter:

Instead, you can easily create your own function that modifies SWF Embbebed, I mean, let's say that you use swfobject for "Normal Player" and then createSWF function, you can dynamically replace the previous video for the actual one.

Hope this helps you.

+5
source share
+3
source share

FYI also has a jQuery plugin that can do this for you, and provide you with a ton of controls!

http://tikku.com/jquery-youtube-tubeplayer-plugin

https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin

+2
source share

It was easier for me to use loadVideoByUrl () as an alternative to loadVideoByIdl () instead of using createSWF, you do not need to contact swfobject this way, it is a built-in function ... just use the video ID to create a youtube swt URL like: url = "http://www.youtube.com/e/" + VIDEO_ID + "? Enablejsapi = 1 & version = 3" and send using the loadVideoByUrl () function as follows: player.loadVideoByUrl (url)

This way you don't have to bother with swfobject, it is spelled out here:

http://code.google.com/apis/youtube/js_api_reference.html#loadVideoById

"player.loadVideoByUrl (mediaContentUrl: String, startSeconds: Number): Void Loads and plays the specified video.

  * The mediaContentUrl must be a fully qualified YouTube player URL in the format http://www.youtube.com/e/VIDEO_ID. In YouTube Data API video feeds, the url attribute of the <media:content> tag contains a fully qualified player URL when the tag format attribute has a value of 5. * startSeconds accepts a float/integer and specifies the time from which the video should start playing. If startSeconds (number can be a float) is specified, the video will start from the closest keyframe to the specified time." 
+1
source share

All Articles