A Streaming Media JukeBox: The Code | WebReference

A Streaming Media JukeBox: The Code


A Streaming Media JukeBox

The Code

<HTML>
<HEAD>
<TITLE>Doc JavaScript's Streaming Media JukeBox</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
var streams = new Array();
streams[0] = new makeStream("http://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx", "Microsoft Promo for Windows Media Player");
streams[1] = new makeStream("http://www.advintsol.com/webmaster030399/webmaster.asx", "Microsoft Training for Windows Media Player");
streams[2] = new makeStream("mms://netshow.microsoft.com/ms/sbnasfs/wmt/turtle28.asf", "The Turtle");
streams[3] = new makeStream("mms://netshow.microsoft.com/ms/sbnasfs/wmt/wmt.asf", "Flying Windows Media Player logo");
function makeStream(url, name) {
	this.url = url;
	this.name = name;
}
function handleControlsOnOffClick() {
  if (document.mediaPlayer.showControls == true) {
    document.mediaPlayer.showControls = false;
	  document.playerCtrl.controls.value = "  Show Controls ";
  }
  else {
    document.mediaPlayer.showControls = true;
	  document.playerCtrl.controls.value = "  Hide Controls "
  }
}
function handlePlayOrPauseClick(){
  var state;
  playerStatus = document.mediaPlayer.playState;
  if (playerStatus == 6) {
    document.mediaPlayer.play();
    document.playerCtrl.playOrPause.value = " Pause ";
  } 
  else if (playerStatus == 1) {
    document.mediaPlayer.play();
    document.playerCtrl.playOrPause.value = " Pause ";
  } 
  else if (playerStatus == 2) {
    document.mediaPlayer.pause();
    document.playerCtrl.playOrPause.value = " Play  ";
  }
} 
function changeSize(newSize) {
  document.mediaPlayer.displaySize = newSize;
}
function change() {
  var list = document.playerCtrl.streams;
  var streamURL = list.options[list.selectedIndex].value;
  document.mediaPlayer.stop();
  document.playerCtrl.playOrPause.value = " Pause ";
  document.mediaPlayer.fileName = streamURL;
}
</SCRIPT>
</HEAD>
<BODY LEFTMARGIN = "100">
<h3>Doc JavaScript's Streaming Media JukeBox</h3><P><P><HR><P>
<OBJECT 
  ID="mediaPlayer"  
  CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"  
  CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
  STANDBY="Loading Microsoft Windows Media Player components..." 
  TYPE="application/x-oleobject">
  <PARAM NAME="fileName" VALUE="http://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx">
  <PARAM NAME="animationatStart" VALUE="true">
  <PARAM NAME="transparentatStart" VALUE="true">
  <PARAM NAME="autoStart" VALUE="true">
  <PARAM NAME="showControls" VALUE="true">
</OBJECT><P>
<FORM NAME="playerCtrl">
<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"><BR><BR>
<SCRIPT LANGUAGE="JavaScript">
with (document) {
  writeln('<SELECT NAME="streams" onChange="change()">');
  for (var i = 0; i < streams.length; i++) {
    writeln('<OPTION VALUE="', streams[i].url, '">', streams[i].name);
  }
  writeln('</SELECT>');
}
</SCRIPT>
</FORM>
</BODY>
</HTML>

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: October 25, 1999
Revised: November 23, 1999

URL: http://www.webreference.com/js/column51/code1.html