Skip to content

Instantly share code, notes, and snippets.

@tbuchanan
Forked from dhinus/youtube360check.js
Created April 7, 2016 00:18
Show Gist options
  • Save tbuchanan/26be5b70001604041e9203051b7f5522 to your computer and use it in GitHub Desktop.
Save tbuchanan/26be5b70001604041e9203051b7f5522 to your computer and use it in GitHub Desktop.
Check if browser supports Youtube 360 video
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