2

This code works fine in Chrome But it doesn't produce audio in Firefox. I'm testing from file:// and not http://. I placed an alert in the playSound function and passed it the audio parameter. It returned the audio div id for all buttons like it should. I'm stumped at this point and any suggestions would be great.

 <li id="siren" class="app_button">
   <img src="img/siren.png" alt=""
     name="siren_pressed" width="102" height="102"
     onmousedown="press('siren_pressed')" 
     onmouseup="release('siren_pressed'), playSound('siren_audio')">
   <audio id="siren_audio">
     <source src="audio/siren.ogg" type="audio/ogg">
     <source src="audio/siren.mp3" type="audio/mpeg">
   </audio>
 </li>

  /* Javascript is in a seperate folder */

  function playSound(audio)
  {
    var sound = document.getElementById(audio);
    sound.play();
  }
CLKT
  • 31
  • 4
  • Did you check this thread...just in case...: http://stackoverflow.com/questions/8831625/html5-audio-not-working-on-firefox – Golmaal Jan 19 '12 at 06:16
  • Yes I did check that thread. It didn't help. – CLKT Jan 19 '12 at 06:22
  • I went back through the thread you referred me to. I tried playing the .mp3 file directly and it worked fine. The .ogg file brought up a grey box with an 'x' in it. I clicked the 'x' and it turned into an audio player but would not play the file. I now have something to troubleshoot. Thanks for re-railing my efforts. – CLKT Jan 19 '12 at 22:22

1 Answers1

1

Solved! It was the .ogg files. I originally converted them from mp3 to ogg using ffmpeg in the command line. Testing audio on its own in the browser showed issues with ogg on both chrome and firefox. I downloaded a different sound converter and tried again. This time the ogg files play with out issue on both browsers. Thanks @Golmaal for pointing me in the right direction.

CLKT
  • 31
  • 4