UNPKG

hls-player

Version:

A hls video player component for Vue.js

1,695 lines (1,390 loc) 2.02 MB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["hls-player"] = factory(); else root["hls-player"] = factory(); })((typeof self !== 'undefined' ? self : this), function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "fb15"); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { /* (ignored) */ /***/ }), /***/ "00ee": /***/ (function(module, exports, __webpack_require__) { var wellKnownSymbol = __webpack_require__("b622"); var TO_STRING_TAG = wellKnownSymbol('toStringTag'); var test = {}; test[TO_STRING_TAG] = 'z'; module.exports = String(test) === '[object z]'; /***/ }), /***/ "0366": /***/ (function(module, exports, __webpack_require__) { var aFunction = __webpack_require__("1c0b"); // optional / simple context binding module.exports = function (fn, that, length) { aFunction(fn); if (that === undefined) return fn; switch (length) { case 0: return function () { return fn.call(that); }; case 1: return function (a) { return fn.call(that, a); }; case 2: return function (a, b) { return fn.call(that, a, b); }; case 3: return function (a, b, c) { return fn.call(that, a, b, c); }; } return function (/* ...args */) { return fn.apply(that, arguments); }; }; /***/ }), /***/ "045f": /***/ (function(module, exports, __webpack_require__) { "use strict"; var window = __webpack_require__("d7d2") var _extends = __webpack_require__("a559"); var isFunction = __webpack_require__("8362"); /** * @license * slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/> * Copyright (c) 2014 David Björklund * Available under the MIT license * <https://github.com/kesla/parse-headers/blob/master/LICENCE> */ var parseHeaders = function(headers) { var result = {}; if (!headers) { return result; } headers.trim().split('\n').forEach(function(row) { var index = row.indexOf(':'); var key = row.slice(0, index).trim().toLowerCase(); var value = row.slice(index + 1).trim(); if (typeof(result[key]) === 'undefined') { result[key] = value } else if (Array.isArray(result[key])) { result[key].push(value) } else { result[key] = [ result[key], value ] } }); return result; }; module.exports = createXHR // Allow use of default import syntax in TypeScript module.exports.default = createXHR; createXHR.XMLHttpRequest = window.XMLHttpRequest || noop createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) { createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) { options = initParams(uri, options, callback) options.method = method.toUpperCase() return _createXHR(options) } }) function forEachArray(array, iterator) { for (var i = 0; i < array.length; i++) { iterator(array[i]) } } function isEmpty(obj){ for(var i in obj){ if(obj.hasOwnProperty(i)) return false } return true } function initParams(uri, options, callback) { var params = uri if (isFunction(options)) { callback = options if (typeof uri === "string") { params = {uri:uri} } } else { params = _extends({}, options, {uri: uri}) } params.callback = callback return params } function createXHR(uri, options, callback) { options = initParams(uri, options, callback) return _createXHR(options) } function _createXHR(options) { if(typeof options.callback === "undefined"){ throw new Error("callback argument missing") } var called = false var callback = function cbOnce(err, response, body){ if(!called){ called = true options.callback(err, response, body) } } function readystatechange() { if (xhr.readyState === 4) { setTimeout(loadFunc, 0) } } function getBody() { // Chrome with requestType=blob throws errors arround when even testing access to responseText var body = undefined if (xhr.response) { body = xhr.response } else { body = xhr.responseText || getXml(xhr) } if (isJson) { try { body = JSON.parse(body) } catch (e) {} } return body } function errorFunc(evt) { clearTimeout(timeoutTimer) if(!(evt instanceof Error)){ evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") ) } evt.statusCode = 0 return callback(evt, failureResponse) } // will load the data & process the response in a special response object function loadFunc() { if (aborted) return var status clearTimeout(timeoutTimer) if(options.useXDR && xhr.status===undefined) { //IE8 CORS GET successful response doesn't have a status field, but body is fine status = 200 } else { status = (xhr.status === 1223 ? 204 : xhr.status) } var response = failureResponse var err = null if (status !== 0){ response = { body: getBody(), statusCode: status, method: method, headers: {}, url: uri, rawRequest: xhr } if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE response.headers = parseHeaders(xhr.getAllResponseHeaders()) } } else { err = new Error("Internal XMLHttpRequest Error") } return callback(err, response, response.body) } var xhr = options.xhr || null if (!xhr) { if (options.cors || options.useXDR) { xhr = new createXHR.XDomainRequest() }else{ xhr = new createXHR.XMLHttpRequest() } } var key var aborted var uri = xhr.url = options.uri || options.url var method = xhr.method = options.method || "GET" var body = options.body || options.data var headers = xhr.headers = options.headers || {} var sync = !!options.sync var isJson = false var timeoutTimer var failureResponse = { body: undefined, headers: {}, statusCode: 0, method: method, url: uri, rawRequest: xhr } if ("json" in options && options.json !== false) { isJson = true headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user if (method !== "GET" && method !== "HEAD") { headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user body = JSON.stringify(options.json === true ? body : options.json) } } xhr.onreadystatechange = readystatechange xhr.onload = loadFunc xhr.onerror = errorFunc // IE9 must have onprogress be set to a unique function. xhr.onprogress = function () { // IE must die } xhr.onabort = function(){ aborted = true; } xhr.ontimeout = errorFunc xhr.open(method, uri, !sync, options.username, options.password) //has to be after open if(!sync) { xhr.withCredentials = !!options.withCredentials } // Cannot set timeout with sync request // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent if (!sync && options.timeout > 0 ) { timeoutTimer = setTimeout(function(){ if (aborted) return aborted = true//IE9 may still call readystatechange xhr.abort("timeout") var e = new Error("XMLHttpRequest timeout") e.code = "ETIMEDOUT" errorFunc(e) }, options.timeout ) } if (xhr.setRequestHeader) { for(key in headers){ if(headers.hasOwnProperty(key)){ xhr.setRequestHeader(key, headers[key]) } } } else if (options.headers && !isEmpty(options.headers)) { throw new Error("Headers cannot be set on an XDomainRequest object") } if ("responseType" in options) { xhr.responseType = options.responseType } if ("beforeSend" in options && typeof options.beforeSend === "function" ) { options.beforeSend(xhr) } // Microsoft Edge browser sends "undefined" when send is called with undefined value. // XMLHttpRequest spec says to pass null as body to indicate no body // See https://github.com/naugtur/xhr/issues/100. xhr.send(body || null) return xhr } function getXml(xhr) { // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException" // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML. try { if (xhr.responseType === "document") { return xhr.responseXML } var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror" if (xhr.responseType === "" && !firefoxBugTakenEffect) { return xhr.responseXML } } catch (e) {} return null } function noop() {} /***/ }), /***/ "0538": /***/ (function(module, exports, __webpack_require__) { "use strict"; var aFunction = __webpack_require__("1c0b"); var isObject = __webpack_require__("861d"); var slice = [].slice; var factories = {}; var construct = function (C, argsLength, args) { if (!(argsLength in factories)) { for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']'; // eslint-disable-next-line no-new-func factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')'); } return factories[argsLength](C, args); }; // `Function.prototype.bind` method implementation // https://tc39.es/ecma262/#sec-function.prototype.bind module.exports = Function.bind || function bind(that /* , ...args */) { var fn = aFunction(this); var partArgs = slice.call(arguments, 1); var boundFunction = function bound(/* args... */) { var args = partArgs.concat(slice.call(arguments)); return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args); }; if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype; return boundFunction; }; /***/ }), /***/ "057f": /***/ (function(module, exports, __webpack_require__) { var toIndexedObject = __webpack_require__("fc6a"); var nativeGetOwnPropertyNames = __webpack_require__("241c").f; var toString = {}.toString; var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : []; var getWindowNames = function (it) { try { return nativeGetOwnPropertyNames(it); } catch (error) { return windowNames.slice(); } }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : nativeGetOwnPropertyNames(toIndexedObject(it)); }; /***/ }), /***/ "06cf": /***/ (function(module, exports, __webpack_require__) { var DESCRIPTORS = __webpack_require__("83ab"); var propertyIsEnumerableModule = __webpack_require__("d1e7"); var createPropertyDescriptor = __webpack_require__("5c6c"); var toIndexedObject = __webpack_require__("fc6a"); var toPrimitive = __webpack_require__("c04e"); var has = __webpack_require__("5135"); var IE8_DOM_DEFINE = __webpack_require__("0cfb"); var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { O = toIndexedObject(O); P = toPrimitive(P, true); if (IE8_DOM_DEFINE) try { return nativeGetOwnPropertyDescriptor(O, P); } catch (error) { /* empty */ } if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]); }; /***/ }), /***/ "0821": /***/ (function(module, exports, __webpack_require__) { "use strict"; /*! @name @videojs/vhs-utils @version 2.3.0 @license MIT */ /** * @file stream.js */ /** * A lightweight readable stream implemention that handles event dispatching. * * @class Stream */ var Stream = /*#__PURE__*/ function () { function Stream() { this.listeners = {}; } /** * Add a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener the callback to be invoked when an event of * the specified type occurs */ var _proto = Stream.prototype; _proto.on = function on(type, listener) { if (!this.listeners[type]) { this.listeners[type] = []; } this.listeners[type].push(listener); } /** * Remove a listener for a specified event type. * * @param {string} type the event name * @param {Function} listener a function previously registered for this * type of event through `on` * @return {boolean} if we could turn it off or not */ ; _proto.off = function off(type, listener) { if (!this.listeners[type]) { return false; } var index = this.listeners[type].indexOf(listener); // TODO: which is better? // In Video.js we slice listener functions // on trigger so that it does not mess up the order // while we loop through. // // Here we slice on off so that the loop in trigger // can continue using it's old reference to loop without // messing up the order. this.listeners[type] = this.listeners[type].slice(0); this.listeners[type].splice(index, 1); return index > -1; } /** * Trigger an event of the specified type on this stream. Any additional * arguments to this function are passed as parameters to event listeners. * * @param {string} type the event name */ ; _proto.trigger = function trigger(type) { var callbacks = this.listeners[type]; if (!callbacks) { return; } // Slicing the arguments on every invocation of this method // can add a significant amount of overhead. Avoid the // intermediate object creation for the common case of a // single callback argument if (arguments.length === 2) { var length = callbacks.length; for (var i = 0; i < length; ++i) { callbacks[i].call(this, arguments[1]); } } else { var args = Array.prototype.slice.call(arguments, 1); var _length = callbacks.length; for (var _i = 0; _i < _length; ++_i) { callbacks[_i].apply(this, args); } } } /** * Destroys the stream and cleans up. */ ; _proto.dispose = function dispose() { this.listeners = {}; } /** * Forwards all `data` events on this stream to the destination stream. The * destination stream should provide a method `push` to receive the data * events as they arrive. * * @param {Stream} destination the stream that will receive all `data` events * @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options */ ; _proto.pipe = function pipe(destination) { this.on('data', function (data) { destination.push(data); }); }; return Stream; }(); module.exports = Stream; /***/ }), /***/ "0cfb": /***/ (function(module, exports, __webpack_require__) { var DESCRIPTORS = __webpack_require__("83ab"); var fails = __webpack_require__("d039"); var createElement = __webpack_require__("cc12"); // Thank's IE8 for his funny defineProperty module.exports = !DESCRIPTORS && !fails(function () { return Object.defineProperty(createElement('div'), 'a', { get: function () { return 7; } }).a != 7; }); /***/ }), /***/ "159b": /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__("da84"); var DOMIterables = __webpack_require__("fdbc"); var forEach = __webpack_require__("17c2"); var createNonEnumerableProperty = __webpack_require__("9112"); for (var COLLECTION_NAME in DOMIterables) { var Collection = global[COLLECTION_NAME]; var CollectionPrototype = Collection && Collection.prototype; // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try { createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach); } catch (error) { CollectionPrototype.forEach = forEach; } } /***/ }), /***/ "15f9": /***/ (function(module, exports, __webpack_require__) { var toUnsigned = __webpack_require__("7fe1").toUnsigned; var parseType = __webpack_require__("8eff"); var findBox = function(data, path) { var results = [], i, size, type, end, subresults; if (!path.length) { // short-circuit the search for empty paths return null; } for (i = 0; i < data.byteLength;) { size = toUnsigned(data[i] << 24 | data[i + 1] << 16 | data[i + 2] << 8 | data[i + 3]); type = parseType(data.subarray(i + 4, i + 8)); end = size > 1 ? i + size : data.byteLength; if (type === path[0]) { if (path.length === 1) { // this is the end of the path and we've found the box we were // looking for results.push(data.subarray(i + 8, end)); } else { // recursively search for the next box along the path subresults = findBox(data.subarray(i + 8, end), path.slice(1)); if (subresults.length) { results = results.concat(subresults); } } } i = end; } // we've finished searching all of data return results; }; module.exports = findBox; /***/ }), /***/ "17c2": /***/ (function(module, exports, __webpack_require__) { "use strict"; var $forEach = __webpack_require__("b727").forEach; var arrayMethodIsStrict = __webpack_require__("a640"); var arrayMethodUsesToLength = __webpack_require__("ae40"); var STRICT_METHOD = arrayMethodIsStrict('forEach'); var USES_TO_LENGTH = arrayMethodUsesToLength('forEach'); // `Array.prototype.forEach` method implementation // https://tc39.es/ecma262/#sec-array.prototype.foreach module.exports = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) { return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } : [].forEach; /***/ }), /***/ "1be4": /***/ (function(module, exports, __webpack_require__) { var getBuiltIn = __webpack_require__("d066"); module.exports = getBuiltIn('document', 'documentElement'); /***/ }), /***/ "1c0b": /***/ (function(module, exports) { module.exports = function (it) { if (typeof it != 'function') { throw TypeError(String(it) + ' is not a function'); } return it; }; /***/ }), /***/ "1d80": /***/ (function(module, exports) { // `RequireObjectCoercible` abstract operation // https://tc39.es/ecma262/#sec-requireobjectcoercible module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; /***/ }), /***/ "1dde": /***/ (function(module, exports, __webpack_require__) { var fails = __webpack_require__("d039"); var wellKnownSymbol = __webpack_require__("b622"); var V8_VERSION = __webpack_require__("2d00"); var SPECIES = wellKnownSymbol('species'); module.exports = function (METHOD_NAME) { // We can't use this feature detection in V8 since it causes // deoptimization and serious performance degradation // https://github.com/zloirock/core-js/issues/677 return V8_VERSION >= 51 || !fails(function () { var array = []; var constructor = array.constructor = {}; constructor[SPECIES] = function () { return { foo: 1 }; }; return array[METHOD_NAME](Boolean).foo !== 1; }); }; /***/ }), /***/ "1fb5": /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.byteLength = byteLength exports.toByteArray = toByteArray exports.fromByteArray = fromByteArray var lookup = [] var revLookup = [] var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i] revLookup[code.charCodeAt(i)] = i } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62 revLookup['_'.charCodeAt(0)] = 63 function getLens (b64) { var len = b64.length if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('=') if (validLen === -1) validLen = len var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) return [validLen, placeHoldersLen] } // base64 is 4/3 + up to two characters of the original data function byteLength (b64) { var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp var lens = getLens(b64) var validLen = lens[0] var placeHoldersLen = lens[1] var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) var curByte = 0 // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen var i for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[curByte++] = (tmp >> 16) & 0xFF arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) arr[curByte++] = tmp & 0xFF } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) arr[curByte++] = (tmp >> 8) & 0xFF arr[curByte++] = tmp & 0xFF } return arr } function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') } function fromByteArray (uint8) { var tmp var len = uint8.length var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes var parts = [] var maxChunkLength = 16383 // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1] parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3F] + '==' ) } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1] parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3F] + lookup[(tmp << 2) & 0x3F] + '=' ) } return parts.join('') } /***/ }), /***/ "23cb": /***/ (function(module, exports, __webpack_require__) { var toInteger = __webpack_require__("a691"); var max = Math.max; var min = Math.min; // Helper for a popular repeating case of the spec: // Let integer be ? ToInteger(index). // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). module.exports = function (index, length) { var integer = toInteger(index); return integer < 0 ? max(integer + length, 0) : min(integer, length); }; /***/ }), /***/ "23e7": /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__("da84"); var getOwnPropertyDescriptor = __webpack_require__("06cf").f; var createNonEnumerableProperty = __webpack_require__("9112"); var redefine = __webpack_require__("6eeb"); var setGlobal = __webpack_require__("ce4e"); var copyConstructorProperties = __webpack_require__("e893"); var isForced = __webpack_require__("94ca"); /* options.target - name of the target object options.global - target is the global object options.stat - export as static methods of target options.proto - export as prototype methods of target options.real - real prototype method for the `pure` version options.forced - export even if the native feature is available options.bind - bind methods to the target, required for the `pure` version options.wrap - wrap constructors to preventing global pollution, required for the `pure` version options.unsafe - use the simple assignment of property instead of delete + defineProperty options.sham - add a flag to not completely full polyfills options.enumerable - export as enumerable property options.noTargetGet - prevent calling a getter on target */ module.exports = function (options, source) { var TARGET = options.target; var GLOBAL = options.global; var STATIC = options.stat; var FORCED, target, key, targetProperty, sourceProperty, descriptor; if (GLOBAL) { target = global; } else if (STATIC) { target = global[TARGET] || setGlobal(TARGET, {}); } else { target = (global[TARGET] || {}).prototype; } if (target) for (key in source) { sourceProperty = source[key]; if (options.noTargetGet) { descriptor = getOwnPropertyDescriptor(target, key); targetProperty = descriptor && descriptor.value; } else targetProperty = target[key]; FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target if (!FORCED && targetProperty !== undefined) { if (typeof sourceProperty === typeof targetProperty) continue; copyConstructorProperties(sourceProperty, targetProperty); } // add a flag to not completely full polyfills if (options.sham || (targetProperty && targetProperty.sham)) { createNonEnumerableProperty(sourceProperty, 'sham', true); } // extend global redefine(target, key, sourceProperty, options); } }; /***/ }), /***/ "241c": /***/ (function(module, exports, __webpack_require__) { var internalObjectKeys = __webpack_require__("ca84"); var enumBugKeys = __webpack_require__("7839"); var hiddenKeys = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method // https://tc39.es/ecma262/#sec-object.getownpropertynames exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return internalObjectKeys(O, hiddenKeys); }; /***/ }), /***/ "256f": /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * mux.js * * Copyright (c) Brightcove * Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE * * Accepts program elementary stream (PES) data events and corrects * decode and presentation time stamps to account for a rollover * of the 33 bit value. */ var Stream = __webpack_require__("4329"); var MAX_TS = 8589934592; var RO_THRESH = 4294967296; var TYPE_SHARED = 'shared'; var handleRollover = function(value, reference) { var direction = 1; if (value > reference) { // If the current timestamp value is greater than our reference timestamp and we detect a // timestamp rollover, this means the roll over is happening in the opposite direction. // Example scenario: Enter a long stream/video just after a rollover occurred. The reference // point will be set to a small number, e.g. 1. The user then seeks backwards over the // rollover point. In loading this segment, the timestamp values will be very large, // e.g. 2^33 - 1. Since this comes before the data we loaded previously, we want to adjust // the time stamp to be `value - 2^33`. direction = -1; } // Note: A seek forwards or back that is greater than the RO_THRESH (2^32, ~13 hours) will // cause an incorrect adjustment. while (Math.abs(reference - value) > RO_THRESH) { value += (direction * MAX_TS); } return value; }; var TimestampRolloverStream = function(type) { var lastDTS, referenceDTS; TimestampRolloverStream.prototype.init.call(this); // The "shared" type is used in cases where a stream will contain muxed // video and audio. We could use `undefined` here, but having a string // makes debugging a little clearer. this.type_ = type || TYPE_SHARED; this.push = function(data) { // Any "shared" rollover streams will accept _all_ data. Otherwise, // streams will only accept data that matches their type. if (this.type_ !== TYPE_SHARED && data.type !== this.type_) { return; } if (referenceDTS === undefined) { referenceDTS = data.dts; } data.dts = handleRollover(data.dts, referenceDTS); data.pts = handleRollover(data.pts, referenceDTS); lastDTS = data.dts; this.trigger('data', data); }; this.flush = function() { referenceDTS = lastDTS; this.trigger('done'); }; this.endTimeline = function() { this.flush(); this.trigger('endedtimeline'); }; this.discontinuity = function() { referenceDTS = void 0; lastDTS = void 0; }; this.reset = function() { this.discontinuity(); this.trigger('reset'); }; }; TimestampRolloverStream.prototype = new Stream(); module.exports = { TimestampRolloverStream: TimestampRolloverStream, handleRollover: handleRollover }; /***/ }), /***/ "25f0": /***/ (function(module, exports, __webpack_require__) { "use strict"; var redefine = __webpack_require__("6eeb"); var anObject = __webpack_require__("825a"); var fails = __webpack_require__("d039"); var flags = __webpack_require__("ad6d"); var TO_STRING = 'toString'; var RegExpPrototype = RegExp.prototype; var nativeToString = RegExpPrototype[TO_STRING]; var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; }); // FF44- RegExp#toString has a wrong name var INCORRECT_NAME = nativeToString.name != TO_STRING; // `RegExp.prototype.toString` method // https://tc39.es/ecma262/#sec-regexp.prototype.tostring if (NOT_GENERIC || INCORRECT_NAME) { redefine(RegExp.prototype, TO_STRING, function toString() { var R = anObject(this); var p = String(R.source); var rf = R.flags; var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf); return '/' + p + '/' + f; }, { unsafe: true }); } /***/ }), /***/ "2806": /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * mux.js * * Copyright (c) Brightcove * Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE * * Utilities to detect basic properties and metadata about MP4s. */ var toUnsigned = __webpack_require__("7fe1").toUnsigned; var toHexString = __webpack_require__("7fe1").toHexString; var findBox = __webpack_require__("15f9"); var parseType = __webpack_require__("8eff"); var parseTfhd = __webpack_require__("caac"); var parseTrun = __webpack_require__("8a2d"); var parseTfdt = __webpack_require__("dbdc"); var timescale, startTime, compositionStartTime, getVideoTrackIds, getTracks, getTimescaleFromMediaHeader; /** * Parses an MP4 initialization segment and extracts the timescale * values for any declared tracks. Timescale values indicate the * number of clock ticks per second to assume for time-based values * elsewhere in the MP4. * * To determine the start time of an MP4, you need two pieces of * information: the timescale unit and the earliest base media decode * time. Multiple timescales can be specified within an MP4 but the * base media decode time is always expressed in the timescale from * the media header box for the track: * ``` * moov > trak > mdia > mdhd.timescale * ``` * @param init {Uint8Array} the bytes of the init segment * @return {object} a hash of track ids to timescale values or null if * the init segment is malformed. */ timescale = function(init) { var result = {}, traks = findBox(init, ['moov', 'trak']); // mdhd timescale return traks.reduce(function(result, trak) { var tkhd, version, index, id, mdhd; tkhd = findBox(trak, ['tkhd'])[0]; if (!tkhd) { return null; } version = tkhd[0]; index = version === 0 ? 12 : 20; id = toUnsigned(tkhd[index] << 24 | tkhd[index + 1] << 16 | tkhd[index + 2] << 8 | tkhd[index + 3]); mdhd = findBox(trak, ['mdia', 'mdhd'])[0]; if (!mdhd) { return null; } version = mdhd[0]; index = version === 0 ? 12 : 20; result[id] = toUnsigned(mdhd[index] << 24 | mdhd[index + 1] << 16 | mdhd[index + 2] << 8 | mdhd[index + 3]); return result; }, result); }; /** * Determine the base media decode start time, in seconds, for an MP4 * fragment. If multiple fragments are specified, the earliest time is * returned. * * The base media decode time can be parsed from track fragment * metadata: * ``` * moof > traf > tfdt.baseMediaDecodeTime * ``` * It requires the timescale value from the mdhd to interpret. * * @param timescale {object} a hash of track ids to timescale values. * @return {number} the earliest base media decode start time for the * fragment, in seconds */ startTime = function(timescale, fragment) { var trafs, baseTimes, result; // we need info from two childrend of each track fragment box trafs = findBox(fragment, ['moof', 'traf']); // determine the start times for each track baseTimes = [].concat.apply([], trafs.map(function(traf) { return findBox(traf, ['tfhd']).map(function(tfhd) { var id, scale, baseTime; // get the track id from the tfhd id = toUnsigned(tfhd[4] << 24 | tfhd[5] << 16 | tfhd[6] << 8 | tfhd[7]); // assume a 90kHz clock if no timescale was specified scale = timescale[id] || 90e3; // get the base media decode time from the tfdt baseTime = findBox(traf, ['tfdt']).map(function(tfdt) { var version, result; version = tfdt[0]; result = toUnsigned(tfdt[4] << 24 | tfdt[5] << 16 | tfdt[6] << 8 | tfdt[7]); if (version === 1) { result *= Math.pow(2, 32); result += toUnsigned(tfdt[8] << 24 | tfdt[9] << 16 | tfdt[10] << 8 | tfdt[11]); } return result; })[0]; baseTime = baseTime || Infinity; // convert base time to seconds return baseTime / scale; }); })); // return the minimum result = Math.min.apply(null, baseTimes); return isFinite(result) ? result : 0; }; /** * Determine the composition start, in seconds, for an MP4 * fragment. * * The composition start time of a fragment can be calculated using the base * media decode time, composition time offset, and timescale, as follows: * * compositionStartTime = (baseMediaDecodeTime + compositionTimeOffset) / timescale * * All of the aforementioned information is contained within a media fragment's * `traf` box, except for timescale info, which comes from the initialization * segment, so a track id (also contained within a `traf`) is also necessary to * associate it with a timescale * * * @param timescales {object} - a hash of track ids to timescale values. * @param fragment {Unit8Array} - the bytes of a media segment * @return {number} the composition start time for the fragment, in seconds **/ compositionStartTime = function(timescales, fragment) { var trafBoxes = findBox(fragment, ['moof', 'traf']); var baseMediaDecodeTime = 0; var compositionTimeOffset = 0; var trackId; if (trafBoxes && trafBoxes.length) { // The spec states that track run samples contained within a `traf` box are contiguous, but // it does not explicitly state whether the `traf` boxes themselves are contiguous. // We will assume that they are, so we only need the first to calculate start time. var tfhd = findBox(trafBoxes[0], ['tfhd'])[0]; var trun = findBox(trafBoxes[0], ['trun'])[0]; var tfdt = findBox(trafBoxes[0], ['tfdt'])[0]; if (tfhd) { var parsedTfhd = parseTfhd(tfhd); trackId = parsedTfhd.trackId; } if (tfdt) { var parsedTfdt = parseTfdt(tfdt); baseMediaDecodeTime = parsedTfdt.baseMediaDecodeTime; } if (trun) { var parsedTrun = parseTrun(trun); if (parsedTrun.samples && parsedTrun.samples.length) { compositionTimeOffset = parsedTrun.samples[0].compositionTimeOffset || 0; } } } // Get timescale for this specific track. Assume a 90kHz clock if no timescale was // specified. var timescale = timescales[trackId] || 90e3; // return the composition start time, in seconds return (baseMediaDecodeTime + compositionTimeOffset) / timescale; }; /** * Find the trackIds of the video tracks in this source. * Found by parsing the Handler Reference and Track Header Boxes: * moov > trak > mdia > hdlr * moov > trak > tkhd * * @param {Uint8Array} init - The bytes of the init segment for this source * @return {Number[]} A list of trackIds * * @see ISO-BMFF-12/2015, Section 8.4.3 **/ getVideoTrackIds = function(init) { var traks = findBox(init, ['moov', 'trak']); var videoTrackIds = []; traks.forEach(function(trak) { var hdlrs = findBox(trak, ['mdia', 'hdlr']); var tkhds = findBox(trak, ['tkhd']); hdlrs.forEach(function(hdlr, index) { var handlerType = parseType(hdlr.subarray(8, 12)); var tkhd = tkhds[index]; var view; var version; var trackId; if (handlerType === 'vide') { view = new DataView(tkhd.buffer, tkhd.byteOffset, tkhd.byteLength); version = view.getUint8(0); trackId = (version === 0) ? view.getUint32(12) : view.getUint32(20); videoTrackIds.push(trackId); } }); }); return videoTrackIds; }; getTimescaleFromMediaHeader = function(mdhd) { // mdhd is a FullBox, meaning it will have its own version as the first byte var version = mdhd[0]; var index = version === 0 ? 12 : 20; return toUnsigned( mdhd[index] << 24 | mdhd[index + 1] << 16 | mdhd[index + 2] << 8 | mdhd[index + 3] ); }; /** * Get all the video, audio, and hint tracks from a non fragmented * mp4 segment */ getTracks = function(init) { var traks = findBox(init, ['moov', 'trak']); var tracks = []; traks.forEach(function(trak) { var track = {}; var tkhd = findBox(trak, ['tkhd'])[0]; var view, tkhdVersion; // id if (tkhd) { view = new DataView(tkhd.buffer, tkhd.byteOffset, tkhd.byteLength); tkhdVersion = view.getUint8(0); track.id = (tkhdVersion === 0) ? view.getUint32(12) : view.getUint32(20); } var hdlr = findBox(trak, ['mdia', 'hdlr'])[0]; // type if (hdlr) { var type = parseType(hdlr.subarray(8, 12)); if (type === 'vide') { track.type = 'video'; } else if (type === 'soun') { track.type = 'audio'; } else { track.type = type; } } // codec var stsd = findBox(trak, ['mdia', 'minf', 'stbl', 'stsd'])[0]; if (stsd) { var sampleDescriptions = stsd.subarray(8); // gives the codec type string track.codec = parseType(sampleDescriptions.subarray(4, 8)); var codecBox = findBox(sampleDescriptions, [track.codec])[0]; var codecConfig, codecConfigType; if (codecBox) { // https://tools.ietf.org/html/rfc6381#section-3.3 if ((/^[a-z]vc[1-9]$/i).test(track.codec)) { // we don't need anything but the "config" parameter of the // avc1 codecBox codecConfig = codecBox.subarray(78); codecConfigType = parseType(codecConfig.subarray(4, 8)); if (codecConfigType === 'avcC' && codecConfig.length > 11) { track.codec += '.'; // left padded with zeroes for single digit hex // profile idc track.codec += toHexString(codecConfig[9]); // the byte containing the constraint_set flags track.codec += toHexString(codecConfig[10]); // level idc track.codec += toHexString(codecConfig[11]); } else { // TODO: show a warning that we couldn't parse the codec // and are using the default track.codec = 'avc1.4d400d'; } } else if ((/^mp4[a,v]$/i).test(track.codec)) { // we do not need anything but the streamDescriptor of the mp4a codecBox codecConfig = codecBox.subarray(28); codecConfigType = parseType(codecConfig.subarray(4, 8)); if (codecConfigType === 'esds' && codecConfig.length > 20 && codecConfig[19] !== 0) { track.codec += '.' + toHexString(codecConfig[19]); // this value is only a single digit track.codec += '.' + toHexString((codecConfig[20] >>> 2) & 0x3f).replace(/^0/, ''); } else { // TODO: show a warning that we couldn't parse the codec // and are using the default track.codec = 'mp4a.40.2'; } } else { // TODO: show a warning? for unknown codec type } } } var mdhd = findBox(trak, ['mdia', 'mdhd'])[0]; if (mdhd) { track.timescale = getTimescaleFromMediaHeader(mdhd); } tracks.push(track); }); return tracks; }; module.exports = { // export mp4 inspector's findBox and parseType for backwards compatibility findBox: findBox, parseType: parseType, timescale: timescale, startTime: startTime, compositionStartTime: compositionStartTime, videoTrackIds: getVideoTrackIds, tracks: getTracks, getTimescaleFromMediaHeader: getTimescaleFromMediaHeader }; /***/ }), /***/ "28de": /***/ (function(module, exports, __webpack_require__) { "use strict"; /*! @name @videojs/vhs-utils @version 2.3.0 @license MIT */ Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var window = _interopDefault(__webpack_require__("be09")); var regexs = { // to determine mime types mp4: /^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/, webm: /^(vp0?[89]|av0?1|opus|vorbis)/, ogg: /^(vp0?[89]|theora|flac|opus|vorbis)/, // to determine if a codec is audio or video video: /^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/, audio: /^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3)/, text: /^(stpp.ttml.im1t)/, // mux.js support regex muxerVideo: /^(avc0?1)/, muxerAudio: /^(mp4a)/, // match nothing as muxer does not support text right now. // there cannot never be a character before the start of a string // so this matches nothing. muxerText: /a^/ }; var mediaTypes = ['video', 'audio', 'text']; var upperMediaTypes = ['Video', 'Audio', 'Text']; /** * Replace the old apple-style `avc1.<dd>.<dd>` codec string with the standard * `avc1.<hhhhhh>` * * @param {string} codec * Codec string to translate * @return {string} * The translated codec string */ var translateLegacyCodec = function translateLegacyCodec(codec) { if (!codec) { return codec; } return codec.replace(/avc1\.(\d+)\.(\d+)/i, function (orig, profile, avcLevel) { var profileHex = ('00' + Number(profile).toString(16)).slice(-2); var avcLevelHex = ('00' + Number(avcLevel).toString(16)).slice(-2); return 'avc1.' + profileHex + '00' + avcLevelHex; }); }; /** * Replace the old apple-style `avc1.<dd>.<dd>` codec strings with the standard * `avc1.<hhhhhh>` * * @param {string[]} codecs * An array of codec strings to translate * @return {string[]} * The translated array of codec strings */ var translateLegacyCodecs = function translateLegacyCodecs(codecs) { return codecs.map(translateLegacyCodec); }; /** * Replace codecs in the codec string with the old apple-style `avc1.<dd>.<dd>` to the * standard `avc1.<hhhhhh>`. * * @param {string} codecString * The codec string * @return {string} * The codec string with old apple-style codecs replaced * * @private */ var mapLegacyAvcCodecs = function mapLegacyAvcCodecs(codecString) { return codecString.replace(/avc1\.(\d+)\.(\d+)/i, function (match) { return translateLegacyCodecs([match])[0]; }); }; /** * @typedef {Object} ParsedCodecInfo * @property {number} codecCount * Number of codecs parsed * @property {string} [videoCodec] * Parsed video codec (if found) * @property {string} [videoObjectTypeIndicator] * Video object type indicator (if fou