...

Random Music loader/refresh

Cloudski
07-15-2002, 04:40 AM
This is a script that will load a page with a random background song, plus will refresh the page when the song finishes!


<script language="javascript">
// use this script freely
// var numsong stands for the number of songs given
var nummidi = 5
day = new Date()
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*numsong
+ 1,10)
if (ran == (5))
{
song=("song source")
words=("song name")
time=("song time in seconds")
}
else if (ran == (4))
{
song=("song source")
words=("song name")
time=("song time in seconds")
}
else if (ran == (3))
{
song=("song source")
words=("song name")
time=("song time in seconds")
}
else if (ran == (2))
{
song=("song source")
words=("song name")
time=("song time in seconds")
}
else if (ran == (1))
{
song=("song source")
words=("song name")
time=("song time in seconds")
}
document.write('<meta http-equiv="refresh" content="' + time + '; URL=npmusic.html">')
document.write('<EMBED SRC= "' + song + '" CONTROLS=smallconsole HEIGHT=45 WIDTH=290 AUTOSTART=TRUE LOOP=FALSE VOLUME=100%>')
document.write('<br>You are listening to ' + words + ' ')
</SCRIPT>


This script was made for a small pop-up window to have nothing but the song file in it. Also, you use this script in the <body> of the file. (Yes, the meta tag works there)

Hope someone can make use of it
:D

jscript_junkie
07-15-2002, 10:49 AM
Very creative!!! 5/5 stars!

Cloudski
07-15-2002, 11:16 AM
:o I noticed a small error... where it says nummidi, that is supposed to be numsongs... in case you couldn't figure out yourself :rolleyes:

jscript_junkie
07-15-2002, 07:11 PM
Didn't even notice it. I just read the main parts of the code, like the meta tag. And how you wrote out the song title. That mistake doesn't cost you a star, so it's still 5/5 :D

Cloudski
07-16-2002, 02:50 AM
I am not fully deserving of such praise. I did not make the main part of the code:


var numsong = 5
day = new Date()
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*numsong
+ 1,10)


I in fact got an origional layout and well, added the auto refresh and cleaned up the if-else statements... (If I left them the way the code origionally was, there would be 15 if statments :D )

So, I give out praise to whoever made up the origional code!!!

jscript_junkie
07-16-2002, 04:37 AM
That's still a lot more than I can do. I can only cut and paste. I can only make minor edits to JavaScripts, like when I see a document.write. I wouldn't have thought up using variables and stuff. I think I could learn how, but JavaScript isn't really important to me. :)

Cloudski
07-22-2002, 05:57 AM
I have found something out.... If you refresh the page manually, without letting the script run alone, it will not do the refresh anymore... The only way to get the script running again, would be to close, then re-open the window with the script....

jscript_junkie
07-22-2002, 06:03 AM
Probably needs a "return false" on the keypress event. Or, you could try:

<body onkeypress="stop()">

function stop(){return false;}

Syntax might not be right, but the above is what I think is right...sigh :D I'm sure I'll learn it sooner or later :rolleyes:

<edit my="post">I thought I'd debut a new signature. It's funny :-)</edit>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum