Click to See Complete Forum and Search --> : I am new to this kinda and have a question.....


Computerman45
11-05-2003, 10:27 PM
I realize this is very rough ... and it doesn't work ....

I put it in an external file for easier editing:

<!--Check if music is playing-->
function checkMusic() {
if music=on
javascript:stopMusic()
else
javascript:playMusic()
}

<!--Stop Music-->
function stopMusic() {
document.Music.stop();
var music=off;
}

<!--Play Music-->
function playMusic() {
document.Music.play();
var music=on;
}


I want this to work so all a person has to do is click on a little music button and turn the sound on or off. Also could you post a <EMBED> example that will set the begining variable of music=on ? I hope someone can help.... Please note: the smiley in the code is realy : playMusic (Without space)

AdamBrill
11-05-2003, 11:01 PM
To set the music variable to on, I would just set it in the JS(since the music will automatically start). Try this instead of what you have:music="on";
<!--Check if music is playing-->
function checkMusic() {
if (music==on){
stopMusic();
}else{
playMusic();
}

<!--Stop Music-->
function stopMusic() {
document.Music.stop();
var music=off;
}

<!--Play Music-->
function playMusic() {
document.Music.play();
var music=on;
}

Computerman45
11-06-2003, 07:51 AM
I tried that and it still said line 89 object expected:
here is the code....
<SCRIPT language="JavaScript">
music="on";
<!--Check if music is playing-->
function checkMusic() {
if (music==on){
stopMusic();
}else{
playMusic();
}

<!--Stop Music-->
function stopMusic() {
document.Music.stop();
var music=off;
}

<!--Play Music-->
function playMusic() {
document.Music.play();
var music=on;
}
</Script>

and here is my EMBED:
<EMBED src="SOUNDNAME.wav" name="Music" autostart="true" hidden="true" loop="true" MASTERSOUND>

The music does not loop with either ="true" or with ="infinite" what could be wrong?

AdamBrill
11-06-2003, 08:38 AM
Try this:<script type="text/javascript">
music="on";
<!--Check if music is playing-->
function checkMusic() {
if (music=="on"){
stopMusic();
}else{
playMusic();
}
}

function stopMusic() {
document.Music.stop();
music="off";
}

function playMusic() {
document.Music.play();
music="on";
}
</script>

<EMBED src="soundfile.wav" name="Music" autostart="true" hidden="true" loop="true" MASTERSOUND>

Computerman45
11-12-2003, 01:58 PM
We are so close to getting it to work ... but it still does not turn the music back on, it turns it off, but not back on... I get this error. (See Attached file)

Computerman45
11-17-2003, 07:04 PM
I got to thinking, and noticed it wasn't the scripts fault .... I was using a .wav file, which doesn't like to loop or use the play() function. Thanks, changed the file to a .mid file, works great! Thanks for your help!