Loading ...
Sorry, an error occurred while loading the content.

Playing a sound

Expand Messages
  • Fernando (UK)
    Considering the user has the appropriate plugin installed, what is the best way to play a sound using javascript? This is not working for me in FF or IE:
    Message 1 of 6 , Apr 1, 2006
    • 0 Attachment
      Considering the user has the appropriate plugin installed, what is the
      best way to play a sound using javascript?

      This is not working for me in FF or IE:

      Javascript:
      document.getElementById('EMAIL_WARNING_SOUND').src =
      'sound/new_message_english.wav';

      HTML:
      <iframe id="EMAIL_WARNING_SOUND" name="EMAIL_WARNING_SOUND" src=""
      style="visibility:hidden; display:none"></iframe>
    • f3l
      On Sat, 01 Apr 2006 06:43:26 -0500, Fernando (UK) ... and it shouldn t, u must use bgsound I m not sure about that being standard, so I wouldnt recommend it.
      Message 2 of 6 , Apr 1, 2006
      • 0 Attachment
        On Sat, 01 Apr 2006 06:43:26 -0500, Fernando (UK)
        <fernandosouzaphp@...> wrote:

        > Considering the user has the appropriate plugin installed, what is the
        > best way to play a sound using javascript?
        >
        > This is not working for me in FF or IE:
        >

        and it shouldn't, u must use bgsound
        I'm not sure about that being standard, so I wouldnt recommend it.
        people are anoyed by the sounds in webpages, so I'd recommend something
        different.

        1. use flash
        2. do NOT use wav, try compressing it in mp3 or something,
        WAVs are way too heavy, and people are more likely not to wait for it.


        > Javascript:
        > document.getElementById('EMAIL_WARNING_SOUND').src =
        > 'sound/new_message_english.wav';
        >
        > HTML:
        > <iframe id="EMAIL_WARNING_SOUND" name="EMAIL_WARNING_SOUND" src=""
        > style="visibility:hidden; display:none"></iframe>
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >



        --
        Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
      • Fernando (UK)
        Actually the sound is not to annoy anyone, the user can choose if he wants to hear the sound when the message comes or not. And, yes, I am using .mp3 I got to
        Message 3 of 6 , Apr 3, 2006
        • 0 Attachment
          Actually the sound is not to annoy anyone, the user can choose if he
          wants to hear the sound when the message comes or not.
          And, yes, I am using .mp3

          I got to solve my problem using <embed>, which is cross-browser, like
          following:

          HTML:
          <span id="SOUND_SPAN"></span>

          JavaScript:

          function DHTMLSound(surl) {
          document.getElementById("SOUND_SPAN").innerHTML="<embed src='"+surl+"'
          hidden='true' autostart='true' loop='false'>";
          }

          // Sound of new message
          var sound_file = 'sound/new_message_sound.mp3';
          DHTMLSound(sound_file); // To play


          f3l escreveu:

          >On Sat, 01 Apr 2006 06:43:26 -0500, Fernando (UK)
          ><fernandosouzaphp@...> wrote:
          >
          >
          >
          >>Considering the user has the appropriate plugin installed, what is the
          >>best way to play a sound using javascript?
          >>
          >>This is not working for me in FF or IE:
          >>
          >>
          >>
          >
          >and it shouldn't, u must use bgsound
          >I'm not sure about that being standard, so I wouldnt recommend it.
          >people are anoyed by the sounds in webpages, so I'd recommend something
          >different.
          >
          >1. use flash
          >2. do NOT use wav, try compressing it in mp3 or something,
          >WAVs are way too heavy, and people are more likely not to wait for it.
          >
          >
          >
          >
          >>Javascript:
          >>document.getElementById('EMAIL_WARNING_SOUND').src =
          >>'sound/new_message_english.wav';
          >>
          >>HTML:
          >><iframe id="EMAIL_WARNING_SOUND" name="EMAIL_WARNING_SOUND" src=""
          >>style="visibility:hidden; display:none"></iframe>
          >>
          >>
        Your message has been successfully submitted and would be delivered to recipients shortly.