PDA

View Full Version : Help with RANDOM MUSIC Script


mikevaleriani
11-05-2002, 07:29 PM
Hello,
I am using this script in my site, but in order to hear a new music the visitor must reload the page. Does anyone know hot to make it play music randomly (like it's doing) and play a different midi when the first one is over?

Here is the script:


<SCRIPT LANGUAGE="JavaScript">
<!--
soundnum = 8;
music = new Array();
music[0]="ififall.mid";
music[1]="imagine.mid";
music[2]="tiltherewasyou.mid";
music[3]="carlo.mid";
music[4]="newyork.mid";
music[5]="iwill.mid";
music[6]="white.mid";
music[7]="careless.mid";
music[8]="yesterday.mid";

soundRnd = Math.floor(Math.random()*soundnum);
Em1='<EMBED src="./midi/';
Em2='" LOOP="true" REPEAT="true" AUTOSTART="true"';
Em3=' WIDTH="0" HEIGHT="0" HIDDEN = "true" >'
document.write(Em1+ music[soundRnd] +Em2+Em3);
//-->
</SCRIPT>


Thank you so much for your time,
Mike

www.mikevaleriani.com

beetle
11-05-2002, 08:09 PM
Well, a guy over in this thread (http://www.codingforums.com/showthread.php?s=&threadid=4112&highlight=midi) learned that you can find out the length of the song and the current position. Seems like those could be used with a setTimeout or loop or something to get what you want. I haven't messed with these myself, so best of luck with your experiemnt!

kwhubby
11-06-2002, 06:08 AM
:)
you could make an iframe, or a frame, or a layer that has your sound object writen into it.
frameName..document.write()


(note, forgive me if that has a bug, if its not correct, tell me and I'll look it up)
if you need something to auto refresh just use this
location.href = location.href

and you may need to do a document.close() to tell the browser that the write function is complete.
frameName.document.close()

glenngv
11-06-2002, 07:03 AM
in the thread linked by beetle, this doesn't work:

for (variable in document.all.embedName) {
alert(variable+" -->" + document.all.embedName[variable]);

}


i got it to work like this:

<embed name="movName" id="movID" src="mov.MPG" width="200" height="200" autostart="false" ></embed><br>
<script>
for (variable in document.embeds[0])
document.write(variable + " = "+document.embeds[0][variable]+"<br>")
</script>

but i can't see the properties CurrentPosition and Duration as the thread starter suggested :confused: