PDA

View Full Version : Anyone Knows How To Make A Stop Background..



Crack_man
11-13-2003, 07:01 PM
I have made a homepage with random background music but sometimes I want to turn the background music off cause I am listening to something else,

I know that I can just hit the stop button which is next to the "Refresh" button but I have made my own picture which I would like to use as a "on/off" button.

This is the random background script I have:

<script>
<!--
//By JavaScript Kit (http://www.javascriptkit.com) More JavaScripts here!
var sound1="sound/onestepcloser.mid"
var sound2="sound/again.mid"
var sound3="sound/waitand.mid"
var sound4="sound/changes.mid"
var sound5="sound/crawling.mid"
var x=Math.round(Math.random()*4)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else x=sound5
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')
else
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
//-->
</script>

Now I just want to have a ON/OFF button but I would like to use my own picture as button.

~FunK_mOb~
11-13-2003, 07:09 PM
shouldn't this be better of in softwareworld or development? :huh:
I think you'll get more replies than in the lounge. :unsure:

Crack_man
11-13-2003, 11:13 PM
Originally posted by ~FunK_mOb~@13 November 2003 - 20:09
shouldn't this be better of in softwareworld or development? :huh:
I think you'll get more replies than in the lounge. :unsure:
I dont know, I dont think this has anything with software or development to do.

Lamsey
11-13-2003, 11:16 PM
It is software-related, so it's going there.

Personally, I wouldn't use background music in a webpage - it's supremely annoying.

SniperInTheShadows
11-13-2003, 11:25 PM
I know this is not the perfect solution to the problem, but if you can't find out how to make your stop button work then perhap's you could just make a small and empty .wav file which the stop button play's once and then stops instead to make it act like a stop button?

Sniper.

EDIT : Got distracted by the tele and forgot the "." on ".wav" lol

I.am
11-14-2003, 12:13 AM
That script is junk. I would prefer writing my own.

I.am
11-14-2003, 12:14 AM
Give me few mins :)

I.am
11-14-2003, 12:19 AM
<script>

// Written by I.am
// for Crack man coz he was using junk script
//****Script****-->
var numberofmid = 2
day = new Date()
myseed = day.getTime()
random = parseInt(((myseed - (parseInt(myseed/1000,10) * 1000))/10)/100*numberofmid + 1,10)

if(random== (1))
midi = ("soundsrcfile1.mid")
if(random==(2))
midi = ("soundsrcfile2.mid")
if(random == (3))
midi = ("soundsrcfile3.mid")

//Make sure to put the right value in numberofmid. If you have 10 mid files then initialize numberofmid = 10
//Add as many random files you want. Increase random by 1 and keep adding the source files.

document.write('<EMBED SRC= "' + midi + '" WIDTH=200 HEIGHT=55 AUTOSTART=TRUE>')
document.write('<BGSOUND SRC= "' + midi + '" loop=infinite AUTOSTART=TRUE>')
//<--End of Script, By I.am

</SCRIPT>

Copy it to your page. In place of soundsrcfile give the path to your mid file.

B)
I.am

ps: Btw, this will be truly random. Almost impossible to predict which mid will be played as compared to that simple Math.random() function.

Second Edit: I forgot to mention what this will do. It will have a player on your page where you can control your mid. Play, Pause, Stop, Forward etc. all in there inbuilt.

Crack_man
11-14-2003, 06:21 AM
Originally posted by I.am@14 November 2003 - 01:19

<script>

// Written by I.am
// for Crack man coz he was using junk script
//****Script****-->
var numberofmid = 2
day = new Date()
myseed = day.getTime()
random = parseInt(((myseed - (parseInt(myseed/1000,10) * 1000))/10)/100*numberofmid + 1,10)

if(random== (1))
midi = ("soundsrcfile1.mid")
if(random==(2))
midi = ("soundsrcfile2.mid")
if(random == (3))
midi = ("soundsrcfile3.mid")

//Make sure to put the right value in numberofmid. If you have 10 mid files then initialize numberofmid = 10
//Add as many random files you want. Increase random by 1 and keep adding the source files.

document.write('<EMBED SRC= "' + midi + '" WIDTH=200 HEIGHT=55 AUTOSTART=TRUE>')
document.write('<BGSOUND SRC= "' + midi + '" loop=infinite AUTOSTART=TRUE>')
//<--End of Script, By I.am

</SCRIPT>

Copy it to your page. In place of soundsrcfile give the path to your mid file.

B)
I.am

ps: Btw, this will be truly random. Almost impossible to predict which mid will be played as compared to that simple Math.random() function.

Second Edit: I forgot to mention what this will do. It will have a player on your page where you can control your mid. Play, Pause, Stop, Forward etc. all in there inbuilt.
I appreciate that you trying to help me but as I said,I would like to use my own button I have made which I can just turn on/off music.

I.am
11-14-2003, 06:52 AM
Well this was the more efficient method. However, as someone else suggested you can have a blank midi and just call that midi when you click stop button. Make another function stop() and call midi in that. Call the stop() on click of the button.

Crack_man
11-15-2003, 12:05 AM
Originally posted by I.am@14 November 2003 - 07:52
Well this was the more efficient method. However, as someone else suggested you can have a blank midi and just call that midi when you click stop button. Make another function stop() and call midi in that. Call the stop() on click of the button.
I AM EINSTEIN.
I know how to make it work now,its very simple.
I copied the whole code of the page where I had my sound script and then removed the background sound script and then saved it as a new page,
then I used 2 buttons to turn off/on music,
I linked one button to the page without the music script which of course turned off the music and used my "OFF" button,the other one was linking to the original page with the music which was my "ON" button.


I prefer using 1 button to turn off/on but I guess this is the easiest way.

I.am
11-15-2003, 12:08 AM
http://www.mcbriens.net/liam/img/smilies/roflmao.gifhttp://www.mcbriens.net/liam/img/smilies/roflmao.gifhttp://www.mcbriens.net/liam/img/smilies/roflmao.gifhttp://www.mcbriens.net/liam/img/smilies/roflmao.gifhttp://www.mcbriens.net/liam/img/smilies/roflmao.gifhttp://www.mcbriens.net/liam/img/smilies/roflmao.gif

I.am
11-15-2003, 02:02 AM
If the page was only for you, then whats wrong using a player integrated in the page? using the script i suggested.

Even einstein will pee his pants laughing reading what you did.
But if it works you good B)
Cheers
I.am

Crack_man
11-15-2003, 02:49 AM
Originally posted by I.am@15 November 2003 - 03:02
If the page was only for you, then whats wrong using a player integrated in the page? using the script i suggested.

Even einstein will pee his pants laughing reading what you did.
But if it works you good B)
Cheers
I.am
the homepage I did was not just for me,in fact it is not even mine,I did the homepage to my brother.

ooo
11-15-2003, 02:50 AM
i used that too... my way to do it was make a frame...

i dont exactly remember frameset scripts... but the two horizontal ones...
you set the 2nd number to 0... so the frame doesnt show... then you can have a link that changes that page...

if you dont get it pm me and i can write up the files

Crack_man
11-16-2003, 02:28 AM
Originally posted by Soul814@15 November 2003 - 03:50
i used that too... my way to do it was make a frame...

i dont exactly remember frameset scripts... but the two horizontal ones...
you set the 2nd number to 0... so the frame doesnt show... then you can have a link that changes that page...

if you dont get it pm me and i can write up the files
that is what I did too with a small frame.