Debt Consolidation - Debt Consolidation - Kamala Harris - Myspace Layouts - Bad Credit Loans

PDA

View Full Version : Adding Music to a website?


livingearth
Jul 4th 2008, 12:30 pm
I have a script that adds a drop down select box to a website which chooses a background music file to be played..
How can I get this script to start automatically with out losing its functionality?


<div style="position:absolute;top:-5px;left:0px;">
<Table width=90% border=0 align=right valign=top><tr><td align=right valign=top><form name=choose>
<font color=white>
<select style="background-color: darkgray;"size=1 onChange="midiplay(this);">
<option value="#">Select Music
<option value="C:\WINDOWS\system32\oobe\images\title.wma" selected="selected">Intro
<option value="./tunes/indian_summer.mp3">Indian Summer
<option value="./tunes/Kenny G - Songbird.mp3">Songbird
</select>
</form></center>
</td></tr></table></div>



<script language="JavaScript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

document.write('<bgsound src="#" id=midijuke LOOP=INFINITE VOLUME = -500 autostart="true">');

function midiplay(what) {
if (document.all) {
document.all.midijuke.src = what.options[what.selectedIndex].value;
}

else {
alert("Sorry, but the Music Menu is only accessible through MSIE4.0 and above.");
}
}

//-->
</script>

zyklon
Jul 4th 2008, 1:17 pm
make the <select> have an onchange attribute, that runs a javascript script that changes what the song is.

edit: it looks like ur already doing that... i am not sure what ur problem is then...

=Messa=
Jul 4th 2008, 3:33 pm
What do you mean by start the script automatically?

Do you want the script to start automatically when the page loads?

Well, there are many ways you can do it. I'll show you one.

Put this after the "midiplay" function:
document.all.midijuke.src="path\to\media\file";

Or better, put this as an attribute to "body" open-part tag:
onload="document.all.midijuke.src='path\to\media\file';"
<body onload="document.all.midijuke.src='path\to\media\file';">

Of course, replace path\to\media\file with the real path to a file.

livingearth
Jul 4th 2008, 5:10 pm
@Messa
I tried the body onload idea but I was not able to get it to work..
Thanks it was a good idea..

=Messa=
Jul 4th 2008, 6:02 pm
Well, it works and should work for you.

Can you show me what path you're putting there?

If e.g. you're trying "C:\sample.mp3", you need to put there "C:\\sample.mp3", with two backslashes.

livingearth
Jul 5th 2008, 11:53 am
@Messa
Here is the code I have now..
Tryit on your desktop. If you are using XP the Intro music file should already be on your computer at the specified location..

=Messa=
Jul 5th 2008, 1:26 pm
I don't see any code.

@Messa
Here is the code I have now..
Tryit on your desktop. If you are using XP the Intro music file should already be on your computer at the specified location..

livingearth
Jul 5th 2008, 4:41 pm
Opps .. Dinner was calling...:)


<html><head></head>

<body bgcolor="#000000"onload="document.all.midijuke.src='C:\\WINDOWS\system32\oobe\images\title.wma';">

<div style="position:absolute;top:-5px;left:0px;">
<Table width=90% border=0 align=right valign=top><tr><td align=right valign=top><form name=choose>
<font color=#ffffff>
<select style="background-color: charcoal;"size=1 onChange="midiplay(this);">
<option value="#">Select Music
<option value="C:\WINDOWS\system32\oobe\images\title.wma" selected="selected">Intro
<option value="./tunes/indian_summer.mp3">Indian Summer
<option value="./tunes/Kenny G - Songbird.mp3">Songbird
</select>
</form></center>
</td></tr></table></div>

<bgsound src="#" id=midijuke LOOP=INFINITE VOLUME = -500 autostart="true">

<script language="JavaScript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com



function midiplay(what) {
if (document.all) {
document.all.midijuke.src = what.options[what.selectedIndex].value;
}

else {
alert("Sorry, but the Music Menu is only accessible through MSIE4.0 and above.");
}
}

//-->
</script>

</body></html>