问题
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?
回答1:
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:
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:
- 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.
来源:https://stackoverflow.com/questions/18603605/what-are-the-limitations-of-html5-audio-on-android-and-ios