A Streaming Media JukeBox - Part II: Netscape: The Code | WebReference

A Streaming Media JukeBox - Part II: Netscape: The Code


A Streaming Media JukeBox - Part II: Netscape

The Code

<HTML>
<HEAD>
<TITLE>Doc JavaScript's Streaming Media JukeBox</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
var streams = new Array();
streams[0] = new makeStream("https://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx", "Microsoft Promo for Windows Media Player");
streams[1] = new makeStream("https://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.GetShowControls() == true) {
    document.mediaPlayer.SetShowControls(false);
	  document.displayMode.controls.value = "  Show Controls ";
  }
  else {
    document.mediaPlayer.SetShowControls(true);
	  document.displayMode.controls.value = "  Hide Controls "
  }
}
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  ";
  }
} 
function changeSize(newSize) {
  document.mediaPlayer.SetDisplaySize(newSize);
}
function getSelectedEntry() {
  var query = location.search.substring(2, location.search.length - 1);
  for (var i = 0; i < streams.length; i++) {
    if (streams[i].url == query) return i;
  }
  return 0;
}
function getQuery() {
  var query = location.search.substring(2, location.search.length - 1);
  return query;
}
function change() {
  var list = document.playerCtrl.streams;
  var streamURL = list.options[list.selectedIndex].value;
  menuSelection = list.selectedIndex;
  document.mediaPlayer.Stop();
  document.displayMode.playOrPause.value = " Pause ";
  location.href = "demo.html" + "?" + '"' + streamURL + '"';
}
function printPlugin() {
  with (document) {
    writeln('<EMBED TYPE="application/x-mplayer2"');
    writeln('PLUGINSPAGE="https://microsoft.com/windows/mediaplayer/en/download/"');
    writeln('ID=mediaPlayer');
    writeln('NAME="mediaPlayer"');
    writeln('DISPLAYSIZE="4"');		// Fit To Size
    writeln('AUTOSIZE="-1"');
    writeln('BGCOLOR="darkblue"');
    writeln('SHOWCONTROLS="-1" ');
    writeln('SHOWTRACKER="-1"');
    writeln('SHOWDISPLAY="0"');
    writeln('SHOWSTATUSBAR="-1"');
    writeln('VIDEOBORDER3D="-1"');
    writeln('WIDTH=320');
    writeln('HEIGHT=313');
    if (getQuery() == "")   writeln('SRC="https://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx"')
    else writeln('SRC=' + getQuery());
    writeln('AUTOSTART="-1" ');
    writeln('DESIGNTIMESP="5311"');
    writeln('>');
    writeln('</EMBED>');
    writeln('<FORM NAME="playerCtrl">');
    writeln('<SELECT NAME="streams" onChange="change()">');
    var menuSelection = getSelectedEntry();
    for (var i = 0; i < streams.length; i++) {
      if (i == menuSelection) writeln('<OPTION VALUE="', streams[i].url, '" SELECTED>', streams[i].name)
      else writeln('<OPTION VALUE="', streams[i].url, '">', streams[i].name)
    }
    writeln('</SELECT>');
    writeln('</FORM>');
  }
}
</SCRIPT>
</HEAD>
<BODY>
<h3>Doc JavaScript's Streaming Media JukeBox</h3><P><P><HR><P>
<SCRIPT LANGUAGE="JavaScript">
  printPlugin();
</SCRIPT><P>
<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>
</BODY>
</HTML>

https://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: November 9, 1999
Revised: November 22, 1999

URL: https://www.webreference.com/js/column52/code1.html