8

Works fine on Chrome. Moreover, I'm using an ogg file so that's not the problem. I'm running on the latest version 9.0.1. HTML5 audio is supposed to be supported by both Chrome and Firefox.

<audio id="audio">
  <source src="audio/Your_Hand_In_Mine.ogg" type="audio/ogg" />
  <source src="audio/Your_Hand_In_Mine.mp3" type="audio/mpeg" />
  Your browser does not support the audio element.
</audio>
Tony
  • 981
  • 5
  • 16
  • 30
  • 1
    your ogg file may not be playable. try playing only the ogg. Chrome supports both mp3 and ogg. it may have skipped the ogg and went for the mp3. firefox plays ogg and wav. http://www.w3schools.com/html5/html5_audio.asp – Joseph Jan 12 '12 at 07:59
  • Interesting take on it. However, I opened up the ogg file on Chrome and it ran fine. I tried creating a .wav file and playing that on FF but without any luck. Thank you for the comment! – Tony Jan 12 '12 at 08:24
  • 1
    Does FF play ogg file standalone when opened directly from the link? Have you encoded this file yourself? – Mikko Ohtamaa Jan 12 '12 at 08:27
  • @MikkoOhtamaa It does not play the file when I opened it via FF. This is a song I downloaded from iTunes and put in an audio folder. – Tony Jan 12 '12 at 08:34
  • 2
    The encoding is probably wrong. Encode the song as Ogg Vorbis using some HTML5 audio tutorial as basis. – Mikko Ohtamaa Jan 12 '12 at 12:58
  • What happens when you load it directly? Do you get some sort of "save or open in a helper application" dialog, by any chance? – Boris Zbarsky Jan 12 '12 at 15:37
  • @MikkoOhtamaa That did the trick! I used an audio converter to convert to ogg. Thanks! – Tony Jan 13 '12 at 04:06
  • @BorisZbarsky Nope, nothing happens, strangely. – Tony Jan 13 '12 at 04:08
  • @JosephtheDreamer +1 for telling me Firefox doesn't support .mp3 but [-1 for link to w3schools](http://w3fools.com/) – AJP Jul 31 '12 at 14:08
  • Wav files can be encoded in ways that Firefox can't play – David Apr 30 '13 at 11:32

4 Answers4

8

Most servers (including those used by GoDaddy) by default don’t serve the appropriate MIME Types for OGG files. That being the case, you’ll need set the appropriate MIME Types for OGG files if you want HTML5 audio players to work correctly in Firefox. So for an Apache server, you would need to add the following to your .htaccess file:

AddType audio/ogg .oga
AddType video/ogg .ogv
AddType application/ogg .ogg

Evidently, other browsers will guess the MIME Type based on file extension if a MIME Type isn’t served.

If you want more info about this, check this page on the Mozilla Developer Network: https://developer.mozilla.org/en/Configuring_servers_for_Ogg_media

Brian Hadaway
  • 1,875
  • 14
  • 23
4

http://support.mozilla.org/en-US/questions/758978 I found this useful in my case, since I had the proper mime types and still no luck:

You can't play MP3 files with such a code in Firefox. See https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements

<audio controls="controls"> 
<source src="http://www.kevinroseworld.com/Music/OkaVanga/OkaVanga/BajeLaCalle.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>

You will have to use a normal object element to play that song in Firefox. You can look these as an example:

<object data="music.mp3" type="application/x-mplayer2" width="xxx" height="xxx"><param name="filename" value="music.mp3"></object>
<embed type="application/x-mplayer2" src="file.mp3" height="xxx" width="xxx" >
ferensick
  • 41
  • 1
2

try using some Audio libraries to deal with HTML5 audios. Because libraries handle various problems regarding html5 audios. Some libraries provide automatic fallback for flash audio if the browser is not supporting HTML5 audio. One of the best library out there is http://www.schillmania.com/projects/soundmanager2/

Raathigesh
  • 2,306
  • 3
  • 26
  • 32
-4

The solution is to properly convert the ogg file into mp3 or vice versa. The encoding was wrong when I just renamed the .ogg file to mp3, silly me. I used software called "Audacity" and "Switch" to accomplish this.

Tony
  • 981
  • 5
  • 16
  • 30
  • have to agree with op's accepted answer. i used an online converter and i could not make any variation of html5 code work in ffox (objects worked). redid the conversion with audacity and all was well. – wazz Mar 04 '13 at 16:53
  • 5
    I guess there is a first time for everything. Including seeing a negatively voted answers as the accpeted answer! – SexyBeast Aug 27 '13 at 15:43
  • I only voted down because this had nothing to do with my actual resolution to the issue. Turns out the Microsoft AAC decoder only works for set sample rates, and playback did not work on windows with firefox in 2020 because of the MSFT AAC decoder. I'm glad you resolved your particular issue. – sova Dec 15 '20 at 05:02