Okay most browsers will still read the deprecated embed tag, but to be up to standards, here is an updated version one version (the 2nd one) uses the embed tag for the browsers who don't understand the object tag, and the other version (the 1st one) uses the object tag which is understood in the latest browsers out. The 1st one might break on a Mac OS.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
text-align:center;
}
form {
margin:0;
padding:0;
}
-->
</style>
<script type="text/javascript">
<!--
function PlayIt(){
document.getElementById('music1').innerHTML='<object id="mediaplayer" type="application/x-mplayer2" width="300" height="45" data="'+document.getElementById('cancion').value+'">'
+'<param id="media1" name="src" value="'+document.getElementById('cancion').value+'">'
+'<param id="media2" name="filename" value="'+document.getElementById('cancion').value+'">'
+'<param name="type" value="application/x-mplayer2">'
+'Your system does cannot find the windows media player that was specified.'
+'</object>'
}
//-->
</script>
</head>
<body onload="document.forms['player'].reset()">
<form name="player" action="" method="">
<select name="" id="cancion" onchange="PlayIt()" size="1">
<option value="none">::::::::::::: Choose Your Song Here :::::::::::::</option>
<option value="http://urltosong1.mp3">Song 1</option>
<option value="http://urltosong2.mp3">Song 2</option>
<option value="http://urltosong3.mp3">Song 3</option>
<option value="http://urltosong4.mp3">Song 4</option>
<option value="http://urltosong5.mp3">Song 5</option>
<option value="http://urltosong6.mp3">Song 6</option>
<option value="http://urltosong7.mp3">Song 7</option>
<option value="http://urltosong8.mp3">Song 8</option>
<option value="http://urltosong9.mp3">Song 9</option>
<option value="http://urltosong10.mp3">Song 10</option>
</select>
</form>
<span id="music1">
<object type="application/x-mplayer2" width="300" height="45" data="">
<param name="src" value="">
<param name="filename" value="">
<param name="type" value="application/x-mplayer2">
Your system does cannot find the windows media player that was specified.
</object>
</span>
</body>
</html>
This works in IE6, FF1.04, Opera 8.0 for PC.
It might break in IE for Mac due to the system structure.
If you don't care about standards, and want to ensure the most cross browser compatability using the object tag and embed tag, then you can use this
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
text-align:center;
}
form {
margin:0;
padding:0;
}
-->
</style>
<script type="text/javascript">
<!--
function PlayIt(){
document.getElementById("music1").innerHTML='<object id="mediaPlayer" width="270" height="45" '
+'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="'+document.getElementById('cancion').value+'">'
+'<param name="animationatStart" value="true">'
+'<param name="transparentatStart" value="true">'
+'<param name="autoStart" value="true">'
+'<param name="showControls" value="true">'
+'<param name="loop" value="true">'
+'<embed type="application/x-mplayer2" '
+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
+'bgcolor="darkblue" showcontrols="true" width="270" height="45" '
+'src="'+document.getElementById('cancion').value+'" autostart="true" designtimesp="5311" loop="true">'
+'</embed>'
+'</object>'
}
//-->
</script>
</head>
<body onload="document.forms['player'].reset()">
<form name="player" action="" method="">
<select name="" id="cancion" onchange="PlayIt()" size="1">
<option value="none">::::::::::::: Choose Your Song Here :::::::::::::</option>
<option value="http://urltosong1.mp3">Song 1</option>
<option value="http://urltosong2.mp3">Song 2</option>
<option value="http://urltosong3.mp3">Song 3</option>
<option value="http://urltosong4.mp3">Song 4</option>
<option value="http://urltosong5.mp3">Song 5</option>
<option value="http://urltosong6.mp3">Song 6</option>
<option value="http://urltosong7.mp3">Song 7</option>
<option value="http://urltosong8.mp3">Song 8</option>
<option value="http://urltosong9.mp3">Song 9</option>
<option value="http://urltosong10.mp3">Song 10</option>
</select>
</form>
<span id="music1">
<object id="mediaPlayer" width="270" height="45"
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="">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="false">
<param name="showControls" value="true">
<param name="loop" value="true">
<embed type="application/x-mplayer2"
pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"
bgcolor="darkblue" showcontrols="true" width="270" height="45"
src="" autostart="false" designtimesp="5311" loop="true">
</object>
</span>
</body>
</html>
AprilZan to answer your question use one of the updated scripts in this post the second one is the one you might want to use, its less bulky and is most cross browser compatable. If you want the first song to play set the filename value in the object to the first song value, and also set the src in the embed tag to the first sound value. You need to set the autostart parameter to true and the autostart attribute in the embed tag to true as well.