View Full Version : sound with javascript?
alaios
08-25-2002, 08:59 PM
I want to play a sound file using Javascript ....How can i do this?
Try something like this:
<EMBED
SRC="mysong.mid"
HIDDEN=true
AUTOSTART=true
REPEAT=true
height="0"
width="0">
<NOEMBED>
<BGSOUND SRC="mysong.mid" loop="infinite">
</NOEMBED>
GDS
zoobie
08-25-2002, 10:03 PM
That's an excellent way to make your visitors leave immediately!.
For Pete's sake and your visitors, don't start the muzik when they enter...and use an "On/Off" button/link, too.
<embed id="plyr" width="0" height="0" autostart="false" loop="true" src="lol.wav"><b>
<a href="javascript: document.getElementById('plyr').play();">start</a>
<a href="javascript: document.getElementById('plyr').stop();">stop</a>
I am having trouble trying to use your code with netscape. Whenever I do I get the following error:
Error: document.getElementById("plyr").play is not a function
What am I doing wrong?
NH
whammy
11-24-2002, 02:01 PM
Are you using Netscape 4.x ?
Only modern browsers use getElementById(), Netscape 4.x is obsolete now. ;)
kwhubby
11-25-2002, 05:48 AM
how would you make it so that the sound playes once, and than the sound can be repeated when wanted, or changed to a different sound and repeated.
would it just be making the loop = "false" and when the play() is used it would play it once, and play again when the play() is used again?
this could be useful for making a game, or somekind of javascript menue that makes sound
kwhubby
11-25-2002, 05:52 AM
scratch that question, I just solved it myself. (the answer is true)
ConfusedOfLife
11-25-2002, 08:51 AM
Are you using Netscape 4.x ?
Only modern browsers use getElementById(), Netscape 4.x is obsolete now.
I'm using IE6 ( WinXP ) and I get the same error message!
zoobie
11-25-2002, 06:41 PM
Who dug this old thread up? :rolleyes:
ConfusedOfLife
11-25-2002, 07:38 PM
HANDS UP! IT WASN'T ME!!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.