![]() |
Previous | Next |
This topic applies to Windows Media Player version 6.4 only.
The Windows Media Player control stores information about its current activity and the files it can play. Most information is stored as the value of a property, which scripts can retrieve, although some information is accessed as a return value of a script function.
Any time you send script commands to it, the Windows Media Player control may already be playing a file, scanning through a file, skipping to another file, or waiting to play a file. The PlayState property indicates what action the Windows Media Player control is performing at the time the property is read. By reading this property, you can decide the best action to perform for a command based on its current play state. For example, if your script calls a function whenever a user hits the play button, the function should check to see if the Windows Media Player control is already playing a file. A Microsoft® JScript® function that performs this check might look like the following.
function onPlay()
{
if (MediaPlayer.PlayState != 2) // If not already playing a file...
{
MediaPlayer.Play();
playBtn.SelectActive();
pauseBtn.SelectNormal();
stopBtn.SelectNormal();
}
}
If you were to call the Play method while Windows Media Player was already playing a file, the call would have no effect on the Windows Media Player operation. To avoid this case, the onPlay function checks first to see if the PlayState property is not equal to 2 (which is the value of that property when a file is currently playing) before performing any operations. If Windows Media Player is not currently playing a file, this function would start playback and change the appearance of the buttons on the faceplate to reflect the new state. In this example, the faceplate graphics are changed by the script commands SelectActive and SelectNormal, defined elsewhere on the page for each graphical button.
If Windows Media Player uses a Windows Media metafile to define the media files for playback, your script can retrieve information contained in the metafile. While a media file is currently playing, the GetMediaInfoString method can return the author, title, and copyright information, as specified by the Windows Media metafile entry for that media file. In addition, the GetMediaParameter method enables you to retrieve custom parameters, defined in the metafile with PARAM tags. (For more information, see Windows Media Metafiles for Faceplates and Windows Media Metafiles.)
Previous | Next |