PDA

View Full Version : Toggle on/off embedded sound


BusterLee
11-17-2002, 10:11 PM
I have embedded a sound in one of my sites using:

<embed SRC="intro.mp3" autostart="true" loop="true" hidden="true">

However, obviously, not everyone wants sound. I am not very clear on java etc so could anyone tell me in simple terms how to allow the option to turn on/off the music whenever the visitor wants.

Perhaps via a link format or an image!!

Cheers in advance

JustAsking
11-17-2002, 11:47 PM
Try this link to Javascriptkit.com for a great script to do this:

http://www.javascriptkit.com/script/script2/soundlink.shtml

Or you can have a play with this script, I have included both play and stop links and buttons.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<head>
<SCRIPT LANGUAGE=JavaScript>
function stopSound(){
document.music.stop();
}
</SCRIPT>
</head>
<body>
<EMBED SRC="intro.mp3" autostart="true" loop="true" hidden="true" NAME="music" MASTERSOUND>
<a href="#null" onclick="stopSound();return false">Stop music</a>
<p><input type="button" value="Stop music" onclick="music.stop()"></p>
<p><a href="#null" onclick="music.play()">Play music</a></p>
<p><input type="button" value="Play music" onclick="music.play()"></p>
</body>
</html>