Friday, April 18, 2008

How you can use YouTube Embedded Player Parameters

This document describes all the parameters that are available in the YouTube embedded player. Appending these parameters to the SWF URL allow you to set things like color and borders,

In order to call the player API methods, you must first get a reference to the player object you wish to control. This can be done by calling getElementById() on the object or embed tag containing the player SWF if using SWFObject to embed the player SWF.

Functions

player.playVideo():Void
Plays the currently cued/loaded video.
player.pauseVideo():Void
Pauses the currently playing video.
player.stopVideo():Void
Stops the current video. This also closes the NetStream object and cancels the loading of the video. Once stopVideo() is called, a video cannot be resumed without reloading the player or loading a new video (chromeless player only). When calling stopVideo(), the player will first broadcast an end event (0), followed by an unstarted event (-1).
player.clearVideo():Void
Clears the video display. Useful if you want to clear the video remnant after calling stopVideo().
player.getVideoBytesLoaded():Number
Returns the number of bytes loaded for the current video.
player.getVideoBytesTotal():Number
Returns the size in bytes of the currently loaded/playing video.
player.getVideoStartBytes():Number
Returns the number of bytes the video file started loading from. Example scenario: the user seeks ahead to a point that hasn't loaded yet, and the player makes a new request to play a segment of the video that hasn't loaded yet.
player.mute():Void
Mutes the player.
player.unMute():Void
Unmutes the player.
player.isMuted():Boolean
Returns true if the player is muted, false if not.
player.setVolume(volume):Void
Sets the volume. Accepts an integer between 0-100.
player.getVolume():Void
Returns the player's current volume, an integer between 0-100. Note that getVolume() will return the volume even if the player is muted.
player.seekTo(seconds, allowSeekAhead):Void
Seeks to the specified time of the video in seconds. The allowSeekAhead determines whether or not the player will make a new request to the server if seconds is beyond the currently loaded video data. Note that seekTo() will look for the closest keyframe before the seconds specified. This means that sometimes the play head may seek to just before the requested time, usually no more than ~2 seconds.
player.getPlayerState():Number
Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
player.getCurrentTime():Number
Returns the current time in seconds of the current video.
player.getDuration():Number
Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.
player.addEventListener(event, listener):Void
Adds a listener function for the specified event.
player.setSize(newWidth, newHeight):Void
Sets the size in pixels of the player.
player.getVideoUrl():String
Returns the YouTube.com URL for the currently loaded/playing video.
player.getVideoEmbedCode():String
Returns the embed code for the currently loaded/playing video.

Events

onStateChange
Fired whenever the player's state changes. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded, it will broadcast an unstarted (-1) event. When the video is cued and ready to play, it will broadcast a video cued event (5).
onError
Fired when an error in the player occurs. Currently there is only one error code, which is 100 for "Video not found." This occurs when a video has been removed (for any reason), or it has been marked as private or non-embeddable by the user.

Special Events

onYouTubePlayerReady(playerid)
Called when the player is fully loaded and the API is ready to receive calls. If a playerapiid is passed into the player via URL arguments, then it will be passed to this function. This function must be implemented in the HTML page containing the YouTube player.

Digg this

0 Comments:

 

blogger templates | Make Money Online