much has been made of the ongoing fight over what will be the html5 video standard for the future. but what about audio support in html5? one might easily assume that a browser that is supposed to support html5 video, will naturally also support html5 audio, right? apparently this is not so, at least not for the android default browser.
* update, for impatient readers: i eventually verified that due to some kind of bug, the audio tag does not work in any currently available version of android, including 2.2 (froyo). the bug is reported to be solved in “post-froyo code”, which probably means android 3.0. read on for details and some info about other platforms.
in my attempt to build a webapp-version of the textopia android app, which should be available both to iphone and android users, i have come across this problem: while i can get users’ position in the same way on both platforms, i can only play sounds using the html5 audio element on iphone, not on android. trying to find out why, i set up a test page with a list of html5 audio elements with test files in different formats. testing out this page in different browsers reveals that while support varies between platforms, android stands out by simply not supporting anything at all – not even the error messages that should come up for browsers that don’t support html5 audio!
looking at desktop browsers first, w3schools.com gives the following overview over audio support:
|Format||IE 8||Firefox 3.5||Opera 10.5||Chrome 3.0||Safari 3.0|
but what about mobile browsers? i have been searching for a while, but have not been able to find official documentation of what audio formats are supported in the different browsers. the android documentation specifies a number of audio formats supported in native apps, but these do not appear to be the same as the ones supported by the default (webkit-based) android browser. so the testpage seems to be the only way of finding out what is supported and not.
opening that page in android and iphone yielded some interesting results.
iphone: supports all the audio formats except ogg. mp3, wav, mp4, m4a, 3gp and amr all play perfectly fine.
android: supports none of the audio tags at all! for android 1.6 (tested on magic and adp1) this happens as expected – the browser displays the text between the audio tags, saying that the browser does not support html5 audio. however, on android 2.1 (tested on my htc desire) neither the text nor the audio element is displayed. why? i have no idea. it looks like the browser is trying to display the audio element, but fails somehow.
looking back at the official documentation, i am actually not able to find anywhere that states clearly that html5 audio is supported in the android browser. sure, the android 2.0 platform highlights claim the browser supports html5 video, but that doesn’t mean audio is supported, right? maybe android is just for silent movie lovers… both html5doctor and this o’reilly article claim audio is supported, but perhaps they just made the same erroneous assumption as me.
of course something could be wrong with my testpage or my test files – but the fact that they all play nicely in other browsers speak against that possibility (and the 3gp and mp4 files play fine in my native android app). which leaves us with the conclusion that unless the htc sense has anything to do with it, the audio implementation in the android browser is simply broken. very disappointing, considering google’s repeated commitment to open standards (and considering they are using the same webkit base as iphone).
for the record, i am totally open to the possibility that i may have made an error in my testing – i will be grateful for any feedback from anyone who try out the testpage in different configurations and report back their results. and i will correct and update this post to reflect that feedback. (in particular, if anyone is able to test this in mobile firefox, it would be fun to see the results! theoretically, mobile firefox should be identical to the desktop version on this, but would be nice to verify that.)
- iphone 3gs running iphone os 3.
- htc desire running android 2.1 (and htc sense interface).
update 30 june: i filed a bug report at the android code pages. they have now responded that the issue is resolved in android 2.2 (froyo) – actually they claim that all 7 sound formats should work there, which is great if it’s true! so then all of us non-nexus owners just have to wait and see when our phones will get updated…
update 7 july: finally got around to installing the android 2.2 emulator. unfortunately the test page does not work there – and another user on the android project page reports same problem on nexus one. so it looks like this issue may in fact *not* be resolved in android 2.2 after all.
update 8 july: new feedback from the android project – seems this bug persists in 2.2 froyo after all. the bug is apparently fixed in whatever version comes after froyo (3.0?). so no html5 audio in android for a good while still…
update 10 august: came across this nice and fairly comprehensive test page, html5test.com. opening that page in my android 2.2 browser shows that the audio element is supported, but none of the listed sound formats. incidentally, it shows the same for the video element – no support even for mpeg-4, which is supported in native apps. is there something i’m missing here, or is this completely pointless – what is the point of supporting the media elements, if no file formats are supported?
results from desktop browsers:
opera and firefox (tested both on mac os x 10.6 and windows xp): supports only the formats cited in the table above .
ie8: nothing, as cited above.
google chrome (tested on mac os x 10.6): supports aac (m4a extension) and mp4, in addition to mp3 and ogg.
safari: supports everything except ogg: mp3, wav, 3gp, aac, mp4, amr.
have a look at this interesting experiment by the nrkbeta guys, testing streaming through the audio element in various browsers.