Class TWMPlayer
The TWMPlayer object exposes the different properties, functions, methods and callbacks of an instance of an imbedded Windows Media Player.
Defined in: <class.wmplayer.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Field Attributes | Field Name and Description |
|---|---|
|
Specifies whether the player will automatically start playing the media URL assigned to it
when the createPlayer function has been successfully called.
|
|
|
Specifies whether a stream will only be sending captioning data or not.
|
|
|
Specifies whether the player's Context Menu must pop-up when the user right-clicks on the player or not.
|
|
|
The height of the player.
|
|
|
The unique ID of the media player.
|
|
|
The URL of the media that will be played by the media player.
|
|
|
Re-expose the onBuffering event.
|
|
|
Re-expose the onClick event.
|
|
|
Re-expose the onData event.
|
|
|
Event is fired after player is fully loaded.
|
|
|
Re-expose the onPlayerStatusChange event.
|
|
|
Subscribe to the onWM_Buffering event to handle any changes in the buffering status.
|
|
|
Subscribe to the onWM_Click event to handle any instance of the user left-clicking on the WMP.
|
|
|
Subscribe to the onWM_MediaChange event to handle any WMP playlist item changes.
|
|
|
Subscribe to the onWM_PlayStateChange event to handle any changes in the media player's status.
|
|
|
Subscribe to the onWM_ScriptData event to handle any raw scripting data that arrives
Arguments passed back to the event handler function are:
|
|
|
Specifies whether the control bar (contains the Play, Stop, Previous, Next, Pause, and Mute buttons
as well as the volume control slider) must be displayed on the media player.
|
|
|
The width of the player.
|
| Method Attributes | Method Name and Description |
|---|---|
|
attachPlayer(PlayerObj)
Register an existing player object.
|
|
|
createPlayer(owner)
Create player object.
|
|
|
Returns the media player's buffering progress.
|
|
|
Object's context name - "TWMPlayer"
|
|
|
getMute()
Get's the media player's settings.mute state.
|
|
|
getMuted()
Get's the media player's settings.mute state.
|
|
|
Get's the wmPlayer object.
|
|
|
Returns the media player's normalized current status code.
|
|
|
Get's the media player's volume.
|
|
|
Returns the media player's non-normalized current state as a number in the range 1 - 11.
|
|
|
Returns the media player's non-normalized current state as a message.
|
|
|
Hide()
Hides the media player.
|
|
|
Checks to see if the media player is buffering or not.
|
|
|
Test to see if the player object is controlable through scripting.
|
|
| <static> |
TWMPlayer.isInstalled()
Static function to detect if Windows Media Player plugin is installed.
|
|
isLoaded()
Player's loading status.
|
|
|
Open(url)
Opens the requested media URL.
|
|
|
Pause()
Pauses the playing of the media player.
|
|
|
Play()
Causes the media player to start playing.
|
|
|
PreBuffer(url)
Opens the requested media URL & pre-buffers the content.
|
|
|
PreBufferCancel(url)
PreBufferCancel - cancel the prebuffering of content.
|
|
|
setMute(muted)
Set's the media player's settings.mute state.
|
|
|
setMuted(muted)
Set's the media player's settings.mute state.
|
|
|
setSize(width, height)
Sets the player width and height
|
|
|
setVolume(volume)
Set's the media player's volume.
|
|
|
Show()
Displays the media player.
|
|
|
Stop()
Stops the playing of the media player.
|
|
|
Mute's or un-Mute 's the media player depending on if it is currently muted or not.
|
Field Detail
{bool}
autostart
Specifies whether the player will automatically start playing the media URL assigned to it
when the createPlayer function has been successfully called.
- Default Value:
- true
{bool}
caption_only
Specifies whether a stream will only be sending captioning data or not.
Very rarely used.
- Default Value:
- false
{bool}
enableContextMenu
Specifies whether the player's Context Menu must pop-up when the user right-clicks on the player or not.
- Default Value:
- false
{int}
height
The height of the player.
- Default Value:
- 240
{string}
id
The unique ID of the media player.
If not specified, an unique ID will be generated for each new instance of a TWMPlayer object.
- Default Value:
- null
{string}
mediaurl
The URL of the media that will be played by the media player.
Note: .asx ( client-side playlist) files can be played and can have references to other .asx files aswell.
{YUI_EVENT}
onBuffering
Re-expose the onBuffering event.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- bufferProgress - Buffering progress as a % (0..100)
{YUI_EVENT}
onClick
Re-expose the onClick event.
No arguments are passed back to event handler function.
No arguments are passed back to event handler function.
{YUI_EVENT}
onData
Re-expose the onData event.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- metadata - Media metadata array.
- See:
- TMediaData#onData
{YUI_EVENT}
onLoaded
Event is fired after player is fully loaded. WMP is actually immediately loaded, however we delay this event with a timer (1ms) to ensure the same constant code flow as those players with a delay.
No arguments are passed back to event handler function.
No arguments are passed back to event handler function.
{YUI_EVENT}
onPlayerStatusChange
Re-expose the onPlayerStatusChange event.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- newstatus - Current normalized status code (1-5) of the Windows media player. Can be 1 - Playing, 2 - Paused, 3 - Stopped, 4 - Buffering, 5 - Error
{YUI_EVENT}
onWM_Buffering
Subscribe to the onWM_Buffering event to handle any changes in the buffering status.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- bStart - True if buffering is starting, False of buffering ended
{YUI_EVENT}
onWM_Click
Subscribe to the onWM_Click event to handle any instance of the user left-clicking on the WMP.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- nButton
- nShiftState
- fX
- fY
{YUI_EVENT}
onWM_MediaChange
Subscribe to the onWM_MediaChange event to handle any WMP playlist item changes.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- Item - Current media element item in ASX file.
- See:
- TMediaData#onMedia
{YUI_EVENT}
onWM_PlayStateChange
Subscribe to the onWM_PlayStateChange event to handle any changes in the media player's status.
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- newstate - Player state code, as per WMP11 SDK
{YUI_EVENT}
onWM_ScriptData
Subscribe to the onWM_ScriptData event to handle any raw scripting data that arrives
Arguments passed back to the event handler function are:
Arguments passed back to the event handler function are:
- bstrType - Script name
- bstrParam - script value
{string}
showcontrols
Specifies whether the control bar (contains the Play, Stop, Previous, Next, Pause, and Mute buttons
as well as the volume control slider) must be displayed on the media player.
A settings of "auto" will only show the controls if the player is not controlable via web buttons, i.e. in FireFox.
Note: Instead of using the control bar, Html buttons and controls can be used to operate the player.
Valid values are "auto", true or false.
- Default Value:
- "auto"
{int}
width
The width of the player.
- Default Value:
- 320
Method Detail
attachPlayer(PlayerObj)
Register an existing player object.
This method will do the following:
- Find the existing player object by ID/Name.
- Subscribes local event handlers to the player object.
- Build functions to fix context of events from player object.
- Attach events to player object.
- Parameters:
- {string} PlayerObj
- The ID/Name of the existing player object
createPlayer(owner)
Create player object.
The owner of the player is a DOM tag element, usually a DIV tag. If no owner is supplied, the BODY tag is used.
Checks to see whether the player must be created for IE or Firefox, then assign all of the player properties
- Parameters:
- {string} owner
- The ID/Name of a DOM tag element
getBufferProgress()
Returns the media player's buffering progress.
Returned value is 0 to 100.
- See:
- TSLPlayer#onMedia
{string}
getContextName()
Object's context name - "TWMPlayer"
- Returns:
- {string} Returns the name of the player "class", i.e. "TWMPlayer"
getMute()
Get's the media player's settings.mute state.
getMuted()
Get's the media player's settings.mute state.
getPlayer()
Get's the wmPlayer object. This is the physical embedded WMP object.
getPlayerStatus()
Returns the media player's normalized current status code.
The codes are:
- 1-Playing
- 2-Paused
- 3-Stopped
- 4-Buffering
- 5-Error
getVolume()
Get's the media player's volume.
The value of the volume returned ranges from 0 to 100.
getWMPPlayState()
Returns the media player's non-normalized current state as a number in the range 1 - 11.
E.g. The state exposed by the WMP 11 SDK's Player object.
getWMPPlayStateMessage()
Returns the media player's non-normalized current state as a message.
E.g. The state exposed by the WMP 11 SDK's Player object.
Hide()
Hides the media player.
Note: The player actually becomes a 1x1 pixel player. Completely hiding a WMP player causes the playback to stop.
isBuffering()
Checks to see if the media player is buffering or not.
isControllable()
Test to see if the player object is controlable through scripting.
<static>
{bool}
TWMPlayer.isInstalled()
Static function to detect if Windows Media Player plugin is installed.
- Returns:
- {bool} Returns TRUE if WMP plugin is detected. (WMP7+, WMP6.4 not supported currently)
{bool}
isLoaded()
Player's loading status.
- Returns:
- {bool} Returns TRUE if player is done loading (successfully), else false.
Open(url)
Opens the requested media URL. If autostart was true, the playback will start.
- Parameters:
- {string} url
- The media url to be loaded by the media player.
Pause()
Pauses the playing of the media player.
Note: Live streams can not be paused.
Play()
Causes the media player to start playing.
PreBuffer(url)
Opens the requested media URL & pre-buffers the content.
NOTE1: This will automatically set #autostart to false!
NOTE2: This only works with progressive downloads. Streaming content can not be paused, thus can not be pre-buffered.
NOTE1: This will automatically set #autostart to false!
NOTE2: This only works with progressive downloads. Streaming content can not be paused, thus can not be pre-buffered.
- Parameters:
- {string} url
- The media url to be loaded by the media player.
PreBufferCancel(url)
PreBufferCancel - cancel the prebuffering of content.
- Parameters:
- {string} url
- Cancel pre-buffering of content
setMute(muted)
Set's the media player's settings.mute state.
- Parameters:
- {bool} muted
- True or False value that indicates whether the media player must be muted or un-muted.
setMuted(muted)
Set's the media player's settings.mute state.
- Parameters:
- {bool} muted
- True or False value that indicates whether the media player must be muted or un-muted.
setSize(width, height)
Sets the player width and height
- Parameters:
- {int} width
- Player width (in pixels)
- {int} height
- Player height (in pixels)
setVolume(volume)
Set's the media player's volume.
- Parameters:
- {int} volume
- The value to which the volume is set. The range is from 0 to 100.
Show()
Displays the media player.
Stop()
Stops the playing of the media player.
toggleMute()
Mute's or un-Mute 's the media player depending on if it is currently muted or not.