Created
February 23, 2013 11:55
-
-
Save sudodoki/5019514 to your computer and use it in GitHub Desktop.
CanPlayType test for testing browser's abilities considering audio.
This file contains hidden or 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
// As seen in https://hacks.mozilla.org/2013/02/simplifying-audio-in-the-browser/ | |
var audioTest = new Audio(); | |
var codecs = { | |
mp3: !!audioTest.canPlayType('audio/mpeg;').replace(/^no$/,''), | |
ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,''), | |
wav: !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/,''), | |
m4a: !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/,''), | |
webm: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,'') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment