Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple MP3 files

Status
Not open for further replies.

BossTweed41

Technical User
Jun 2, 2005
22
US
I would like to know how one puts multiple music files on a site where visitors can choose the one the want to listen to. Like a juke box I guess?
Thanks, Boss
 
Flash would be probably better in the long run, but you can check out this code
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Title here</title>


</head>

<body>

<p align="Center">
<script language="javascript">var streams = new Array();
streams[0] = new makeStream("one.wav", "1...Song Title One");
streams[1] = new makeStream("two.wav", "2...Song Title Two");
streams[2] = new makeStream("three.wav", "3...Song Title Three");
streams[3] = new makeStream("four.wav", "4...Song Title Four");
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 PLAYER.:";
  }
  else {
    document.mediaPlayer.showControls = true;
	  document.playerCtrl.controls.value = "  :.HIDE PLAYER.: "
  }}
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>

<object id="mediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
codebase="[URL unfurl="true"]http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"[/URL]
standby="Loading Microsoft Windows Media Player components..."
type="application/x-oleobject" width="239" height="179">
  <param name="fileName" value="sounds/bestieverhad.wav">
  <param name="animationatStart" value="false">
  <param name="transparentatStart" value="true">
  <param name="autoStart" value="true">
  <param name="loop" value="true">
  <param name="showControls" value="false">
</object>

<form name="playerCtrl">
  <input type="button" value=" :.PAUSE.: " name="playOrPause"
  onclick="handlePlayOrPauseClick()" style="font-family:courier"> <input
  type="button" value="  :.SHOW PLAYER.: " name="controls"
  onclick="handleControlsOnOffClick()" style="font-family:courier">

<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>
</p>

</body>

</html>

__________________________
Corey

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top