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

拥有回忆 提交于 2019-12-04 01:03:44

问题


<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?


回答1:


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

  • HTML 5 Doctor - HTML5 audio, the state of play
  • Chromium - Audio/Video



回答2:


<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 |
+---------------------+-----+-----+-----+-----+



回答3:


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.



来源:https://stackoverflow.com/questions/15568884/how-can-i-use-html5-audio-tag-to-play-aac-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!