10

I've noticed that for the HTML5 Audio element, what works on the latest version of Chrome for PCs will not necessarily work on the default browser in Android, Chrome for Android, or Safari on iOS.

What limitations exist for Audio on these platforms?

Specifically:

  • Which audio formats are supported on each platform?
  • For each platform, is a user interaction event (eg. onclick) required to play audio from javascript? (via new Audio(url);)
  • Can audio be played from a data URI on the Android and iOS Audio element?
  • Are there any other major limitations (or bugs) for HTML5 Audio on these platforms?
3
  • Obviously, you didn't google this, but did you at least search SO for it? scirra.com/blog/44/on-html5-audio-formats-aac-and-ogg Sep 4, 2013 at 1:36
  • Actually, I did both. All sources seem to assume that Safari on iOS is the same as Safari on desktop. That doesn't seem to be the case. Same goes for Chrome. The link you provided doesn't mention iOS or Android. This question is about those platforms specifically.
    – James
    Sep 4, 2013 at 9:31
  • For now, we use .aac format for html5 audio on Android and iOS, mostly in WeChat app in China, It works for iOS and most of china-brand android phones.
    – jiguang
    Dec 8, 2017 at 2:22

3 Answers 3

5

Summary

MP3 seems to be the best bet for broad platform coverage. It is supported by the newest versions of all major desktop and mobile browsers. (Safari on iOS & Chrome on Android)

At the moment, playback through DataURIs is limited mainly to desktop browsers, but will soon become available in Android.

Android (default browser)

Formats

  • Ogg Vorbis: Yes
  • MP3: Yes
  • FLAC: No (not 100% certain)

Data URIs

Yes

Autoplay allowed

TBC

User interaction event required

TBC

Limitations

  • Full audio doesn't seem to play. (tested with short sounds)

Android (Chrome)

Formats

  • Ogg Vorbis: Yes
  • MP3: Yes
  • FLAC: Yes

Data URIs

Yes (bug fixed in Chrome 34, which is currently in beta)

Autoplay allowed

No (bug)

User interaction event required

Yes

Limitations

  • "ended" event never fires. (bug)
  • "ended" event doesn't have user interaction privileges, so audio cannot be chained. (bug)

iOS

Formats

  • Ogg Vorbis: No
  • MP3: Yes
  • FLAC: No

Data URIs

No (workaround for iOS 6; no known workaround for iOS 6+)

Autoplay allowed

TBC

User interaction event required

TBC

Limitations

TBC


Format tests performed using http://hpr.dogphilosophy.net/test/

2
  • 2
    What do you mean with TBC? Nov 9, 2017 at 14:03
  • @maracuja-juice "To Be Confirmed" I guess.
    – Rodrigo
    Apr 3, 2020 at 2:30
4
+50

Which audio formats are supported on each platform?

iOS: AAC audio, MP3 audio, AIF audio, WAVE audio

Safari on iOS (including iPad) currently supports uncompressed WAV and AIF audio, MP3 audio, and AAC-LC or HE-AAC audio. HE-AAC is the preferred format.

Safari on iOS (including iPad) currently supports MPEG-4 video (Baseline profile) and QuickTime movies encoded with H.264 video (Baseline profile) and one of the supported audio types.

iPad and iPhone 3G and later support H.264 Baseline profile 3.1. Earlier versions of iPhone support H.264 Baseline profile 3.0.

Links:

https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW1

Android : MP3

Link:

http://html5test.com/compare/browser/android23/android40/android22.html

You can follow this link to test the supported audio format

http://hpr.dogphilosophy.net/test/

For each platform, is a user interaction event (eg. onclick) required to play audio from javascript?

No, it can also play automatically.

http://www.w3schools.com/tags/att_video_autoplay.asp

Can audio be played from a data URI on the Android and iOS Audio element?

Here is the link which explains the probability to play audio using data URI

Is it possible to use data URIs in video and audio tags?

Are there any other major limitations of HTML5 Audio on these platforms?

Here is the link which explains the linitations

http://www.ibm.com/developerworks/library/wa-ioshtml5/

http://blog.chenalexander.com/2011/limitations-of-layering-html5-audio/

3
  • 3
    The big limitation on iOS is the inability to autoplay or programmatically play audio. My company built a web-app for PCs that polls a service for notifications and plays an alert sound if there is one. When they wanted to convert this to iOS, we had to build a phonegap shell and invoke a phonegap method to play the audio instead of using HTML5 audio.
    – xdumaine
    Sep 10, 2013 at 12:34
  • Newer Android versions can definitely play more than just MP3. My Android phone can play several formats from hpr.dogphilosophy.net/test
    – James
    Sep 11, 2013 at 23:35
  • I'm not sure how true this is for Android. My ancient Android 1.5 OS can play Ogg files (but not MP3s).
    – ashes999
    Nov 8, 2014 at 22:08
0
  • Which audio formats are supported on each platform?

Android
IOS

  • Can audio be played from a data URI on the Android

You can accomplish this using MediaPlayer. Also refer here and here for additional info.
Using phonegap and cordova where you can play and record audio

  • Are there any other major limitations of HTML5 Audio on these platforms?

Refer here

P.S. This post focuses more on Android.

1
  • 1
    MediaPlayer seems to be for native apps. I'm specifically interested in whether data URIs can or can't work with HTML5 Audio on Android & iOS.
    – James
    Sep 12, 2013 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.