Hi Everybody!
I'm trying to create a checkbox that, when checked, loops a soundfile and when unchecked, stops the sound file. So basically "checked=play", "unchecked=stop". I have some simple javascript code that works by using two separate buttons, one for play and one for stop. But I would like this to be controlled by a single checkbox. Simple code below. Any ideas? Thanks in advance!
<!DOCTYPE html>
<head>
<script type="text/javascript">
/*-----this code asks whether the button contains var "start" or "stop" and plays, stops accordingly----*/
function EvalSound(soundobj,check){
var thissound=document.getElementById(soundobj);
if(check=="start")
{
thissound.Play();
}
else if(check=="stop")
{
thissound.Stop();
}
}
</script>
<body>
<embed src="SOUND.MP3" loop='true' autostart='false' width='0' height=0' id="sound" enablejavascript="true" />
<button class="start" onclick="EvalSound('sound','start');">start</button>
<button class="stop" onclick="EvalSound('sound', 'stop');">stop</button>
<br/>
</body>
</html>