Category Archives: Apache

Making HTML5 AAC audio work

Web authors may be leaping to use the simple media embedding that HTML5 offers them: but there is a problem generated by the strictness of Microsoft’s Internet Explorer 9. It is particularly fussy, far more so than Google Chrome, about the mime-type of the media file.

As an example, a web page that includes this code:

<audio src="http://johnwarburton.net/aria.mp4" controls="true">

won’t play on Internet Explorer 9 when the file is served by an off-the-shelf Apache server running on Red Hat or Centos. The expected audio controls are replaced by a red cross. However, IE9 has the tools to analyse the problem (and, for that matter, so does Google Chrome, though the audio played first time). By pressing F12 and selecting the Console tab, one may query the Document Object Model for the error held by the audio object:

document.getElementsByTagName("audio")[0].error.code

One may need to adjust the index following ‘audio’ if the tag in question is not the first <audio> tag on the page. The error codes returned mean this:

  • MEDIA_ERR_ABORTED : 1
    The fetching process for the media resource was aborted by the user.
  • MEDIA_ERR_DECODE : 3
    An error has occurred in the decoding of the media resource, after the resource was established to be usable.
  • MEDIA_ERR_NETWORK : 2
    A network error has caused the user agent to stop fetching the media resource, after the resource was established to be usable
  • MEDIA_ERR_SRC_NOT_SUPPORTED : 4
    The media resource specified by the ‘src’ parameter was not usable.
The stock Apache server on Red Hat or Centos generates error 4 on an mp4 AAC audio file, and further investigation, again entirely within Internet Explorer 9, reveals the problem to be the server not sending the mime-type header which IE9 expects. Other browsers look at the file itself, but not IE9. Again, within the F12 debugging window, one may select the ‘Network’ tab, click the ‘Start Capture’ button, and reload the page to see the mime-types actually sent by the server. If the audio file doesn’t have type ‘audio/mp4’, the server’s mime-types file needs to be reconfigured to send it.
On the server, one needs to add this line to mime-types:
audio/mp4                       mp4

then restart the Apache server

service httpd restart

This cured the problem here.

Acknowledgement for this information is gladly given to the following blog from Microsoft: http://blogs.msdn.com/b/thebeebs/archive/2011/07/20/html5-video-not-working-in-ie9-some-tips-to-debug.aspx