littlehank
10-22-2005, 10:49 PM
Can someone please fix this script for me? I don't know what I did wrong. The script is supposed to play the song you select from the dropdown menu when you hit play, and stop when you hit the stop button. Here it is:
<script language="javascript">
var aySound = new array();
sound[1] = "test1.mp3";
sound[2] = "test2.mp3";
sound[3] = "test3.wma";
sound[4] = "test4.mp3";
sound[5] = "test5.mp3";
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;
function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>
<form>
<select name="song">
<option playSound(1)>Test1</option><option playSound(2)>Test2</option><option playSound(3)>Test3</option><option playSound(4)>Test4</option><option playSound(5)>Test5</option>
</select>
<br><input type=submit value="play">
</form>
<img src="stop.gif" onmousedown="stopsound()">
Thanks,
littlehank
<script language="javascript">
var aySound = new array();
sound[1] = "test1.mp3";
sound[2] = "test2.mp3";
sound[3] = "test3.wma";
sound[4] = "test4.mp3";
sound[5] = "test5.mp3";
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;
function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>
<form>
<select name="song">
<option playSound(1)>Test1</option><option playSound(2)>Test2</option><option playSound(3)>Test3</option><option playSound(4)>Test4</option><option playSound(5)>Test5</option>
</select>
<br><input type=submit value="play">
</form>
<img src="stop.gif" onmousedown="stopsound()">
Thanks,
littlehank