PDA

View Full Version : Sound file in drop menu



mailtosaleh
03-13-2007, 07:06 AM
I have this drop menu for audio files, I need it because there is small space in my page, But it is not working for me, it is supposed to play sound file by just chose the song,


<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Nicholas Loar -->
<!-- Web Site: http://www.cass.net/~anarchy -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
songNum = new Array();
songNum[0] = "001.mp3";
songNum[1] = "002.mp3";
songNum[2] = "003.mp3";
songNum[3] = "004.mp3";

var music = null;
var track = 0;
var ver = navigator.appName;
function audioCheck(plugName) {
for (var i = 0; i < navigator.plugins.length; i++) {
if (navigator.plugins[i].name.toLowerCase() == plugName.toLowerCase())
{ for (var j = 0; j < navigator.plugins[i].length; j++) {
if (navigator.plugins[i][j].enabledPlugin) {
return true;
}
}
return false;
}
}
return false;
}
function chooseSong(s) { // ie
track = s.options[s.selectedIndex].value;
if (ver == "Microsoft Internet Explorer") {
document.all.music.src = songNum[track];
} else {
songPlay('play');
}
}
function songPlay(cmd) { // netscape
if (audioCheck("LiveAudio")) {
if (cmd == 'play') {
document.musicSource.play(false, songNum[track]);
}
} else {
alert("You Do Not Have The Correct Plugin");
}
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form name=choose>
<select size=1 name=track
onChange="chooseSong(this);">
<option value="0">ABC</option>
<option value="1">ABD</option>
<option value="2">ABE</option>
<option value="3">ABF</option>
</select>

</form>

<script language="JavaScript">
<!-- Begin
var ver = navigator.appName;
if (ver == "Microsoft Internet Explorer") {
document.write('<bgsound src="#" ID=music loop=1
AUTOSTART=true>');
} else {
document.write('<embed type="audio/midi"
src="new.mid" AUTOSTART=false
hidden=false VOLUME="90" name="musicSource" MASTERSOUND></EMBED>');
}
// End -->
</script>



Please I need this or something smiler to it to play sound files


Thanks for Help