Created
November 30, 2012 09:30
-
-
Save 4rn0/4174742 to your computer and use it in GitHub Desktop.
Modernizr HTTP Live Streaming test
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
Modernizr.addTest('hls', function() { | |
var a = navigator.userAgent, | |
b = document.createElement('video'); | |
if (a.match(/iPhone|iPod|iPad/)) { | |
return true | |
} | |
try { | |
return b && b.canPlayType && !! b.canPlayType('application/x-mpegURL; codecs="avc1.42E01E, mp4a.40.2"') | |
} | |
catch(c) { | |
return false | |
} | |
}); |
heres a pattern for matching iOS devices.
/ip(?:hone|[a|o]d)/gi.test(a)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There seem to be more possible codecs, see the table on http://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/FrequentlyAskedQuestions/FrequentlyAskedQuestions.html