A Streaming Media JukeBox - Part II: Netscape: The Windows Media Player Plugin's Properties
A Streaming Media JukeBox - Part II: Netscape
The Windows Media Player Plugin's Methods
The Windows Media Player Plugin supports several methods. We've built a demo jukebox to show their usage. We have several buttons on our demo: Pause/Play, Show Controls/Hide Controls, Small, Normal, and Large. Here is the HTML form:
<FORM NAME="displayMode">
<INPUT TYPE="button" VALUE=" Pause " NAME="playOrPause"
onClick="handlePlayOrPauseClick()" STYLE = "font-family:courier">
<INPUT TYPE="button" VALUE=" Hide Controls " NAME="controls"
onClick="handleControlsOnOffClick()" STYLE = "font-family:courier"><BR>
<INPUT TYPE="button" VALUE=" Small " NAME="small" onClick="changeSize(1)"
STYLE="font-family:courier">
<INPUT TYPE="button" VALUE=" Normal " NAME="normal" onClick="changeSize(0)"
STYLE="font-family:courier">
<INPUT TYPE="button" VALUE=" Large " NAME="large" onClick="changeSize(2)"
STYLE="font-family:courier">
</FORM>
The top left button is the Pause/Play button. Every clicking of this button carries out the proper command and switches the button around. The HandlePlayOrPauseClick()
function is the event handler for this button:
function handlePlayOrPauseClick(){
var state;
playerStatus = document.mediaPlayer.GetPlayState();
if (playerStatus == 6) {
document.mediaPlayer.Play();
document.displayMode.playOrPause.value = " Pause ";
}
else if (playerStatus == 1) {
document.mediaPlayer.Play();
document.displayMode.playOrPause.value = " Pause ";
}
else if (playerStatus == 2) {
document.mediaPlayer.Pause();
document.displayMode.playOrPause.value = " Play ";
}
}
The GetPlayState()
method returns the status of the media. It is 0 when the media is in stop position, 1 when it is in pause position, and 2 if the media is currently playing. When the user clicks the Play button, we call the Play()
method and switch the value of the button to Pause
. When the user clicks the Pause button, we call the Pause()
method and switch the value of the button to Play
.
The Show Controls/Hide Controls button is implemented similarly to the Play/Pause button. Here is the function that handles these clicks:
function handleControlsOnOffClick() {
if (document.mediaPlayer.GetShowControls() == true) {
document.mediaPlayer.SetShowControls(false);
document.displayMode.controls.value = " Show Controls ";
}
else {
document.mediaPlayer.SetShowControls(true);
document.displayMode.controls.value = " Hide Controls "
}
}
This function is straight forward. We get the SHOWCONTROLS
status by calling the GetShowControls()
method, and set it by calling the SetShowControls()
with either the true
value to show the controls, or the false
value to hide them. We also switch the button value accordingly.
Controlling the size of the player's footprint is the simplest of all. The event handler for all three size buttons (Small, Normal, and Large) is common:
function changeSize(newSize) {
document.mediaPlayer.SetDisplaySize(newSize);
}
We call the SetDisplaySize()
method with 0 when the user clicks the Normal button, with 1 if he or she clicks the Small button, and with 2 if the user chooses the Large button.
Produced by Yehuda Shiran and Tomer Shiran
Created: November 9, 1999
Revised: November 23, 1999
URL: https://www.webreference.com/js/column52/properties.html