Skip to content

Instantly share code, notes, and snippets.

@dhinus
Created March 14, 2016 13:26
Show Gist options
  • Save dhinus/909b1530d2b30681edf7 to your computer and use it in GitHub Desktop.
Save dhinus/909b1530d2b30681edf7 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