loadVideoById() in YouTube's regular player (not chromeless)
Solution 1
You can not do that, cause the calls in the "regular youtube player" have the VideoID in the URL instead as a parameter:
- Regular Video: http://www.youtube.com/v/VIDEO_ID&enablejsapi=1&playerapiid=ytplayer
- Chromeless: http://www.youtube.com/apiplayer?enablejsapi=1
Instead of that you can easily create your own function that changes the Embbebed SWF, i mean, say that you are using swfobject for the "Regular Player", then using createSWF function you will be able to replace the previous video for the actual one dynamically.
Hope this help you.
Solution 2
You can do this...
http://code.google.com/apis/ajax/playground/#change_the_playing_video
Solution 3
FYI there also a jQuery plugin that can do it for you, and provide you with a ton of controls!
http://tikku.com/jquery-youtube-tubeplayer-plugin
https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin
Solution 4
I found it easier to use loadVideoByUrl() as an alternative to loadVideoByIdl() instead of using createSWF, you don't have to mess with the swfobject this way, it's a built-in function...just use the video ID to create a youtube swf url such as: url="http://www.youtube.com/e/" + VIDEO_ID + "?enablejsapi=1&version=3" and submit using the loadVideoByUrl() function like this: player.loadVideoByUrl(url)
That way you don't have to mess with the swfobject, it's 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's 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."
Comments
-
Fczbkk almost 2 years
I have a YouTube's player in the webpage. I need to change the video played by this player dynamicaly.
This is (relatively) easy using YouTube's chromeless player. It has method
loadVideoById()
which works perfectly. The problem is, that the chromeless player doesn't have any controls (play/pause, etc.). The regular YouTube player has all this, but it doesn't have theloadVideoById()
method.Is there any way to include the controls of regular player into chromeless player, or to implement
loadVideoById()
method in the regular player?Thanks.
-
rtdp over 12 yearsnow "regular video player" has loadVidoeById and loadVideoByUrl options
-
NickG over 10 yearsThis is so much easier! Why didn't I just think to look for a jQuery plugin in the first place?! Thanks!