...

View Full Version : sound with javascript?



alaios
08-25-2002, 09:59 PM
I want to play a sound file using Javascript ....How can i do this?

GDS
08-25-2002, 10:15 PM
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, 11: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>

noel
11-24-2002, 05:07 AM
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, 03:01 PM
Are you using Netscape 4.x ?

Only modern browsers use getElementById(), Netscape 4.x is obsolete now. ;)

noel
11-24-2002, 10:18 PM
Netscape 7.0

kwhubby
11-25-2002, 06: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, 06:52 AM
scratch that question, I just solved it myself. (the answer is true)

ConfusedOfLife
11-25-2002, 09: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, 07:41 PM
Who dug this old thread up? :rolleyes:

ConfusedOfLife
11-25-2002, 08:38 PM
HANDS UP! IT WASN'T ME!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum