Created
March 14, 2016 13:26
-
-
Save dhinus/909b1530d2b30681edf7 to your computer and use it in GitHub Desktop.
Check if browser supports Youtube 360 video
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
function browserSupports360 () { | |
// YouTube supports 360 videos in a limited set of browsers, | |
// see https://support.google.com/youtube/answer/6178631 | |
var ua = navigator.userAgent; | |
// No mobile browser is supported at the moment | |
if (/Mobile/.test(ua) || /Tablet/.test(ua)) return false; | |
// Chrome >= 40 | |
if (/Chrome\/[^123][0-9]/.test(ua) && !/Edge\//.test(ua) && !/OPR\//.test(ua)) return true; | |
// Firefox >= 40 | |
if (/Firefox\/[^123][0-9]/.test(ua)) return true; | |
// Microsoft Edge | |
if (/Edge\//.test(ua)) return true; | |
// Opera >= 30 | |
if (/OPR\/[^12][0-9]/.test(ua)) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment