onWMPChangeState This page was last modified over 30 day(s) ago and has 1 comment(s)


Back to MediaPlayer Class Summary

Availability
Windows

Usage
mpInstance.onWMPChangeState:Function

Parameters
newState:Number - Current state of player

Returns
nothing

Description
Dispatched when the state of the MediaPlayer instance changes.
The state is available on opaque data holder property at path:
var state = event.data.state

The states returned are as follows:
0 = Windows Media Player is in an undefined state
1 = Playback of the current media has stopped
2 = Playback of the current media item is paused
3 = The current media item is playing
4 = The current media item is fast forwarding
5 = The current media item is fast rewinding
6 = Buffering - The current media item is getting additional data from the server
7 = Waiting - Connection is established, but the server is not sending data. Waiting for session to begin
8 = Media item has completed playback
9 = Preparing new media item
10 = Ready to begin playing
11 = Reconnecting to stream.

Notes
There are two ways to listen for events in 4.0:
#1
using "onEventNameFunction" - callback based handlers introduced in {mdm} 2.0
#2
using IEventListener model based on Events introduced in 4.0.

No matter what implementation you would use either callback and listener handler would have to use single-argument defintion as in below sample:
// callback based handlers
mdm.Appllication.onAppChangeFocus = function(event:Event):void
{
// proceed with event
};

// handlers based on IEventListener model
function onAppChangeFocusHandler(event:Event):void
{
// proceed with event
};

Example Code
myMP.onWMPChangeState = function(event:Object){
var state = event.data.state
}
// or
myMP.onWMPChangeState = function(event:mdm.Event){
var state = event.data.state;
}

// or
myMP.addEventListener("onWMPChangeState", onWMPChangeStateHandler);
// then
function onWMPChangeStateHandler(event:Object){
var state = event.data.state;
}

mdm.MediaPlayer Class Example Downloads
No Example Downloads Available


User Comment by Bragolgirith on 4th October 2012 - 13:55
I think the syntax has changed since - what works for me is:

var state:Number = event.data.newState;

Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page