sound width javascript

Discussion in 'Javascript' started by Gandalf, Aug 24, 2007.

  1. Gandalf

    Gandalf Guest

    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
     
    Gandalf, Aug 24, 2007
    #1
    1. Advertising

  2. Gandalf wrote:
    > 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
     
    Thomas 'PointedEars' Lahn, Aug 24, 2007
    #2
    1. Advertising

  3. Gandalf

    Gandalf Guest

    On Aug 24, 11:03 am, Thomas 'PointedEars' Lahn <>
    wrote:
    > Gandalf wrote:
    > > 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!
     
    Gandalf, Aug 24, 2007
    #3
  4. Gandalf wrote:
    > 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
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Aug 24, 2007
    #4
  5. Gandalf

    elephant Guest

    On Aug 24, 3:58 am, Gandalf <> wrote:
    > 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.
     
    elephant, Aug 24, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    844
    Bruce Barker
    Oct 10, 2005
  2. Xu
    Replies:
    11
    Views:
    8,658
    Andrew Thompson
    Jul 16, 2005
  3. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,515
    Andrew Thompson
    Oct 31, 2005
  4. Replies:
    0
    Views:
    561
  5. Sean Jorden
    Replies:
    1
    Views:
    624
    laurie
    Aug 19, 2003
Loading...

Share This Page