sound width javascript

G

Gandalf

I need to create sound with Javascript. Until now all the code I have
been trying doesn't work width Firefox. can some one please show me
how to do it, or give me a link to a good article?

thanks
 
T

Thomas 'PointedEars' Lahn

Gandalf said:
I need to create sound with Javascript.

Generally, you cannot do that with a Web browser. You can create (X)HTML
elements that refer audio media and/or you can access plugin APIs to play
that audio media.
Until now all the code I have been trying doesn't work width Firefox.

"Does not work" is a useless error description. [psf 4.11]

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork
can some one please show me how to do it [...]

Show the relevant part of your code, or post a URL of a test case.


PointedEars
 
G

Gandalf

Gandalf said:
I need to create sound with Javascript.

Generally, you cannot do that with a Web browser. You can create (X)HTML
elements that refer audio media and/or you can access plugin APIs to play
that audio media.
Until now all the code I have been trying doesn't work width Firefox.

"Does not work" is a useless error description. [psf 4.11]

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork
can some one please show me how to do it [...]

Show the relevant part of your code, or post a URL of a test case.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

OK this is my element

<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="IncomingIM.mp3">
<EMBED NAME="Bach" id="Bach" SRC="IncomingIM.mp3"
LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>

this is the function

function playSound() {
document.all['BGSOUND_ID'].src='IncomingIM.mp3';
document.getElementById('bach').play(false)
}
it works only on IE
thank you!
 
T

Thomas 'PointedEars' Lahn

Gandalf said:
OK this is my element

<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="IncomingIM.mp3">
<EMBED NAME="Bach" id="Bach" SRC="IncomingIM.mp3"
LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>

http://validator.w3.org/ will tell you that neither element is part of any
standard. Use the `object' element instead.
this is the function

function playSound() {
document.all['BGSOUND_ID'].src='IncomingIM.mp3';

document.all is another IE-ism that is only recently partially supported
by Gecko-based UAs in Quirks Mode (a bad move IMHO). Standards compliant
referencing won't help much here though, because the underlying markup is
not standards compliant.
document.getElementById('bach').play(false)

This might work if the element object reference could be retrieved (that is
assuming the proprietary `embed' element is reflected in the DOM) and the
used plugin had a play() method. But you don't tell which media player
plugin you use, let alone the UA where you have tested this to fail, or what
error messages you get. Read the FAQ Notes section I pointed you to, again.
}
it works only on IE

That is not surprising, most of this is MSHTML-only. But which of the
numerous IE versions have you tested with? Which other UAs have you tested
with? Again, you are providing far too little information for an analysis.


PointedEars
 
E

elephant

I need to create sound with Javascript. Until now all the code I have
been trying doesn't work width Firefox. can some one please show me
how to do it, or give me a link to a good article?

If you're willing to spend $5 (I think, maybe just $1), you can go to
www.istockphoto.com and download a Flash sound player. Most don't
require you to have Flash, and just have an XML file you can edit with
the URL of the audio you'd like to play. There are others free online
but the ones I've seen require you have Flash to edit the file.

It wont play on computers that don't have Flash installed, but, most
do these days.

If you need more info, or a specific link to one I've used before, let
me know. I didn't post one because the design may not match your
site, and I'm a bit worried people will think I'm linking to one of my
own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top