Home | Index

Yahoo! Live: Flash Embeds and JavaScript API

JavaScript API

Use the JavaScript API to control the players, get information about the player, and to broadcast status from inside the HTML container. The APIs are grouped into three categories: general-purpose methods, event management methods, and events. There's also a utility callback that you can configure in the <embed> tag to have the player call the JavaScript function of your choice to announce that it is ready to be interacted with from JavaScript.

General-Purpose Methods

These methods handle basic functionality of the player.

getChannelUrl():String

Returns the channel URL for the stream currently being displayed in the player. Returns null if the player has no permalink assigned.

getDisplayAspectRatio():String

Gets the aspect ratio, width and height, at which the stream is actually being displayed. To get the stream's actual (that is, native) aspect ratio, use getVideoAspectRatio()

getFullscreen():Boolean

Returns true if the player is in fullscreen mode, false otherwise.

getPermalink():String

Returns the permalink that's currently being displayed in the player.

getProfileUrl():String

Returns the profile url for the owner of the stream that's currently assigned to the player. Returns null if no permalink is assigned.

getVersion():String

Returns the version of the player in major.minor format.

getVolume():Number

Returns the audio volume of the player as a number between 0 and 1. The volume here refers to the player's volume; the broadcast stream might not have sound, in which case setting the volume will have no effect. You can subscribe to the broadcastMute and broadcastUnmute events to determine if the stream actually contains audio at a given point in time.

getVideoAspectRatio():Number

Returns the actual aspect ratio, width and height, of the stream that the player is displaying.

mute():void

Sets the audio volume of the player to 0. Before it mutes the player, the mute() method saves the current volume, which can be restored later with the unmute() method.

playerPreferredSize(width,height):Array

Returns the size at which the player needs to be displayed in order to display video at the dimension specified by width and height. The returned array will contain two items: width and height, in that order.

setPermalink(String):void

Sets the permalink that the player will play. The initial permalink can also be set at load time using the 'permalink' FlashVar.

setVolume(Number):void

Sets the audio volume of the player. The argument should be a number between 0 an 1. Note that the broadcast might not have sound. The initial volume can be set at load time using the 'vol' FlashVar.

unmute():void

Set the audio volume of the player to the volume that was set before mute() was called.