Windows Media Player SDK banner art
PreviousNext

Handling Events in Faceplates

This topic applies to Windows Media Player version 6.4 only.

At various times during its operation, Windows Media Player generates events, which can be handled by scripts. This can be useful for resetting your control button graphics when a media file finishes playing, or displaying new clip information on the faceplate when a new media file begins playing.

This is done in Microsoft® JScript® by specifying a script that will execute in response to a particular event, and placing it inside a SCRIPT tag. The FOR parameter of the SCRIPT tag gives the name of the Windows Media Player object (as defined in the OBJECT tag), and the EVENT parameter specifies the name of the event plus any parameter names.

For example, when a clip finishes playback, Windows Media Player generates an EndOfStream event. The following example script would be called any time the Windows Media Player reached the end of a media file and the EndOfStream event occurred:

<SCRIPT FOR="MediaPlayer" 
        EVENT="EndOfStream(bResult)" 
        LANGUAGE="JScript">
    if (bResult == 0)
    {
        MediaPlayer.Stop();
        playBtn.SelectNormal();
        stopBtn.SelectActive();
        pauseBtn.SelectNormal();
    }
</SCRIPT>

The EndOfStream event passes one parameter to the script. If the clip has played all the way through, the value of this parameter is zero. In that instance, the script calls the Stop method to make sure playback is stopped and resets the control button graphics to reflect the new state.

For a full list of supported Windows Media Player events, consult Windows Media Player Events in the Version 6.4 Control Reference.

PreviousNext


© 2000-2001 Microsoft Corporation. All rights reserved.