Fix ogg/oga not play in Firefox 3.6

Tue 15 February 2011
  • 把戏 tags:
  • apache
  • firefox
  • html published: true comments: true

Native audio support was introduced in since Firefox 3.5 . Ogg is one of the media format supported by Firefox. However, sometimes you may find it doesn't work even if you set the right source path. And you just check the network status of audio element:

document.getElementsByTagName("audio")[0].networkState

Then you get the constant of a 4, which is HTMLMediaElement.NETWORK_NO_SOURCE.

This is because firefox checks the Content-Type header to make sure it's a media file. (Webkit based browsers don't have this restriction.) However, ogg format is not configured on most http servers. You can check the content type by: curl -I <url-to-media-file>

Take Apache as example, you can add following content to your configuration file: AddType audio/ogg .oga AddType video/ogg .ogv .ogg

For more, check this article: https://developer.mozilla.org/en/Configuring_servers_for_Ogg_media