-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move audio test to feature-detects/audio.js
- Loading branch information
Showing
2 changed files
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
// This tests evaluates support of the audio element, as well as | ||
// testing what types of content it supports. | ||
// | ||
// We're using the Boolean constructor here, so that we can extend the value | ||
// e.g. Modernizr.audio // true | ||
// Modernizr.video.ogg // 'probably' | ||
// | ||
// Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845 | ||
// thx to NielsLeenheer and zcorpan | ||
|
||
// Note: in some older browsers, "no" was a return value instead of empty string. | ||
// It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2 | ||
// It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5 | ||
Modernizr.addTest('audio', function() { | ||
var elem = document.createElement('audio'), | ||
bool = false; | ||
|
||
try { | ||
if ( bool = !!elem.canPlayType ) { | ||
bool = new Boolean(bool); | ||
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,''); | ||
bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,''); | ||
|
||
// Mimetypes accepted: | ||
// developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements | ||
// bit.ly/iphoneoscodecs | ||
bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,''); | ||
bool.m4a = ( elem.canPlayType('audio/x-m4a;') || | ||
elem.canPlayType('audio/aac;')) .replace(/^no$/,''); | ||
} | ||
} catch(e) { } | ||
|
||
return bool; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters