user2198903
user2198903

Reputation: 111

how can I use html5 <audio> tag to play aac file?

<audio controls>
  <source src="xxx.aac" type="audio/aac">
</audio>

I can get it to work in safari but doesn't work in chrome and firefox. any solution?

Upvotes: 11

Views: 30353

Answers (4)

Raja Jee
Raja Jee

Reputation: 51

    <source src="test.acc" type="audio/ogg; codecs=vorbis" />

This worked for me incase anybody is still looking for an answer

Upvotes: -1

Greg
Greg

Reputation: 31

The AAC audio format seems to be widely supported by HTML5 in most browsers as long as it is in the MP4 container. For example, an apple .m4a file is an MP4 containing only an audio file, usually an AAC file.

The .aac file itself would not be widely supported.

Thus:

<audio controls="controls">
    <source src="xxx.m4a" type="audio/mpeg" />
</audio>

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats

See the browser compatibility chart - line "AAC in MP4" and footnotes.

Upvotes: 3

Daniel Imms
Daniel Imms

Reputation: 50149

Only Safari and IE support .aac. Here is what each browser supports:

  • Internet Explorer 9.0+: .mp3, .aac
  • Chrome: .ogg, .mp3, .wav, .aac*
  • Firefox: .ogg, .wav
  • Safari: .mp3, .aac, .wav
  • Opera: .ogg, .wav

* Chrome seems to support .aac but it isn't included in the list of officially supported file extensions.

I suggest using both .ogg and .mp3 or .ogg and .aac to cover all bases.

References

Upvotes: 13

周川添
周川添

Reputation: 93

<audio controls="controls"> <source src="xxx.aac" type="audio/mp4" /> </audio>

+---------------------+-----+-----+-----+-----+
| Browser             | Ogg | MP3 | AAC | Wav |
+---------------------+-----+-----+-----+-----+
| Internet Explorer 9 | No  | Yes | Yes | No  |
| Firefox 5           | Yes | No  | No  | Yes |
| Chrome 12           | Yes | Yes | Yes | Yes |
| Safari 5            | No  | Yes | Yes | Yes |
| Opera 11.5          | Yes | No  | No  | Yes |
+---------------------+-----+-----+-----+-----+

Upvotes: 6

Related Questions