-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c0c7bb
commit b73dedd
Showing
5 changed files
with
158 additions
and
114 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import window from 'global/window'; | ||
import document from 'global/document'; | ||
import videojs from 'video.js'; | ||
|
||
const USER_AGENT = window && window.navigator && window.navigator.userAgent || ''; | ||
|
||
// get the major/minor/patch for safari desktop an ios | ||
// should be used in conjunction with videojs.browser | ||
export const safariVersion = (function() { | ||
const version = {major: 0, minor: 0, patch: 0}; | ||
|
||
if (!videojs.browser.IS_ANY_SAFARI) { | ||
return version; | ||
} | ||
|
||
const matches = (/Version\/(\d+)(\.\d+)?(\.\d+)? /i).exec(USER_AGENT); | ||
|
||
if (!matches || matches.length === 0) { | ||
return version; | ||
} | ||
|
||
version.major = parseInt(matches[1], 10); | ||
|
||
if (matches[2]) { | ||
version.minor = parseInt(matches[2].replace('.', ''), 10); | ||
} | ||
|
||
if (matches[3]) { | ||
version.patch = parseInt(matches[3].replace('.', ''), 10); | ||
} | ||
|
||
return version; | ||
})(); | ||
|
||
// check if the browser supports cors | ||
export const corsSupport = (function() { | ||
const video = document.createElement('video'); | ||
|
||
video.crossOrigin = 'anonymous'; | ||
|
||
return video.hasAttribute('crossorigin'); | ||
})(); | ||
|
||
export const isHLS = function(currentType) { | ||
// hls video types | ||
const hlsTypes = [ | ||
// Apple santioned | ||
'application/vnd.apple.mpegurl', | ||
// Very common | ||
'application/x-mpegurl', | ||
// Included for completeness | ||
'video/x-mpegurl', | ||
'video/mpegurl', | ||
'application/mpegurl' | ||
]; | ||
|
||
// if the current type has a case insensitivie match from the list above | ||
// this is hls | ||
return hlsTypes.some((type) => (RegExp(`^${type}$`, 'i')).test(currentType)); | ||
}; | ||
|
||
export const validProjections = [ | ||
'360', | ||
'360_LR', | ||
'360_TB', | ||
'360_CUBE', | ||
'NONE', | ||
'AUTO', | ||
'Sphere', | ||
'Cube', | ||
'equirectangular' | ||
]; | ||
|
||
export const getInternalProjectionName = function(projection) { | ||
if (!projection) { | ||
return; | ||
} | ||
|
||
projection = projection.toString().trim(); | ||
|
||
if ((/sphere/i).test(projection)) { | ||
return '360'; | ||
} | ||
|
||
if ((/cube/i).test(projection)) { | ||
return '360_CUBE'; | ||
} | ||
|
||
if ((/equirectangular/i).test(projection)) { | ||
return '360'; | ||
} | ||
|
||
for (let i = 0; i < validProjections.length; i++) { | ||
if (new RegExp('^' + validProjections[i] + '$', 'i').test(projection)) { | ||
return validProjections[i]; | ||
} | ||
} | ||
|
||
}; |
This file was deleted.
Oops, something went wrong.