Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to controle playing of sounds.

controling sound (IE)

How to controle playing of sounds.

by  N3XuS  Posted    (Edited  )
1st off:
You could controle sound using next methods:

<script>
function start() {
document.all.sound.play();
//document.all.sound.stop();
}
</script>
<body onload="document.all.sound.play()">
<embed src="sound.wav" autoplay="true" name="sound"></embed>
<A href="#" onmouseover="start()">START</A>
</body>
this doesn't seem to work on all PCs though, probably has something to do with sounds being played by different plugins. Both my PCs that had realplayer installed wouldn't accept the play() and stop() methods.

A workaround this problem is each time you wanna start a sound and stop it , re-initiate the sound source and times it has to loop.
1: put ur sound as backgroundsound.
<bgsound src="#" id=sound loop=1 autostart="true">
2: to start the sound do
document.all.sound.loop=5000
document.all.sound.src= 'typewriter.wav'
to stop the sound do
document.all.sound.loop=0
document.all.sound.src= 'typewriter.wav'

it may not be the cleanest solution, but it seemed to work on all my PCs running IE.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top