playable
Version:
Video player based on HTML5Video
57 lines • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NativeEnvironmentSupport = exports.isBrowser = void 0;
/**
* `true` if we are running inside a web browser, `false` otherwise (e.g. running inside Node.js).
*/
exports.isBrowser = typeof window !== 'undefined';
/**
* This is a map which lists native support of formats and APIs.
* It gets filled during runtime with the relevant values to the current environment.
*/
exports.NativeEnvironmentSupport = {
MSE: false,
HLS: false,
DASH: false,
MP4: false,
WEBM: false,
OGG: false,
MOV: false,
MKV: false,
};
/* ignore coverage */
function detectEnvironment() {
if (!exports.isBrowser) {
return; // Not in a browser
}
exports.NativeEnvironmentSupport.MSE =
'WebKitMediaSource' in window || 'MediaSource' in window;
var video = document.createElement('video');
if (typeof video.canPlayType !== 'function') {
return; // env doesn't support HTMLMediaElement (e.g PhantomJS)
}
if (video.canPlayType('application/x-mpegURL') ||
video.canPlayType('application/vnd.apple.mpegURL')) {
exports.NativeEnvironmentSupport.HLS = true;
}
if (video.canPlayType('application/dash+xml')) {
exports.NativeEnvironmentSupport.DASH = true;
}
if (video.canPlayType('video/mp4')) {
exports.NativeEnvironmentSupport.MP4 = true;
}
if (video.canPlayType('video/webm')) {
exports.NativeEnvironmentSupport.WEBM = true;
}
if (video.canPlayType('video/ogg')) {
exports.NativeEnvironmentSupport.OGG = true;
}
if (video.canPlayType('video/quicktime')) {
exports.NativeEnvironmentSupport.MOV = true;
}
if (video.canPlayType('video/x-matroska')) {
exports.NativeEnvironmentSupport.MKV = true;
}
}
detectEnvironment(); // Run once
//# sourceMappingURL=environment-detection.js.map