![]() |
Previous | Next |
This topic applies to Windows Media Player version 6.4 only.
In addition to specifying STYLE attributes, with DHTML you can specify event handlers for the DIV and SPAN tags. These events can be mouse clicks or keystrokes initiated by the user which cause certain Windows Media Player actions to happen. They can also initiate changes to the faceplate graphics.
A common user interface element for a faceplate would be a play button. In DHTML, this is how a tag that specifies event handler scripts might look.
<SPAN ID="PlayButtonSpan"
STYLE="position:absolute;
left:493px;
top:216px;
width:35px;
height:31px;"
onClick="onPlay()"
onMouseOver="onPlayMouseOver()"
onMouseOut="onPlayMouseOut()" >
<IMG NAME="PlayButton"
WIDTH=35
HEIGHT=31
src="../art/demo2/play_n.gif" >
</SPAN>
As before, the STYLE attribute specifies the size and position of the button. In this example, however, there are three event handlers specified for any mouse events that may occur on the region of the SPAN tag. The onMouseOver event happens when a user moves the mouse into the SPAN tag, and the onMouseOut event happens when the mouse moves out of that region. Each of these events calls a script function that switches the graphic used for the play button, indicating to users that this region of the screen controls a function for Windows Media Player.
The onClick event happens when a user clicks the mouse button once over the region. For this button, the event causes the onPlay function to be called. This function, which is defined in the script, is shown below.
function onPlay()
{
if(MediaPlayer.PlayState != 2)
{
MediaPlayer.Play();
playBtn.SelectActive();
pauseBtn.SelectNormal();
stopBtn.SelectNormal();
startTrackbar();
}
}
First the script checks to see whether Windows Media Player is already playing a file. If not, it calls the Windows Media Player Play method to start playback of the current file. The next three script calls are functions that change the graphics of the play button, pause button, and stop button to reflect the current play state of Windows Media Player. The last script call starts another script that monitors the progress of the playback and displays the elapsed and total playback time in text on the faceplate.
Event handlers for events such as onClick can also be created for the Windows Media Player object. For more information, see Handling Events.
Previous | Next |