@clappr/hlsjs-playback 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/hlsjs-playback.esm.js +23689 -19740
- package/dist/hlsjs-playback.external.js +135 -224
- package/dist/hlsjs-playback.external.min.js +1 -1
- package/dist/hlsjs-playback.external.min.js.map +1 -1
- package/dist/hlsjs-playback.js +23690 -19741
- package/dist/hlsjs-playback.min.js +268 -72
- package/dist/hlsjs-playback.min.js.map +1 -1
- package/package.json +1 -1
- package/src/hls.js +10 -0
- package/src/hls.test.js +23 -0
|
@@ -1,85 +1,281 @@
|
|
|
1
|
-
var HlsjsPlayback=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=a(e);if(t){var n=a(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return o(this,r)}}function u(e,t,r){return(u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function c(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e,t,r){return t&&g(e.prototype,t),r&&g(e,r),e}function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){v(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?T(e):t}function k(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=E(e);if(t){var n=E(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return b(this,r)}}function S(e,t,r){return(S="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=E(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],i=!0,n=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(i=(s=o.next()).done)&&(r.push(s.value),!t||r.length!==t);i=!0);}catch(e){n=!0,a=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw a}}return r}(e,t)||L(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||L(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){if(e){if("string"==typeof e)return C(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?C(e,t):void 0}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function O(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=L(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return a;n++}}}),Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=[t[r],e[t[r]]];return i}),Object.values||(Object.values=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=e[t[r]];return i}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},writable:!0,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return n;n++}return-1},configurable:!0,writable:!0});var D,I={mp4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE="},P=function(){var e,t,r,i,n,a,s=[],o=s.concat,l=s.filter,u=s.slice,c=window.document,d={},h={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/^(?:body|html)$/i,A=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],E=c.createElement("table"),_=c.createElement("tr"),T={tr:c.createElement("tbody"),tbody:E,thead:E,tfoot:E,td:_,th:_,"*":c.createElement("div")},b=/complete|loaded|interactive/,k=/^[\w-]*$/,S={},R=S.toString,w={},L=c.createElement("div"),C={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},O=Array.isArray||function(e){return e instanceof Array};function D(e){return null==e?String(e):S[R.call(e)]||"object"}function I(e){return"function"==D(e)}function P(e){return null!=e&&e==e.window}function x(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function N(e){return"object"==D(e)}function M(e){return N(e)&&!P(e)&&Object.getPrototypeOf(e)==Object.prototype}function F(e){var t=!!e&&"length"in e&&e.length,i=r.type(e);return"function"!=i&&!P(e)&&("array"==i||0===t||"number"==typeof t&&t>0&&t-1 in e)}function U(e){return e.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function B(e){return e in h?h[e]:h[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function j(e,t){return"number"!=typeof t||f[U(e)]?t:t+"px"}function G(e){return"children"in e?u.call(e.children):r.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function K(e,t){var r,i=e?e.length:0;for(r=0;r<i;r++)this[r]=e[r];this.length=i,this.selector=t||""}function Y(r,i,n){for(t in i)n&&(M(i[t])||O(i[t]))?(M(i[t])&&!M(r[t])&&(r[t]={}),O(i[t])&&!O(r[t])&&(r[t]=[]),Y(r[t],i[t],n)):i[t]!==e&&(r[t]=i[t])}function V(e,t){return null==t?r(e):r(e).filter(t)}function H(e,t,r,i){return I(t)?t.call(e,r,i):t}function W(e,t,r){null==r?e.removeAttribute(t):e.setAttribute(t,r)}function z(t,r){var i=t.className||"",n=i&&i.baseVal!==e;if(r===e)return n?i.baseVal:i;n?i.baseVal=r:t.className=r}function q(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?r.parseJSON(e):e):e}catch(t){return e}}function X(e,t){t(e);for(var r=0,i=e.childNodes.length;r<i;r++)X(e.childNodes[r],t)}return w.matches=function(e,t){if(!t||!e||1!==e.nodeType)return!1;var r=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.matchesSelector;if(r)return r.call(e,t);var i,n=e.parentNode,a=!n;return a&&(n=L).appendChild(e),i=~w.qsa(n,t).indexOf(e),a&&L.removeChild(e),i},n=function(e){return e.replace(/-+(.)?/g,(function(e,t){return t?t.toUpperCase():""}))},a=function(e){return l.call(e,(function(t,r){return e.indexOf(t)==r}))},w.fragment=function(t,i,n){var a,s,o;return p.test(t)&&(a=r(c.createElement(RegExp.$1))),a||(t.replace&&(t=t.replace(v,"<$1></$2>")),i===e&&(i=g.test(t)&&RegExp.$1),i in T||(i="*"),(o=T[i]).innerHTML=""+t,a=r.each(u.call(o.childNodes),(function(){o.removeChild(this)}))),M(n)&&(s=r(a),r.each(n,(function(e,t){y.indexOf(e)>-1?s[e](t):s.attr(e,t)}))),a},w.Z=function(e,t){return new K(e,t)},w.isZ=function(e){return e instanceof w.Z},w.init=function(t,i){var n,a;if(!t)return w.Z();if("string"==typeof t)if("<"==(t=t.trim())[0]&&g.test(t))n=w.fragment(t,RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=w.qsa(c,t)}else{if(I(t))return r(c).ready(t);if(w.isZ(t))return t;if(O(t))a=t,n=l.call(a,(function(e){return null!=e}));else if(N(t))n=[t],t=null;else if(g.test(t))n=w.fragment(t.trim(),RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=w.qsa(c,t)}}return w.Z(n,t)},(r=function(e,t){return w.init(e,t)}).extend=function(e){var t,r=u.call(arguments,1);return"boolean"==typeof e&&(t=e,e=r.shift()),r.forEach((function(r){Y(e,r,t)})),e},w.qsa=function(e,t){var r,i="#"==t[0],n=!i&&"."==t[0],a=i||n?t.slice(1):t,s=k.test(a);return e.getElementById&&s&&i?(r=e.getElementById(a))?[r]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:u.call(s&&!i&&e.getElementsByClassName?n?e.getElementsByClassName(a):e.getElementsByTagName(t):e.querySelectorAll(t))},r.contains=c.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},r.type=D,r.isFunction=I,r.isWindow=P,r.isArray=O,r.isPlainObject=M,r.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},r.isNumeric=function(e){var t=Number(e),r=typeof e;return null!=e&&"boolean"!=r&&("string"!=r||e.length)&&!isNaN(t)&&isFinite(t)||!1},r.inArray=function(e,t,r){return s.indexOf.call(t,e,r)},r.camelCase=n,r.trim=function(e){return null==e?"":String.prototype.trim.call(e)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(e,t){var i,n,a,s,o=[];if(F(e))for(n=0;n<e.length;n++)null!=(i=t(e[n],n))&&o.push(i);else for(a in e)null!=(i=t(e[a],a))&&o.push(i);return(s=o).length>0?r.fn.concat.apply([],s):s},r.each=function(e,t){var r,i;if(F(e)){for(r=0;r<e.length;r++)if(!1===t.call(e[r],r,e[r]))return e}else for(i in e)if(!1===t.call(e[i],i,e[i]))return e;return e},r.grep=function(e,t){return l.call(e,t)},window.JSON&&(r.parseJSON=JSON.parse),r.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),(function(e,t){S["[object "+t+"]"]=t.toLowerCase()})),r.fn={constructor:w.Z,length:0,forEach:s.forEach,reduce:s.reduce,push:s.push,sort:s.sort,splice:s.splice,indexOf:s.indexOf,concat:function(){var e,t,r=[];for(e=0;e<arguments.length;e++)t=arguments[e],r[e]=w.isZ(t)?t.toArray():t;return o.apply(w.isZ(this)?this.toArray():this,r)},map:function(e){return r(r.map(this,(function(t,r){return e.call(t,r,t)})))},slice:function(){return r(u.apply(this,arguments))},ready:function(e){return b.test(c.readyState)&&c.body?e(r):c.addEventListener("DOMContentLoaded",(function(){e(r)}),!1),this},get:function(t){return t===e?u.call(this):this[t>=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(e){return s.every.call(this,(function(t,r){return!1!==e.call(t,r,t)})),this},filter:function(e){return I(e)?this.not(this.not(e)):r(l.call(this,(function(t){return w.matches(t,e)})))},add:function(e,t){return r(a(this.concat(r(e,t))))},is:function(e){return this.length>0&&w.matches(this[0],e)},not:function(t){var i=[];if(I(t)&&t.call!==e)this.each((function(e){t.call(this,e)||i.push(this)}));else{var n="string"==typeof t?this.filter(t):F(t)&&I(t.item)?u.call(t):r(t);this.forEach((function(e){n.indexOf(e)<0&&i.push(e)}))}return r(i)},has:function(e){return this.filter((function(){return N(e)?r.contains(this,e):r(this).find(e).size()}))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!N(e)?e:r(e)},last:function(){var e=this[this.length-1];return e&&!N(e)?e:r(e)},find:function(e){var t=this;return e?"object"==typeof e?r(e).filter((function(){var e=this;return s.some.call(t,(function(t){return r.contains(t,e)}))})):1==this.length?r(w.qsa(this[0],e)):this.map((function(){return w.qsa(this,e)})):r()},closest:function(e,t){var i=[],n="object"==typeof e&&r(e);return this.each((function(r,a){for(;a&&!(n?n.indexOf(a)>=0:w.matches(a,e));)a=a!==t&&!x(a)&&a.parentNode;a&&i.indexOf(a)<0&&i.push(a)})),r(i)},parents:function(e){for(var t=[],i=this;i.length>0;)i=r.map(i,(function(e){if((e=e.parentNode)&&!x(e)&&t.indexOf(e)<0)return t.push(e),e}));return V(t,e)},parent:function(e){return V(a(this.pluck("parentNode")),e)},children:function(e){return V(this.map((function(){return G(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||u.call(this.childNodes)}))},siblings:function(e){return V(this.map((function(e,t){return l.call(G(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return r.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){var e,t,r;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(e=this.nodeName,d[e]||(t=c.createElement(e),c.body.appendChild(t),r=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==r&&(r="block"),d[e]=r),d[e]))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=I(e);if(this[0]&&!t)var i=r(e).get(0),n=i.parentNode||this.length>1;return this.each((function(a){r(this).wrapAll(t?e.call(this,a):n?i.cloneNode(!0):i)}))},wrapAll:function(e){if(this[0]){var t;for(r(this[0]).before(e=r(e));(t=e.children()).length;)e=t.first();r(e).append(this)}return this},wrapInner:function(e){var t=I(e);return this.each((function(i){var n=r(this),a=n.contents(),s=t?e.call(this,i):e;a.length?a.wrapAll(s):n.append(s)}))},unwrap:function(){return this.parent().each((function(){r(this).replaceWith(r(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(t){return this.each((function(){var i=r(this);(t===e?"none"==i.css("display"):t)?i.show():i.hide()}))},prev:function(e){return r(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return r(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(t){var i=this.innerHTML;r(this).empty().append(H(this,e,t,i))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var r=H(this,e,t,this.textContent);this.textContent=null==r?"":""+r})):0 in this?this.pluck("textContent").join(""):null},attr:function(r,i){var n;return"string"!=typeof r||1 in arguments?this.each((function(e){if(1===this.nodeType)if(N(r))for(t in r)W(this,t,r[t]);else W(this,r,H(this,i,e,this.getAttribute(r)))})):0 in this&&1==this[0].nodeType&&null!=(n=this[0].getAttribute(r))?n:e},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){W(this,e)}),this)}))},prop:function(e,t){return e=C[e]||e,1 in arguments?this.each((function(r){this[e]=H(this,t,r,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=C[e]||e,this.each((function(){delete this[e]}))},data:function(t,r){var i="data-"+t.replace(A,"-$1").toLowerCase(),n=1 in arguments?this.attr(i,r):this.attr(i);return null!==n?q(n):e},val:function(e){return 0 in arguments?(null==e&&(e=""),this.each((function(t){this.value=H(this,e,t,this.value)}))):this[0]&&(this[0].multiple?r(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each((function(t){var i=r(this),n=H(this,e,t,i.offset()),a=i.offsetParent().offset(),s={top:n.top-a.top,left:n.left-a.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)}));if(!this.length)return null;if(c.documentElement!==this[0]&&!r.contains(c.documentElement,this[0]))return{top:0,left:0};var t=this[0].getBoundingClientRect();return{left:t.left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}},css:function(e,i){if(arguments.length<2){var a=this[0];if("string"==typeof e){if(!a)return;return a.style[n(e)]||getComputedStyle(a,"").getPropertyValue(e)}if(O(e)){if(!a)return;var s={},o=getComputedStyle(a,"");return r.each(e,(function(e,t){s[t]=a.style[n(t)]||o.getPropertyValue(t)})),s}}var l="";if("string"==D(e))i||0===i?l=U(e)+":"+j(e,i):this.each((function(){this.style.removeProperty(U(e))}));else for(t in e)e[t]||0===e[t]?l+=U(t)+":"+j(t,e[t])+";":this.each((function(){this.style.removeProperty(U(t))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(e){return e?this.indexOf(r(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&s.some.call(this,(function(e){return this.test(z(e))}),B(e))},addClass:function(e){return e?this.each((function(t){if("className"in this){i=[];var n=z(this);H(this,e,t,n).split(/\s+/g).forEach((function(e){r(this).hasClass(e)||i.push(e)}),this),i.length&&z(this,n+(n?" ":"")+i.join(" "))}})):this},removeClass:function(t){return this.each((function(r){if("className"in this){if(t===e)return z(this,"");i=z(this),H(this,t,r,i).split(/\s+/g).forEach((function(e){i=i.replace(B(e)," ")})),z(this,i.trim())}}))},toggleClass:function(t,i){return t?this.each((function(n){var a=r(this);H(this,t,n,z(this)).split(/\s+/g).forEach((function(t){(i===e?!a.hasClass(t):i)?a.addClass(t):a.removeClass(t)}))})):this},scrollTop:function(t){if(this.length){var r="scrollTop"in this[0];return t===e?r?this[0].scrollTop:this[0].pageYOffset:this.each(r?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var r="scrollLeft"in this[0];return t===e?r?this[0].scrollLeft:this[0].pageXOffset:this.each(r?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),i=this.offset(),n=m.test(t[0].nodeName)?{top:0,left:0}:t.offset();return i.top-=parseFloat(r(e).css("margin-top"))||0,i.left-=parseFloat(r(e).css("margin-left"))||0,n.top+=parseFloat(r(t[0]).css("border-top-width"))||0,n.left+=parseFloat(r(t[0]).css("border-left-width"))||0,{top:i.top-n.top,left:i.left-n.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||c.body;e&&!m.test(e.nodeName)&&"static"==r(e).css("position");)e=e.offsetParent;return e}))}},r.fn.detach=r.fn.remove,["width","height"].forEach((function(t){var i=t.replace(/./,(function(e){return e[0].toUpperCase()}));r.fn[t]=function(n){var a,s=this[0];return n===e?P(s)?s["inner"+i]:x(s)?s.documentElement["scroll"+i]:(a=this.offset())&&a[t]:this.each((function(e){(s=r(this)).css(t,H(this,n,e,s[t]()))}))}})),["after","prepend","before","append"].forEach((function(t,i){var n=i%2;r.fn[t]=function(){var t,a,s=r.map(arguments,(function(i){var n=[];return"array"==(t=D(i))?(i.forEach((function(t){return t.nodeType!==e?n.push(t):r.zepto.isZ(t)?n=n.concat(t.get()):void(n=n.concat(w.fragment(t)))})),n):"object"==t||null==i?i:w.fragment(i)})),o=this.length>1;return s.length<1?this:this.each((function(e,t){a=n?t:t.parentNode,t=0==i?t.nextSibling:1==i?t.firstChild:2==i?t:null;var l=r.contains(c.documentElement,a);s.forEach((function(e){if(o)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,t),l&&X(e,(function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var t=e.ownerDocument?e.ownerDocument.defaultView:window;t.eval.call(t,e.innerHTML)}}))}))}))},r.fn[n?t+"To":"insert"+(i?"Before":"After")]=function(e){return r(e)[t](this),this}})),w.Z.prototype=K.prototype=r.fn,w.uniq=a,w.deserializeValue=q,r.zepto=w,r}();window.Zepto=P,void 0===window.$&&(window.$=P),function(e){var t,r,i=+new Date,n=window.document,a=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,o=/^(?:text|application)\/xml/i,l="application/json",u="text/html",c=/^\s*$/,d=n.createElement("a");function h(t,r,i,a){if(t.global)return function(t,r,i){var n=e.Event(r);return e(t).trigger(n,i),!n.isDefaultPrevented()}(r||n,i,a)}function f(e,t){var r=t.context;if(!1===t.beforeSend.call(r,e,t)||!1===h(t,r,"ajaxBeforeSend",[e,t]))return!1;h(t,r,"ajaxSend",[e,t])}function g(e,t,r,i){var n=r.context,a="success";r.success.call(n,e,a,t),i&&i.resolveWith(n,[e,a,t]),h(r,n,"ajaxSuccess",[t,r,e]),v(a,t,r)}function p(e,t,r,i,n){var a=i.context;i.error.call(a,r,t,e),n&&n.rejectWith(a,[r,t,e]),h(i,a,"ajaxError",[r,i,e||t]),v(t,r,i)}function v(t,r,i){var n=i.context;i.complete.call(n,r,t),h(i,n,"ajaxComplete",[r,i]),function(t){t.global&&!--e.active&&h(t,null,"ajaxStop")}(i)}function m(){}function A(e,t){return""==t?e:(e+"&"+t).replace(/[&?]{1,2}/,"?")}function y(t,r,i,n){return e.isFunction(r)&&(n=i,i=r,r=void 0),e.isFunction(i)||(n=i,i=void 0),{url:t,data:r,success:i,dataType:n}}d.href=window.location.href,e.active=0,e.ajaxJSONP=function(t,r){if(!("type"in t))return e.ajax(t);var a,s,o=t.jsonpCallback,l=(e.isFunction(o)?o():o)||"Zepto"+i++,u=n.createElement("script"),c=window[l],d=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:d};return r&&r.promise(h),e(u).on("load error",(function(i,n){clearTimeout(s),e(u).off().remove(),"error"!=i.type&&a?g(a[0],h,t,r):p(null,n||"error",h,t,r),window[l]=c,a&&e.isFunction(c)&&c(a[0]),c=a=void 0})),!1===f(h,t)?(d("abort"),h):(window[l]=function(){a=arguments},u.src=t.url.replace(/\?(.+)=\?/,"?$1="+l),n.head.appendChild(u),t.timeout>0&&(s=setTimeout((function(){d("timeout")}),t.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:m,success:m,error:m,complete:m,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:u,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:m},e.ajax=function(i){var a,v,y=e.extend({},i||{}),E=e.Deferred&&e.Deferred();for(t in e.ajaxSettings)void 0===y[t]&&(y[t]=e.ajaxSettings[t]);!function(t){t.global&&0==e.active++&&h(t,null,"ajaxStart")}(y),y.crossDomain||((a=n.createElement("a")).href=y.url,a.href=a.href,y.crossDomain=d.protocol+"//"+d.host!=a.protocol+"//"+a.host),y.url||(y.url=window.location.toString()),(v=y.url.indexOf("#"))>-1&&(y.url=y.url.slice(0,v)),function(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=A(t.url,t.data),t.data=void 0)}(y);var _=y.dataType,T=/\?.+=\?/.test(y.url);if(T&&(_="jsonp"),!1!==y.cache&&(i&&!0===i.cache||"script"!=_&&"jsonp"!=_)||(y.url=A(y.url,"_="+Date.now())),"jsonp"==_)return T||(y.url=A(y.url,y.jsonp?y.jsonp+"=?":!1===y.jsonp?"":"callback=?")),e.ajaxJSONP(y,E);var b,k=y.accepts[_],S={},R=function(e,t){S[e.toLowerCase()]=[e,t]},w=/^([\w-]+:)\/\//.test(y.url)?RegExp.$1:window.location.protocol,L=y.xhr(),C=L.setRequestHeader;if(E&&E.promise(L),y.crossDomain||R("X-Requested-With","XMLHttpRequest"),R("Accept",k||"*/*"),(k=y.mimeType||k)&&(k.indexOf(",")>-1&&(k=k.split(",",2)[0]),L.overrideMimeType&&L.overrideMimeType(k)),(y.contentType||!1!==y.contentType&&y.data&&"GET"!=y.type.toUpperCase())&&R("Content-Type",y.contentType||"application/x-www-form-urlencoded"),y.headers)for(r in y.headers)R(r,y.headers[r]);if(L.setRequestHeader=R,L.onreadystatechange=function(){if(4==L.readyState){L.onreadystatechange=m,clearTimeout(b);var t,r=!1;if(L.status>=200&&L.status<300||304==L.status||0==L.status&&"file:"==w){if(_=_||function(e){return e&&(e=e.split(";",2)[0]),e&&(e==u?"html":e==l?"json":s.test(e)?"script":o.test(e)&&"xml")||"text"}(y.mimeType||L.getResponseHeader("content-type")),"arraybuffer"==L.responseType||"blob"==L.responseType)t=L.response;else{t=L.responseText;try{t=function(e,t,r){if(r.dataFilter==m)return e;var i=r.context;return r.dataFilter.call(i,e,t)}(t,_,y),"script"==_?(0,eval)(t):"xml"==_?t=L.responseXML:"json"==_&&(t=c.test(t)?null:e.parseJSON(t))}catch(e){r=e}if(r)return p(r,"parsererror",L,y,E)}g(t,L,y,E)}else p(L.statusText||null,L.status?"error":"abort",L,y,E)}},!1===f(L,y))return L.abort(),p(null,"abort",L,y,E),L;var O=!("async"in y)||y.async;if(L.open(y.type,y.url,O,y.username,y.password),y.xhrFields)for(r in y.xhrFields)L[r]=y.xhrFields[r];for(r in S)C.apply(L,S[r]);return y.timeout>0&&(b=setTimeout((function(){L.onreadystatechange=m,L.abort(),p(null,"timeout",L,y,E)}),y.timeout)),L.send(y.data?y.data:null),L},e.get=function(){return e.ajax(y.apply(null,arguments))},e.post=function(){var t=y.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=y.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,r,i){if(!this.length)return this;var n,s=this,o=t.split(/\s/),l=y(t,r,i),u=l.success;return o.length>1&&(l.url=o[0],n=o[1]),l.success=function(t){s.html(n?e("<div>").html(t.replace(a,"")).find(n):t),u&&u.apply(s,arguments)},e.ajax(l),this};var E=encodeURIComponent;function _(t,r,i,n){var a,s=e.isArray(r),o=e.isPlainObject(r);e.each(r,(function(r,l){a=e.type(l),n&&(r=i?n:n+"["+(o||"object"==a||"array"==a?r:"")+"]"),!n&&s?t.add(l.name,l.value):"array"==a||!i&&"object"==a?_(t,l,i,r):t.add(r,l)}))}e.param=function(t,r){var i=[];return i.add=function(t,r){e.isFunction(r)&&(r=r()),null==r&&(r=""),this.push(E(t)+"="+E(r))},_(i,t,r),i.join("&").replace(/%20/g,"+")}}(P),(D=P).Callbacks=function(e){e=D.extend({},e);var t,r,i,n,a,s,o=[],l=!e.once&&[],u=function(d){for(t=e.memory&&d,r=!0,s=n||0,n=0,a=o.length,i=!0;o&&s<a;++s)if(!1===o[s].apply(d[0],d[1])&&e.stopOnFalse){t=!1;break}i=!1,o&&(l?l.length&&u(l.shift()):t?o.length=0:c.disable())},c={add:function(){if(o){var r=o.length,s=function(t){D.each(t,(function(t,r){"function"==typeof r?e.unique&&c.has(r)||o.push(r):r&&r.length&&"string"!=typeof r&&s(r)}))};s(arguments),i?a=o.length:t&&(n=r,u(t))}return this},remove:function(){return o&&D.each(arguments,(function(e,t){for(var r;(r=D.inArray(t,o,r))>-1;)o.splice(r,1),i&&(r<=a&&--a,r<=s&&--s)})),this},has:function(e){return!(!o||!(e?D.inArray(e,o)>-1:o.length))},empty:function(){return a=o.length=0,this},disable:function(){return o=l=t=void 0,this},disabled:function(){return!o},lock:function(){return l=void 0,t||c.disable(),this},locked:function(){return!l},fireWith:function(e,t){return!o||r&&!l||(t=[e,(t=t||[]).slice?t.slice():t],i?l.push(t):u(t)),this},fire:function(){return c.fireWith(this,arguments)},fired:function(){return!!r}};return c},function(e){var t=Array.prototype.slice;function r(t){var i=[["resolve","done",e.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",e.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",e.Callbacks({memory:1})]],n="pending",a={state:function(){return n},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var t=arguments;return r((function(r){e.each(i,(function(i,n){var o=e.isFunction(t[i])&&t[i];s[n[1]]((function(){var t=o&&o.apply(this,arguments);if(t&&e.isFunction(t.promise))t.promise().done(r.resolve).fail(r.reject).progress(r.notify);else{var i=this===a?r.promise():this,s=o?[t]:arguments;r[n[0]+"With"](i,s)}}))})),t=null})).promise()},promise:function(t){return null!=t?e.extend(t,a):a}},s={};return e.each(i,(function(e,t){var r=t[2],o=t[3];a[t[1]]=r.add,o&&r.add((function(){n=o}),i[1^e][2].disable,i[2][2].lock),s[t[0]]=function(){return s[t[0]+"With"](this===s?a:this,arguments),this},s[t[0]+"With"]=r.fireWith})),a.promise(s),t&&t.call(s,s),s}e.when=function(i){var n,a,s,o=t.call(arguments),l=o.length,u=0,c=1!==l||i&&e.isFunction(i.promise)?l:0,d=1===c?i:r(),h=function(e,r,i){return function(a){r[e]=this,i[e]=arguments.length>1?t.call(arguments):a,i===n?d.notifyWith(r,i):--c||d.resolveWith(r,i)}};if(l>1)for(n=new Array(l),a=new Array(l),s=new Array(l);u<l;++u)o[u]&&e.isFunction(o[u].promise)?o[u].promise().done(h(u,s,o)).fail(d.reject).progress(h(u,a,n)):--c;return c||d.resolveWith(s,o),d.promise()},e.Deferred=r}(P),function(e){var t,r=1,i=Array.prototype.slice,n=e.isFunction,a=function(e){return"string"==typeof e},s={},o={},l="onfocusin"in window,u={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};function d(e){return e._zid||(e._zid=r++)}function h(e,t,r,i){if((t=f(t)).ns)var n=(a=t.ns,new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)"));var a;return(s[d(e)]||[]).filter((function(e){return e&&(!t.e||e.e==t.e)&&(!t.ns||n.test(e.ns))&&(!r||d(e.fn)===d(r))&&(!i||e.sel==i)}))}function f(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function g(e,t){return e.del&&!l&&e.e in u||!!t}function p(e){return c[e]||l&&u[e]||e}function v(r,i,n,a,o,l,u){var h=d(r),v=s[h]||(s[h]=[]);i.split(/\s/).forEach((function(i){if("ready"==i)return e(document).ready(n);var s=f(i);s.fn=n,s.sel=o,s.e in c&&(n=function(t){var r=t.relatedTarget;if(!r||r!==this&&!e.contains(this,r))return s.fn.apply(this,arguments)}),s.del=l;var d=l||n;s.proxy=function(e){if(!(e=T(e)).isImmediatePropagationStopped()){e.data=a;var i=d.apply(r,e._args==t?[e]:[e].concat(e._args));return!1===i&&(e.preventDefault(),e.stopPropagation()),i}},s.i=v.length,v.push(s),"addEventListener"in r&&r.addEventListener(p(s.e),s.proxy,g(s,u))}))}function m(e,t,r,i,n){var a=d(e);(t||"").split(/\s/).forEach((function(t){h(e,t,r,i).forEach((function(t){delete s[a][t.i],"removeEventListener"in e&&e.removeEventListener(p(t.e),t.proxy,g(t,n))}))}))}o.click=o.mousedown=o.mouseup=o.mousemove="MouseEvents",e.event={add:v,remove:m},e.proxy=function(t,r){var s=2 in arguments&&i.call(arguments,2);if(n(t)){var o=function(){return t.apply(r,s?s.concat(i.call(arguments)):arguments)};return o._zid=d(t),o}if(a(r))return s?(s.unshift(t[r],t),e.proxy.apply(null,s)):e.proxy(t[r],t);throw new TypeError("expected function")},e.fn.bind=function(e,t,r){return this.on(e,t,r)},e.fn.unbind=function(e,t){return this.off(e,t)},e.fn.one=function(e,t,r,i){return this.on(e,t,r,i,1)};var A=function(){return!0},y=function(){return!1},E=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,_={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function T(r,i){return!i&&r.isDefaultPrevented||(i||(i=r),e.each(_,(function(e,t){var n=i[e];r[e]=function(){return this[t]=A,n&&n.apply(i,arguments)},r[t]=y})),r.timeStamp||(r.timeStamp=Date.now()),(i.defaultPrevented!==t?i.defaultPrevented:"returnValue"in i?!1===i.returnValue:i.getPreventDefault&&i.getPreventDefault())&&(r.isDefaultPrevented=A)),r}function b(e){var r,i={originalEvent:e};for(r in e)E.test(r)||e[r]===t||(i[r]=e[r]);return T(i,e)}e.fn.delegate=function(e,t,r){return this.on(t,e,r)},e.fn.undelegate=function(e,t,r){return this.off(t,e,r)},e.fn.live=function(t,r){return e(document.body).delegate(this.selector,t,r),this},e.fn.die=function(t,r){return e(document.body).undelegate(this.selector,t,r),this},e.fn.on=function(r,s,o,l,u){var c,d,h=this;return r&&!a(r)?(e.each(r,(function(e,t){h.on(e,s,o,t,u)})),h):(a(s)||n(l)||!1===l||(l=o,o=s,s=t),l!==t&&!1!==o||(l=o,o=t),!1===l&&(l=y),h.each((function(t,n){u&&(c=function(e){return m(n,e.type,l),l.apply(this,arguments)}),s&&(d=function(t){var r,a=e(t.target).closest(s,n).get(0);if(a&&a!==n)return r=e.extend(b(t),{currentTarget:a,liveFired:n}),(c||l).apply(a,[r].concat(i.call(arguments,1)))}),v(n,r,l,o,s,d||c)})))},e.fn.off=function(r,i,s){var o=this;return r&&!a(r)?(e.each(r,(function(e,t){o.off(e,i,t)})),o):(a(i)||n(s)||!1===s||(s=i,i=t),!1===s&&(s=y),o.each((function(){m(this,r,s,i)})))},e.fn.trigger=function(t,r){return(t=a(t)||e.isPlainObject(t)?e.Event(t):T(t))._args=r,this.each((function(){t.type in u&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,r)}))},e.fn.triggerHandler=function(t,r){var i,n;return this.each((function(s,o){(i=b(a(t)?e.Event(t):t))._args=r,i.target=o,e.each(h(o,t.type||t),(function(e,t){if(n=t.proxy(i),i.isImmediatePropagationStopped())return!1}))})),n},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}})),e.Event=function(e,t){a(e)||(e=(t=e).type);var r=document.createEvent(o[e]||"Events"),i=!0;if(t)for(var n in t)"bubbles"==n?i=!!t[n]:r[n]=t[n];return r.initEvent(e,i,!0),T(r)}}(P),function(){try{getComputedStyle(void 0)}catch(t){var e=getComputedStyle;window.getComputedStyle=function(t,r){try{return e(t,r)}catch(e){return null}}}}(),function(e){var t=e.zepto,r=t.qsa,i=t.matches;function n(t){return!(!(t=e(t)).width()&&!t.height())&&"none"!==t.css("display")}var a=e.expr[":"]={visible:function(){if(n(this))return this},hidden:function(){if(!n(this))return this},selected:function(){if(this.selected)return this},checked:function(){if(this.checked)return this},parent:function(){return this.parentNode},first:function(e){if(0===e)return this},last:function(e,t){if(e===t.length-1)return this},eq:function(e,t,r){if(e===r)return this},contains:function(t,r,i){if(e(this).text().indexOf(i)>-1)return this},has:function(e,r,i){if(t.qsa(this,i).length)return this}},s=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),o=/^\s*>/,l="Zepto"+ +new Date;function u(e,t){e=e.replace(/=#\]/g,'="#"]');var r,i,n=s.exec(e);if(n&&n[2]in a&&(r=a[n[2]],i=n[3],e=n[1],i)){var o=Number(i);i=isNaN(o)?i.replace(/^["']|["']$/g,""):o}return t(e,r,i)}t.qsa=function(i,n){return u(n,(function(a,s,u){try{var c;!a&&s?a="*":o.test(a)&&(c=e(i).addClass(l),a="."+l+" "+a);var d=r(i,a)}catch(e){throw console.error("error performing selector: %o",n),e}finally{c&&c.removeClass(l)}return s?t.uniq(e.map(d,(function(e,t){return s.call(e,t,d,u)}))):d}))},t.matches=function(e,t){return u(t,(function(t,r,n){return(!t||i(e,t))&&(!r||r.call(e,null,n)===e)}))}}(P);var x,N,M,F=P,U=[{name:"Chromium",group:"Chrome",identifier:"Chromium/([0-9.]*)"},{name:"Chrome Mobile",group:"Chrome",identifier:"Chrome/([0-9.]*) Mobile",versionIdentifier:"Chrome/([0-9.]*)"},{name:"Chrome",group:"Chrome",identifier:"Chrome/([0-9.]*)"},{name:"Chrome for iOS",group:"Chrome",identifier:"CriOS/([0-9.]*)"},{name:"Android Browser",group:"Chrome",identifier:"CrMo/([0-9.]*)"},{name:"Firefox",group:"Firefox",identifier:"Firefox/([0-9.]*)"},{name:"Opera Mini",group:"Opera",identifier:"Opera Mini/([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera ([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"},{name:"IEMobile",group:"Explorer",identifier:"IEMobile/([0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"MSIE ([a-zA-Z0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"Trident/([0-9.]*)",versionIdentifier:"rv:([0-9.]*)"},{name:"Spartan",group:"Spartan",identifier:"Edge/([0-9.]*)",versionIdentifier:"Edge/([0-9.]*)"},{name:"Safari",group:"Safari",identifier:"Safari/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"}],B=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X High Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])13([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])12([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],j={},G=function(e,t){var r=e.split(".",2);t.fullVersion=e,r[0]&&(t.majorVersion=parseInt(r[0])),r[1]&&(t.minorVersion=parseInt(r[1]))},K=function(e,t,r){var i="["==t.substr(0,1)?new RegExp(t,"g"):t,n=e.split(i,2);"."!=t&&(e=e.replace(new RegExp(t,"g"),".")),r.fullVersion=e,n&&n[0]&&(r.majorVersion=parseInt(n[0])),n&&n[1]&&(r.minorVersion=parseInt(n[1]))},Y=function(e){var t,r=e.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(r[1]))return t=/\brv[ :]+(\d+)/g.exec(e)||[],{name:"IE",version:parseInt(t[1]||"")};if("Chrome"===r[1]){if(null!=(t=e.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:parseInt(t[1])};if(null!=(t=e.match(/\bEdge\/(\d+)/)))return{name:"Edge",version:parseInt(t[1])}}else/android/i.test(e)&&(t=e.match(/version\/(\d+)/i))&&(r.splice(1,1,"Android WebView"),r.splice(2,1,t[1]));return{name:(r=r[2]?[r[1],r[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(r[1])}}(navigator.userAgent);j.isEdge=/edge/i.test(navigator.userAgent),j.isChrome=/chrome|CriOS/i.test(navigator.userAgent)&&!j.isEdge,j.isSafari=/safari/i.test(navigator.userAgent)&&!j.isChrome&&!j.isEdge,j.isFirefox=/firefox/i.test(navigator.userAgent),j.isLegacyIE=!!window.ActiveXObject,j.isIE=j.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),j.isIE11=/trident.*rv:11/i.test(navigator.userAgent),j.isChromecast=j.isChrome&&/CrKey/i.test(navigator.userAgent),j.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),j.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),j.isAndroid=/Android/i.test(navigator.userAgent),j.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),j.isWin8App=/MSAppHost/i.test(navigator.userAgent),j.isWiiU=/WiiU/i.test(navigator.userAgent),j.isPS4=/PlayStation 4/i.test(navigator.userAgent),j.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(e){return!1}}(),j.hasFlash=function(){try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){return!(!navigator.mimeTypes||void 0===navigator.mimeTypes["application/x-shockwave-flash"]||!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)}}(),j.name=Y.name,j.version=Y.version,j.userAgent=navigator.userAgent,j.data=function(){var e,t={},r=j.userAgent.toLowerCase(),i=O(U);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a&&a[1]){if(t.name=n.name,t.group=n.group,n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&G(s[1],t)}else G(a[1],t);break}}}catch(e){i.e(e)}finally{i.f()}return t}(),j.os=function(){var e,t={},r=j.userAgent.toLowerCase(),i=O(B);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a){if(t.name=n.name,t.group=n.group,n.version)K(n.version,n.versionSeparator?n.versionSeparator:".",t);else if(a[1])K(a[1],n.versionSeparator?n.versionSeparator:".",t);else if(n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&K(s[1],n.versionSeparator?n.versionSeparator:".",t)}break}}}catch(e){i.e(e)}finally{i.f()}return t}(),j.viewport=((x={}).width=F(window).width(),x.height=F(window).height(),x),j.device=(N=j.userAgent,(M=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(N))&&(M[1]||M[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:j.viewport.orientation="landscape";break;default:j.viewport.orientation="portrait"}}();var V={},H=[],W=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}).bind(window),z=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function q(e,t){if(t)for(var r in t){var i=Object.getOwnPropertyDescriptor(t,r);i?Object.defineProperty(e,r,i):e[r]=t[r]}return e}function X(e,t){var r=function(e){y(i,e);var r=k(i);function i(){var e;f(this,i);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return e=r.call.apply(r,[this].concat(a)),t.initialize&&t.initialize.apply(T(e),a),e}return i}(e);return q(r.prototype,t),r}var $={fullscreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullscreen:function(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen){if("function"==typeof e.then)return e.webkitRequestFullscreen();e.webkitRequestFullscreen()}else{if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();e.querySelector&&e.querySelector("video")&&e.querySelector("video").webkitEnterFullScreen?e.querySelector("video").webkitEnterFullScreen():e.webkitEnterFullScreen&&e.webkitEnterFullScreen()}},cancelFullscreen:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;e.exitFullscreen?e.exitFullscreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.webkitExitFullscreen?e.webkitExitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.msExitFullscreen&&e.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},Z=function(){function e(){f(this,e)}return p(e,null,[{key:"parse",value:function(e){for(var t,r=/\+/g,i=/([^&=]+)=?([^&]*)/g,n=function(e){return decodeURIComponent(e.replace(r," "))},a={};t=i.exec(e);)a[n(t[1]).toLowerCase()]=n(t[2]);return a}},{key:"params",get:function(){var e=window.location.search.substring(1);return e!==this.query&&(this._urlParams=this.parse(e),this.query=e),this._urlParams}},{key:"hashParams",get:function(){var e=window.location.hash.substring(1);return e!==this.hash&&(this._hashParams=this.parse(e),this.hash=e),this._hashParams}}]),e}();function Q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",t=0,r=Z.params[e]||Z.hashParams[e]||"",i=r.match(/[0-9]+[hms]+/g)||[];if(i.length>0){var n={h:3600,m:60,s:1};i.forEach((function(e){if(e){var r=e[e.length-1],i=parseInt(e.slice(0,e.length-1),10);t+=i*n[r]}}))}else r&&(t=parseInt(r,10));return t}function J(e){return V[e]||(V[e]=0),e+ ++V[e]}function ee(e){return e-parseFloat(e)+1>=0}function te(){var e=document.getElementsByTagName("script");return e.length?e[e.length-1].src:""}function re(){return window.navigator&&window.navigator.language}function ie(e,t){var r=(t=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:I.mp4,element:null},t)).element?t.element:document.createElement(t.type);r.muted=t.muted,!0===t.muted&&r.setAttribute("muted","muted"),!0===t.inline&&r.setAttribute("playsinline","playsinline"),r.src=t.source;var i=r.play(),n=setTimeout((function(){a(!1,new Error("Timeout ".concat(t.timeout," ms has been reached")))}),t.timeout),a=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(n),e(t,r)};void 0!==i?i.then((function(){return a(!0)})).catch((function(e){return a(!1,e)})):a(!0)}var ne=function(){function e(){f(this,e)}return p(e,null,[{key:"configure",value:function(e){this.options=F.extend(!0,this.options,e)}},{key:"create",value:function(e){return this.options.recycleVideo&&"video"===e&&H.length>0?H.shift():document.createElement(e)}},{key:"garbage",value:function(e){this.options.recycleVideo&&"VIDEO"===e.tagName.toUpperCase()&&(F(e).children().remove(),Object.values(e.attributes).forEach((function(t){return e.removeAttribute(t.name)})),H.push(e))}}]),e}();ne.options={recycleVideo:!1};var ae=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;f(this,e),this.delay=t,this.lastTime=0}return p(e,[{key:"handle",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(new Date).getTime(),n=i-this.lastTime;n<this.delay&&n>0&&(t(),r&&e.preventDefault()),this.lastTime=i}}]),e}(),se=function(){return window.performance&&window.performance.now?performance.now():Date.now()},oe=function(e,t){return void 0!==e&&void 0!==t&&void 0!==t.find((function(t){return e.toLowerCase()===t.toLowerCase()}))},le="font-weight: bold; font-size: 13px;",ue="color: #ff8000;"+le,ce="color: #ff0000;"+le,de=["color: #0000ff;font-weight: bold; font-size: 13px;","color: #006600;font-weight: bold; font-size: 13px;",ue,ce,ce],he=["debug","info","warn","error","disabled"],fe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;f(this,e),this.EXCLUDE_LIST=["timeupdate","playback:timeupdate","playback:progress","container:hover","container:timeupdate","container:progress"],this.level=t,this.previousLevel=this.level,this.offLevel=r}return p(e,[{key:"level",get:function(){return this._level},set:function(e){this._level=e}}]),p(e,[{key:"debug",value:function(e){this.log(e,0,Array.prototype.slice.call(arguments,1))}},{key:"info",value:function(e){this.log(e,1,Array.prototype.slice.call(arguments,1))}},{key:"warn",value:function(e){this.log(e,2,Array.prototype.slice.call(arguments,1))}},{key:"error",value:function(e){this.log(e,3,Array.prototype.slice.call(arguments,1))}},{key:"onOff",value:function(){this.level===this.offLevel?this.level=this.previousLevel:(this.previousLevel=this.level,this.level=this.offLevel),window.console&&window.console.log&&window.console.log("%c[Clappr.Log] set log level to "+he[this.level],ue)}},{key:"log",value:function(e,t,r){if(!(this.EXCLUDE_LIST.indexOf(r[0])>=0||t<this.level)){r||(r=e,e=null);var i=de[t],n="";e&&(n="["+e+"]"),window.console&&window.console.log&&window.console.log.apply(console,["%c["+he[t]+"]"+n,i].concat(r))}}}]),e}();fe.LEVEL_DEBUG=0,fe.LEVEL_INFO=1,fe.LEVEL_WARN=2,fe.LEVEL_ERROR=3,fe.getInstance=function(){return void 0===this._instance&&(this._instance=new this),this._instance},fe.setLevel=function(e){this.getInstance().level=e},fe.debug=function(){this.getInstance().debug.apply(this.getInstance(),arguments)},fe.info=function(){this.getInstance().info.apply(this.getInstance(),arguments)},fe.warn=function(){this.getInstance().warn.apply(this.getInstance(),arguments)},fe.error=function(){this.getInstance().error.apply(this.getInstance(),arguments)};var ge=Array.prototype.slice,pe=/\s+/,ve=function(e,t,r,i){if(!r)return!0;if("object"===h(r)){for(var n in r)e[t].apply(e,[n,r[n]].concat(i));return!1}if(pe.test(r)){for(var a=r.split(pe),s=0,o=a.length;s<o;s++)e[t].apply(e,[a[s]].concat(i));return!1}return!0},me=function(e,t,r,i){var n,a=-1,s=e.length,o=t[0],l=t[1],u=t[2];!function c(){try{switch(t.length){case 0:for(;++a<s;)(n=e[a]).callback.call(n.ctx);return;case 1:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o);return;case 2:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l);return;case 3:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l,u);return;default:for(;++a<s;)(n=e[a]).callback.apply(n.ctx,t);return}}catch(e){fe.error.apply(fe,[r,"error on event",i,"trigger","-",e]),c()}}()},Ae=function(){function e(){f(this,e)}return p(e,[{key:"on",value:function(e,t,r){return ve(this,"on",e,[t,r])&&t?(this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t,context:r,ctx:r||this}),this):this}},{key:"once",value:function(e,t,r){var i,n=this;if(!ve(this,"once",e,[t,r])||!t)return this;var a=function(){return n.off(e,i)};return i=function(){a(),t.apply(this,arguments)},this.on(e,i,r)}},{key:"off",value:function(e,t,r){var i,n,a,s,o,l,u,c;if(!this._events||!ve(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;for(o=0,l=(s=e?[e]:Object.keys(this._events)).length;o<l;o++)if(e=s[o],a=this._events[e]){if(this._events[e]=i=[],t||r)for(u=0,c=a.length;u<c;u++)n=a[u],(t&&t!==n.callback&&t!==n.callback._callback||r&&r!==n.context)&&i.push(n);i.length||delete this._events[e]}return this}},{key:"trigger",value:function(e){var t=this.name||this.constructor.name;if(fe.debug.apply(fe,[t].concat(Array.prototype.slice.call(arguments))),!this._events)return this;var r=ge.call(arguments,1);if(!ve(this,"trigger",e,r))return this;var i=this._events[e],n=this._events.all;return i&&me(i,r,t,e),n&&me(n,arguments,t,e),this}},{key:"stopListening",value:function(e,t,r){var i=this._listeningTo;if(!i)return this;var n=!t&&!r;for(var a in r||"object"!==h(t)||(r=this),e&&((i={})[e._listenId]=e),i)(e=i[a]).off(t,r,this),(n||0===Object.keys(e._events).length)&&delete this._listeningTo[a];return this}}],[{key:"register",value:function(t){e.Custom||(e.Custom={});var r="string"==typeof t&&t.toUpperCase().trim();r&&!e.Custom[r]?e.Custom[r]=r.toLowerCase().split("_").map((function(e,t){return 0===t?e:e=e[0].toUpperCase()+e.slice(1)})).join(""):fe.error("Events","Error when register event: "+t)}},{key:"listAvailableCustomEvents",value:function(){return e.Custom||(e.Custom={}),Object.keys(e.Custom).filter((function(t){return"string"==typeof e.Custom[t]}))}}]),e}(),ye={listenTo:"on",listenToOnce:"once"};Object.keys(ye).forEach((function(e){Ae.prototype[e]=function(t,r,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=J("l"))]=t,i||"object"!==h(r)||(i=this),t[ye[e]](r,i,this),this}})),Ae.PLAYER_READY="ready",Ae.PLAYER_RESIZE="resize",Ae.PLAYER_FULLSCREEN="fullscreen",Ae.PLAYER_PLAY="play",Ae.PLAYER_PAUSE="pause",Ae.PLAYER_STOP="stop",Ae.PLAYER_ENDED="ended",Ae.PLAYER_SEEK="seek",Ae.PLAYER_ERROR="playererror",Ae.ERROR="error",Ae.PLAYER_TIMEUPDATE="timeupdate",Ae.PLAYER_VOLUMEUPDATE="volumeupdate",Ae.PLAYER_SUBTITLE_AVAILABLE="subtitleavailable",Ae.PLAYBACK_PROGRESS="playback:progress",Ae.PLAYBACK_TIMEUPDATE="playback:timeupdate",Ae.PLAYBACK_READY="playback:ready",Ae.PLAYBACK_BUFFERING="playback:buffering",Ae.PLAYBACK_BUFFERFULL="playback:bufferfull",Ae.PLAYBACK_SETTINGSUPDATE="playback:settingsupdate",Ae.PLAYBACK_LOADEDMETADATA="playback:loadedmetadata",Ae.PLAYBACK_HIGHDEFINITIONUPDATE="playback:highdefinitionupdate",Ae.PLAYBACK_BITRATE="playback:bitrate",Ae.PLAYBACK_LEVELS_AVAILABLE="playback:levels:available",Ae.PLAYBACK_LEVEL_SWITCH_START="playback:levels:switch:start",Ae.PLAYBACK_LEVEL_SWITCH_END="playback:levels:switch:end",Ae.PLAYBACK_PLAYBACKSTATE="playback:playbackstate",Ae.PLAYBACK_DVR="playback:dvr",Ae.PLAYBACK_MEDIACONTROL_DISABLE="playback:mediacontrol:disable",Ae.PLAYBACK_MEDIACONTROL_ENABLE="playback:mediacontrol:enable",Ae.PLAYBACK_ENDED="playback:ended",Ae.PLAYBACK_PLAY_INTENT="playback:play:intent",Ae.PLAYBACK_PLAY="playback:play",Ae.PLAYBACK_PAUSE="playback:pause",Ae.PLAYBACK_SEEK="playback:seek",Ae.PLAYBACK_SEEKED="playback:seeked",Ae.PLAYBACK_STOP="playback:stop",Ae.PLAYBACK_ERROR="playback:error",Ae.PLAYBACK_STATS_ADD="playback:stats:add",Ae.PLAYBACK_FRAGMENT_LOADED="playback:fragment:loaded",Ae.PLAYBACK_LEVEL_SWITCH="playback:level:switch",Ae.PLAYBACK_SUBTITLE_AVAILABLE="playback:subtitle:available",Ae.PLAYBACK_SUBTITLE_CHANGED="playback:subtitle:changed",Ae.CORE_CONTAINERS_CREATED="core:containers:created",Ae.CORE_ACTIVE_CONTAINER_CHANGED="core:active:container:changed",Ae.CORE_OPTIONS_CHANGE="core:options:change",Ae.CORE_READY="core:ready",Ae.CORE_FULLSCREEN="core:fullscreen",Ae.CORE_RESIZE="core:resize",Ae.CORE_SCREEN_ORIENTATION_CHANGED="core:screen:orientation:changed",Ae.CORE_MOUSE_MOVE="core:mousemove",Ae.CORE_MOUSE_LEAVE="core:mouseleave",Ae.CONTAINER_PLAYBACKSTATE="container:playbackstate",Ae.CONTAINER_PLAYBACKDVRSTATECHANGED="container:dvr",Ae.CONTAINER_BITRATE="container:bitrate",Ae.CONTAINER_STATS_REPORT="container:stats:report",Ae.CONTAINER_DESTROYED="container:destroyed",Ae.CONTAINER_READY="container:ready",Ae.CONTAINER_RESIZE="container:resize",Ae.CONTAINER_ERROR="container:error",Ae.CONTAINER_LOADEDMETADATA="container:loadedmetadata",Ae.CONTAINER_SUBTITLE_AVAILABLE="container:subtitle:available",Ae.CONTAINER_SUBTITLE_CHANGED="container:subtitle:changed",Ae.CONTAINER_TIMEUPDATE="container:timeupdate",Ae.CONTAINER_PROGRESS="container:progress",Ae.CONTAINER_PLAY="container:play",Ae.CONTAINER_STOP="container:stop",Ae.CONTAINER_PAUSE="container:pause",Ae.CONTAINER_ENDED="container:ended",Ae.CONTAINER_CLICK="container:click",Ae.CONTAINER_DBLCLICK="container:dblclick",Ae.CONTAINER_CONTEXTMENU="container:contextmenu",Ae.CONTAINER_MOUSE_ENTER="container:mouseenter",Ae.CONTAINER_MOUSE_LEAVE="container:mouseleave",Ae.CONTAINER_SEEK="container:seek",Ae.CONTAINER_SEEKED="container:seeked",Ae.CONTAINER_VOLUME="container:volume",Ae.CONTAINER_FULLSCREEN="container:fullscreen",Ae.CONTAINER_STATE_BUFFERING="container:state:buffering",Ae.CONTAINER_STATE_BUFFERFULL="container:state:bufferfull",Ae.CONTAINER_SETTINGSUPDATE="container:settingsupdate",Ae.CONTAINER_HIGHDEFINITIONUPDATE="container:highdefinitionupdate",Ae.CONTAINER_MEDIACONTROL_SHOW="container:mediacontrol:show",Ae.CONTAINER_MEDIACONTROL_HIDE="container:mediacontrol:hide",Ae.CONTAINER_MEDIACONTROL_DISABLE="container:mediacontrol:disable",Ae.CONTAINER_MEDIACONTROL_ENABLE="container:mediacontrol:enable",Ae.CONTAINER_STATS_ADD="container:stats:add",Ae.CONTAINER_OPTIONS_CHANGE="container:options:change",Ae.MEDIACONTROL_RENDERED="mediacontrol:rendered",Ae.MEDIACONTROL_FULLSCREEN="mediacontrol:fullscreen",Ae.MEDIACONTROL_SHOW="mediacontrol:show",Ae.MEDIACONTROL_HIDE="mediacontrol:hide",Ae.MEDIACONTROL_MOUSEMOVE_SEEKBAR="mediacontrol:mousemove:seekbar",Ae.MEDIACONTROL_MOUSELEAVE_SEEKBAR="mediacontrol:mouseleave:seekbar",Ae.MEDIACONTROL_PLAYING="mediacontrol:playing",Ae.MEDIACONTROL_NOTPLAYING="mediacontrol:notplaying",Ae.MEDIACONTROL_CONTAINERCHANGED="mediacontrol:containerchanged",Ae.MEDIACONTROL_OPTIONS_CHANGE="mediacontrol:options:change";var Ee=function(e){y(r,e);var t=k(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return f(this,r),(e=t.call(this,i))._options=i,e.uniqueId=J("o"),e}return p(r,[{key:"options",get:function(){return this._options}}]),r}(Ae),_e={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Te=/(.)^/,be={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},ke=/\\|'|\r|\n|\t|\u2028|\u2029/g,Se={"&":"&","<":"<",">":">",'"':""","'":"'"},Re=new RegExp("[&<>\"']","g"),we=function(e){return null===e?"":(""+e).replace(Re,(function(e){return Se[e]}))},Le=0,Ce=function(e,t){var r,i=new RegExp([(_e.escape||Te).source,(_e.interpolate||Te).source,(_e.evaluate||Te).source].join("|")+"|$","g"),n=0,a="__p+='";e.replace(i,(function(t,r,i,s,o){return a+=e.slice(n,o).replace(ke,(function(e){return"\\"+be[e]})),r&&(a+="'+\n((__t=("+r+"))==null?'':escapeExpr(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),s&&(a+="';\n"+s+"\n__p+='"),n=o+t.length,t})),a+="';\n",_e.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n//# sourceURL=/microtemplates/source["+Le+++"]";try{r=new Function(_e.variable||"obj","escapeExpr",a)}catch(e){throw e.source=a,e}if(t)return r(t,we);var s=function(e){return r.call(this,e,we)};return s.source="function("+(_e.variable||"obj")+"){\n"+a+"}",s};Ce.settings=_e;var Oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return F('<style class="clappr-style"></style>').html(Ce(e.toString())(t))},De=/^(\S+)\s*(.*)$/,Ie=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e)).cid=J("c"),i._ensureElement(),i.delegateEvents(),i}return p(r,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}}]),p(r,[{key:"$",value:function(e){return this.$el.find(e)}},{key:"render",value:function(){return this}},{key:"destroy",value:function(){return this.$el.remove(),this.stopListening(),this.undelegateEvents(),this}},{key:"setElement",value:function(e,t){return this.$el&&this.undelegateEvents(),this.$el=F.zepto.isZ(e)?e:F(e),this.el=this.$el[0],!1!==t&&this.delegateEvents(),this}},{key:"delegateEvents",value:function(e){for(var t in e||(e=this.events),this.undelegateEvents(),e){var r=e[t];if(r&&r.constructor!==Function&&(r=this[e[t]]),r){var i=t.match(De),n=i[1],a=i[2];n+=".delegateEvents"+this.cid,""===a?this.$el.on(n,r.bind(this)):this.$el.on(n,a,r.bind(this))}}return this}},{key:"undelegateEvents",value:function(){return this.$el.off(".delegateEvents"+this.cid),this}},{key:"_ensureElement",value:function(){if(this.el)this.setElement(this.el,!1);else{var e=F.extend(!0,{},this.attributes);this.id&&(e.id=this.id),this.className&&(e.class=this.className);var t=F(ne.create(this.tagName)).attr(e);this.setElement(t,!1)}}}]),r}(Ee),Pe=function(e){y(r,e);var t=k(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return f(this,r),(e=t.call(this,i)).core=n,e}return p(r,[{key:"name",get:function(){return"error"}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}]),p(r,[{key:"createError",value:function(e){this.core?this.core.trigger(Ae.ERROR,e):fe.warn(this.name,"Core is not set. Error: ",e)}}]),r}(Ee),xe={createError:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},r=this.constructor&&this.constructor.type||"",i=this.name||r,n=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,a="".concat(i,":").concat(e&&e.code||"unknown"),s={description:"",level:Pe.Levels.FATAL,origin:i,scope:r,raw:{}},o=Object.assign({},s,e,{code:t.useCodePrefix?a:e.code});if(n&&o.level==Pe.Levels.FATAL&&!o.UI){var l={title:n.t("default_error_title"),message:n.t("default_error_message")};o.UI=l}return this.playerError?this.playerError.createError(o):fe.warn(i,"PlayerError is not defined. Error: ",o),o}},Ne=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i.render(),i}return p(r,[{key:"playerError",get:function(){return this.core.playerError}}]),p(r,[{key:"bindEvents",value:function(){}},{key:"getExternalInterface",value:function(){return{}}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"render",value:function(){return this}}]),r}(Ie);Object.assign(Ne.prototype,xe),Ne.extend=function(e){return X(Ne,e)},Ne.type="core";var Me=function(e){y(r,e);var t=k(r);function r(e,i,n){var a;return f(this,r),(a=t.call(this,e))._i18n=i,a.currentTime=0,a.volume=100,a.playback=e.playback,a.playerError=n,a.settings=F.extend(!0,{},a.playback.settings),a.isReady=!1,a.mediaControlDisabled=!1,a.plugins=[a.playback],a.dblTapHandler=new ae(500),a.clickTimer=null,a.clickDelay=200,a.bindEvents(),a}return p(r,[{key:"name",get:function(){return"Container"}},{key:"attributes",get:function(){return{class:"container","data-container":""}}},{key:"events",get:function(){return{click:"clicked",dblclick:"dblClicked",touchend:"dblTap",contextmenu:"onContextMenu",mouseenter:"mouseEnter",mouseleave:"mouseLeave"}}},{key:"ended",get:function(){return this.playback.ended}},{key:"buffering",get:function(){return this.playback.buffering}},{key:"i18n",get:function(){return this._i18n}},{key:"hasClosedCaptionsTracks",get:function(){return this.playback.hasClosedCaptionsTracks}},{key:"closedCaptionsTracks",get:function(){return this.playback.closedCaptionsTracks}},{key:"closedCaptionsTrackId",get:function(){return this.playback.closedCaptionsTrackId},set:function(e){this.playback.closedCaptionsTrackId=e}}]),p(r,[{key:"bindEvents",value:function(){this.listenTo(this.playback,Ae.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,Ae.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,Ae.PLAYBACK_READY,this.ready),this.listenTo(this.playback,Ae.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,Ae.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,Ae.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,Ae.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,Ae.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,Ae.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,Ae.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,Ae.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,Ae.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,Ae.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,Ae.PLAYBACK_SEEK,this.onSeek),this.listenTo(this.playback,Ae.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,Ae.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,Ae.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,Ae.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,Ae.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,Ae.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,Ae.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,Ae.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged)}},{key:"subtitleAvailable",value:function(){this.trigger(Ae.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(e){this.trigger(Ae.CONTAINER_SUBTITLE_CHANGED,e)}},{key:"playbackStateChanged",value:function(e){this.trigger(Ae.CONTAINER_PLAYBACKSTATE,e)}},{key:"playbackDvrStateChanged",value:function(e){this.settings=this.playback.settings,this.dvrInUse=e,this.trigger(Ae.CONTAINER_PLAYBACKDVRSTATECHANGED,e)}},{key:"updateBitrate",value:function(e){this.trigger(Ae.CONTAINER_BITRATE,e)}},{key:"statsReport",value:function(e){this.trigger(Ae.CONTAINER_STATS_REPORT,e)}},{key:"getPlaybackType",value:function(){return this.playback.getPlaybackType()}},{key:"isDvrEnabled",value:function(){return!!this.playback.dvrEnabled}},{key:"isDvrInUse",value:function(){return!!this.dvrInUse}},{key:"destroy",value:function(){this.disableResizeObserver(),this.trigger(Ae.CONTAINER_DESTROYED,this,this.name),this.stopListening(),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove()}},{key:"setStyle",value:function(e){this.$el.css(e)}},{key:"animate",value:function(e,t){return this.$el.animate(e,t).promise()}},{key:"ready",value:function(){this.isReady=!0,this.trigger(Ae.CONTAINER_READY,this.name)}},{key:"isPlaying",value:function(){return this.playback.isPlaying()}},{key:"getStartTimeOffset",value:function(){return this.playback.getStartTimeOffset()}},{key:"getCurrentTime",value:function(){return this.currentTime}},{key:"getDuration",value:function(){return this.playback.getDuration()}},{key:"error",value:function(e){this.isReady||this.ready(),this.trigger(Ae.CONTAINER_ERROR,e,this.name)}},{key:"loadedMetadata",value:function(e){this.trigger(Ae.CONTAINER_LOADEDMETADATA,e)}},{key:"timeUpdated",value:function(e){this.currentTime=e.current,this.trigger(Ae.CONTAINER_TIMEUPDATE,e,this.name)}},{key:"onProgress",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.trigger.apply(this,[Ae.CONTAINER_PROGRESS].concat(t,[this.name]))}},{key:"playing",value:function(){this.trigger(Ae.CONTAINER_PLAY,this.name)}},{key:"paused",value:function(){this.trigger(Ae.CONTAINER_PAUSE,this.name)}},{key:"play",value:function(){this.playback.play()}},{key:"stop",value:function(){this.playback.stop(),this.currentTime=0}},{key:"pause",value:function(){this.playback.pause()}},{key:"onEnded",value:function(){this.trigger(Ae.CONTAINER_ENDED,this,this.name),this.currentTime=0}},{key:"stopped",value:function(){this.trigger(Ae.CONTAINER_STOP)}},{key:"clicked",value:function(){var e=this;this.options.chromeless&&!this.options.allowUserInteraction||(this.clickTimer=setTimeout((function(){e.clickTimer&&e.trigger(Ae.CONTAINER_CLICK,e,e.name)}),this.clickDelay))}},{key:"cancelClicked",value:function(){clearTimeout(this.clickTimer),this.clickTimer=null}},{key:"dblClicked",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||(this.cancelClicked(),this.trigger(Ae.CONTAINER_DBLCLICK,this,this.name))}},{key:"dblTap",value:function(e){var t=this;this.options.chromeless&&!this.options.allowUserInteraction||this.dblTapHandler.handle(e,(function(){t.cancelClicked(),t.trigger(Ae.CONTAINER_DBLCLICK,t,t.name)}))}},{key:"onContextMenu",value:function(e){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Ae.CONTAINER_CONTEXTMENU,e,this.name)}},{key:"seek",value:function(e){this.playback.seek(e)}},{key:"onSeek",value:function(e){this.trigger(Ae.CONTAINER_SEEK,e,this.name)}},{key:"onSeeked",value:function(){this.trigger(Ae.CONTAINER_SEEKED,this.name)}},{key:"seekPercentage",value:function(e){var t=this.getDuration();if(e>=0&&e<=100){var r=t*(e/100);this.seek(r)}}},{key:"setVolume",value:function(e){this.volume=parseFloat(e),this.trigger(Ae.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(Ae.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(Ae.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(Ae.CONTAINER_STATE_BUFFERFULL,this.name)}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"mouseEnter",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Ae.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Ae.CONTAINER_MOUSE_LEAVE)}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(Ae.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(e){this.trigger(Ae.CONTAINER_HIGHDEFINITIONUPDATE,e)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(Ae.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(Ae.CONTAINER_MEDIACONTROL_ENABLE))}},{key:"updateStyle",value:function(){!this.options.chromeless||this.options.allowUserInteraction?this.$el.removeClass("chromeless"):this.$el.addClass("chromeless")}},{key:"enableResizeObserver",value:function(){var e=this;this.disableResizeObserver(),this.resizeObserverInterval=setInterval((function(){return e.checkResize()}),500)}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval)}},{key:"checkResize",value:function(){var e={width:this.el.clientWidth,height:this.el.clientHeight},t=this.currentSize||{},r=t.width;(t.height!==e.height||r!==e.width)&&(this.currentSize=e,this.trigger(Ae.CONTAINER_RESIZE,e))}},{key:"configure",value:function(e){this._options=F.extend(!0,this._options,e),this.updateStyle(),this.playback.configure(this.options),this.trigger(Ae.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){var e=Oe(".container[data-container] {\n position: absolute;\n background-color: black;\n height: 100%;\n width: 100%;\n max-width: 100%; }\n .container[data-container] .chromeless {\n cursor: default; }\n\n[data-player]:not(.nocursor) .container[data-container]:not(.chromeless).pointer-enabled {\n cursor: pointer; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}]),r}(Ie);Object.assign(Me.prototype,xe);var Fe=function(e){y(r,e);var t=k(r);function r(e,i,n){var a;return f(this,r),(a=t.call(this,e)).settings={},a._i18n=i,a.playerError=n,a._consented=!1,a}return p(r,[{key:"isAudioOnly",get:function(){return!1}},{key:"isAdaptive",get:function(){return!1}},{key:"ended",get:function(){return!1}},{key:"i18n",get:function(){return this._i18n}},{key:"buffering",get:function(){return!1}}]),p(r,[{key:"consent",value:function(e){"function"==typeof e&&e()}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"stop",value:function(){}},{key:"seek",value:function(e){}},{key:"seekPercentage",value:function(e){}},{key:"getStartTimeOffset",value:function(){return 0}},{key:"getDuration",value:function(){return 0}},{key:"isPlaying",value:function(){return!1}},{key:"getPlaybackType",value:function(){return r.NO_OP}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"mute",value:function(){}},{key:"unmute",value:function(){}},{key:"volume",value:function(e){}},{key:"configure",value:function(e){this._options=F.extend(!0,this._options,e)}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){t&&e.play()}))}},{key:"canAutoPlay",value:function(e){e(!0,null)}},{key:"isReady",get:function(){return!1}},{key:"hasClosedCaptionsTracks",get:function(){return this.closedCaptionsTracks.length>0}},{key:"closedCaptionsTracks",get:function(){return[]}},{key:"closedCaptionsTrackId",get:function(){return-1},set:function(e){}}]),r}(Ie);Object.assign(Fe.prototype,xe),Fe.extend=function(e){return X(Fe,e)},Fe.canPlay=function(e,t){return!1},Fe.VOD="vod",Fe.AOD="aod",Fe.LIVE="live",Fe.NO_OP="no_op",Fe.type="playback";var Ue=function(e){y(r,e);var t=k(r);function r(e,i,n,a){var s;return f(this,r),(s=t.call(this,e))._i18n=n,s.loader=i,s.playerError=a,s}return p(r,[{key:"options",get:function(){return this._options},set:function(e){this._options=e}}]),p(r,[{key:"createContainers",value:function(){var e=this;return F.Deferred((function(t){t.resolve(e.options.sources.map((function(t){return e.createContainer(t)})))}))}},{key:"findPlaybackPlugin",value:function(e,t){return this.loader.playbackPlugins.filter((function(r){return r.canPlay(e,t)}))[0]}},{key:"createContainer",value:function(e){var t=null,r=this.options.mimeType;"object"===h(e)?(t=e.source.toString(),e.mimeType&&(r=e.mimeType)):t=e.toString(),t.match(/^\/\//)&&(t=window.location.protocol+t);var i=A(A({},this.options),{},{src:t,mimeType:r}),n=this.findPlaybackPlugin(t,r),a=n?new n(i,this._i18n,this.playerError):new Fe;i=A(A({},i),{},{playback:a});var s=new Me(i,this._i18n,this.playerError),o=F.Deferred();return o.promise(s),this.addContainerPlugins(s),this.listenToOnce(s,Ae.CONTAINER_READY,(function(){return o.resolve(s)})),s}},{key:"addContainerPlugins",value:function(e){this.loader.containerPlugins.forEach((function(t){e.addPlugin(new t(e))}))}}]),r}(Ee),Be=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e)).playerError=new Pe(e,T(i)),i.configureDomRecycler(),i.firstResize=!0,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},F(document).bind("fullscreenchange",i._boundFullscreenHandler),F(document).bind("MSFullscreenChange",i._boundFullscreenHandler),F(document).bind("mozfullscreenchange",i._boundFullscreenHandler),j.isMobile&&F(window).bind("resize",(function(e){i.handleWindowResize(e)})),i}return p(r,[{key:"events",get:function(){return{webkitfullscreenchange:"handleFullscreenChange",mousemove:"onMouseMove",mouseleave:"onMouseLeave"}}},{key:"attributes",get:function(){return{"data-player":"",tabindex:9999}}},{key:"isReady",get:function(){return!!this.ready}},{key:"i18n",get:function(){return this.getPlugin("strings")||{t:function(e){return e}}}},{key:"mediaControl",get:function(){return this._mediaControl||(this._mediaControl=this.getPlugin("media_control"))||this.dummyMediaControl}},{key:"dummyMediaControl",get:function(){return this._dummyMediaControl||(this._dummyMediaControl=new Ne(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(e){this._activeContainer=e,this.trigger(Ae.CORE_ACTIVE_CONTAINER_CHANGED,this._activeContainer)}},{key:"activePlayback",get:function(){return this.activeContainer&&this.activeContainer.playback}}]),p(r,[{key:"configureDomRecycler",value:function(){var e=this.options&&this.options.playback&&this.options.playback.recycleVideo;ne.configure({recycleVideo:e})}},{key:"createContainers",value:function(e){this.defer=F.Deferred(),this.defer.promise(this),this.containerFactory=new Ue(e,e.loader,this.i18n,this.playerError),this.prepareContainers()}},{key:"prepareContainers",value:function(){var e=this;this.containerFactory.createContainers().then((function(t){return e.setupContainers(t)})).then((function(t){return e.resolveOnContainersReady(t)}))}},{key:"updateSize",value:function(){this.isFullscreen()?this.setFullscreen():this.setPlayerSize()}},{key:"setFullscreen",value:function(){j.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:F(window).width(),height:F(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:F(window).width(),height:F(window).height()},this.resize(this.currentSize)}},{key:"resize",value:function(e){ee(e.height)||ee(e.width)?(this.el.style.height="".concat(e.height,"px"),this.el.style.width="".concat(e.width,"px")):(this.el.style.height="".concat(e.height),this.el.style.width="".concat(e.width)),this.previousSize={width:this.options.width,height:this.options.height},this.options.width=e.width,this.options.height=e.height,this.currentSize=e,this.triggerResize(this.currentSize)}},{key:"enableResizeObserver",value:function(){var e=this;this.disableResizeObserver();this.resizeObserverInterval=setInterval((function(){e.triggerResize({width:e.el.clientWidth,height:e.el.clientHeight})}),500)}},{key:"triggerResize",value:function(e){(this.firstResize||this.oldHeight!==e.height||this.oldWidth!==e.width)&&(this.oldHeight=e.height,this.oldWidth=e.width,this.computedSize=e,this.firstResize=!1,this.trigger(Ae.CORE_RESIZE,e))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(e){var t=this;F.when.apply(F,e).done((function(){t.defer.resolve(t),t.ready=!0,t.trigger(Ae.CORE_READY)}))}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"load",value:function(e,t){this.options.mimeType=t,e=e&&e.constructor===Array?e:[e],this.options.sources=e,this.containers.forEach((function(e){return e.destroy()})),this.containerFactory.options=F.extend(!0,this.options,{sources:e}),this.prepareContainers()}},{key:"destroy",value:function(){this.disableResizeObserver(),this.containers.forEach((function(e){return e.destroy()})),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove(),F(document).unbind("fullscreenchange",this._boundFullscreenHandler),F(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),F(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),this.stopListening()}},{key:"handleFullscreenChange",value:function(){this.trigger(Ae.CORE_FULLSCREEN,this.isFullscreen()),this.updateSize()}},{key:"handleWindowResize",value:function(e){var t=window.innerWidth>window.innerHeight?"landscape":"portrait";this._screenOrientation!==t&&(this._screenOrientation=t,this.triggerResize({width:this.el.clientWidth,height:this.el.clientHeight}),this.trigger(Ae.CORE_SCREEN_ORIENTATION_CHANGED,{event:e,orientation:this._screenOrientation}))}},{key:"removeContainer",value:function(e){this.stopListening(e),this.containers=this.containers.filter((function(t){return t!==e}))}},{key:"setupContainer",value:function(e){this.listenTo(e,Ae.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(e)}},{key:"setupContainers",value:function(e){return e.forEach(this.setupContainer.bind(this)),this.trigger(Ae.CORE_CONTAINERS_CREATED),this.renderContainers(),this.activeContainer=e[0],this.render(),this.appendToParent(),this.containers}},{key:"renderContainers",value:function(){var e=this;this.containers.forEach((function(t){return e.el.appendChild(t.render().el)}))}},{key:"createContainer",value:function(e,t){var r=this.containerFactory.createContainer(e,t);return this.setupContainer(r),this.el.appendChild(r.render().el),r}},{key:"getCurrentContainer",value:function(){return this.activeContainer}},{key:"getCurrentPlayback",value:function(){return this.activePlayback}},{key:"getPlaybackType",value:function(){return this.activeContainer&&this.activeContainer.getPlaybackType()}},{key:"isFullscreen",value:function(){var e=$.fullscreenElement();if(!e)return!1;var t=this.activePlayback&&this.activePlayback.el;return e===this.el||e===t}},{key:"toggleFullscreen",value:function(){var e=this;if(this.isFullscreen())$.cancelFullscreen(),!j.isiOS&&this.$el.removeClass("fullscreen nocursor");else{var t=j.isiOS?this.activePlayback&&this.activePlayback.el:this.el;if(!t)return;j.isSafari||j.isiOS?$.requestFullscreen(t):$.requestFullscreen(t).then((function(e){return e}),(function(t){return setTimeout((function(){if(!e.isFullscreen())throw new ReferenceError(t)}),600)})),!j.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(e){this.trigger(Ae.CORE_MOUSE_MOVE,e)}},{key:"onMouseLeave",value:function(e){this.trigger(Ae.CORE_MOUSE_LEAVE,e)}},{key:"configure",value:function(e){var t=this;this._options=F.extend(!0,this._options,e),this.configureDomRecycler();var r=e.source||e.sources;r&&this.load(r,e.mimeType||this.options.mimeType),this.trigger(Ae.CORE_OPTIONS_CHANGE,e),this.containers.forEach((function(e){return e.configure(t.options)}))}},{key:"appendToParent",value:function(){var e=Oe('[data-player] {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n -o-user-select: none;\n user-select: none;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n transform: translate3d(0, 0, 0);\n position: relative;\n margin: 0;\n padding: 0;\n border: 0;\n font-style: normal;\n font-weight: normal;\n text-align: center;\n overflow: hidden;\n font-size: 100%;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-shadow: 0 0 0;\n box-sizing: border-box; }\n [data-player]:focus {\n outline: 0; }\n [data-player] * {\n box-sizing: inherit; }\n [data-player] > * {\n float: none;\n max-width: none; }\n [data-player] > div {\n display: block; }\n [data-player].fullscreen {\n width: 100% !important;\n height: 100% !important;\n top: 0;\n left: 0; }\n [data-player].nocursor {\n cursor: none; }\n\n.clappr-style {\n display: none !important; }\n'.toString(),{baseUrl:this.options.baseUrl}),t=Oe('[data-player] div, [data-player] span, [data-player] applet, [data-player] object, [data-player] iframe,\n[data-player] h1, [data-player] h2, [data-player] h3, [data-player] h4, [data-player] h5, [data-player] h6, [data-player] p, [data-player] blockquote, [data-player] pre,\n[data-player] a, [data-player] abbr, [data-player] acronym, [data-player] address, [data-player] big, [data-player] cite, [data-player] code,\n[data-player] del, [data-player] dfn, [data-player] em, [data-player] img, [data-player] ins, [data-player] kbd, [data-player] q, [data-player] s, [data-player] samp,\n[data-player] small, [data-player] strike, [data-player] strong, [data-player] sub, [data-player] sup, [data-player] tt, [data-player] var,\n[data-player] b, [data-player] u, [data-player] i, [data-player] center,\n[data-player] dl, [data-player] dt, [data-player] dd, [data-player] ol, [data-player] ul, [data-player] li,\n[data-player] fieldset, [data-player] form, [data-player] label, [data-player] legend,\n[data-player] table, [data-player] caption, [data-player] tbody, [data-player] tfoot, [data-player] thead, [data-player] tr, [data-player] th, [data-player] td,\n[data-player] article, [data-player] aside, [data-player] canvas, [data-player] details, [data-player] embed,\n[data-player] figure, [data-player] figcaption, [data-player] footer, [data-player] header, [data-player] hgroup,\n[data-player] menu, [data-player] nav, [data-player] output, [data-player] ruby, [data-player] section, [data-player] summary,\n[data-player] time, [data-player] mark, [data-player] audio, [data-player] video {\n margin: 0;\n padding: 0;\n border: 0;\n font: inherit;\n font-size: 100%;\n vertical-align: baseline; }\n\n[data-player] table {\n border-collapse: collapse;\n border-spacing: 0; }\n\n[data-player] caption, [data-player] th, [data-player] td {\n text-align: left;\n font-weight: normal;\n vertical-align: middle; }\n\n[data-player] q, [data-player] blockquote {\n quotes: none; }\n [data-player] q:before, [data-player] q:after, [data-player] blockquote:before, [data-player] blockquote:after {\n content: "";\n content: none; }\n\n[data-player] a img {\n border: none; }\n'.toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0]),this.options.includeResetStyle&&this.$el.append(t[0]),!(this.$el.parent()&&this.$el.parent().length)&&this.$el.appendTo(this.options.parentElement)}},{key:"render",value:function(){this.options.width=this.options.width||this.$el.width(),this.options.height=this.options.height||this.$el.height();var e={width:this.options.width,height:this.options.height};return this.previousSize=this.currentSize=this.computedSize=e,this.updateSize(),this.enableResizeObserver(),this}}]),r}(Ie);Object.assign(Be.prototype,xe);var je,Ge,Ke=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e.options)).player=e,i}return p(r,[{key:"loader",get:function(){return this.player.loader}}]),p(r,[{key:"create",value:function(){return this.options.loader=this.loader,this.core=new Be(this.options),this.addCorePlugins(),this.core.createContainers(this.options),this.core}},{key:"addCorePlugins",value:function(){var e=this;return this.loader.corePlugins.forEach((function(t){var r=new t(e.core);e.core.addPlugin(r),e.setupExternalInterface(r)})),this.core}},{key:"setupExternalInterface",value:function(e){var t=e.getExternalInterface();for(var r in t)this.player[r]=t[r].bind(e)}}]),r}(Ee),Ye=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,Ve=function(){function e(t,r,i){f(this,e),this.major=parseInt(t||0,10),this.minor=parseInt(r||0,10),this.patch=parseInt(i||0,10)}return p(e,null,[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=t.match(Ye)||[],i=R(r,4),n=i[1],a=i[2],s=i[3];return void 0===n?null:new e(n,a,s)}}]),p(e,[{key:"compare",value:function(e){var t=this.major-e.major;return t=(t=t||this.minor-e.minor)||this.patch-e.patch}},{key:"inc",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"patch";return void 0!==this[e]&&(this[e]+=1),this}},{key:"satisfies",value:function(e,t){return this.compare(e)>=0&&(!t||this.compare(t)<0)}},{key:"toString",value:function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.patch)}}]),e}(),He=function(e,t){return e&&t?Object.entries(e).filter((function(e){return R(e,2)[1].type===t})).reduce((function(e,t){var r=R(t,2),i=r[0],n=r[1];return e[i]=n,e}),{}):{}},We=(je={plugins:{},playbacks:[]},Ge="0.4.18",function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;f(this,e),this.playerId=r,this.playbackPlugins=w(je.playbacks);var i=e.registeredPlugins,n=i.core,a=i.container;this.containerPlugins=Object.values(a),this.corePlugins=Object.values(n),Array.isArray(t)||this.validateExternalPluginsType(t),this.addExternalPlugins(t)}return p(e,null,[{key:"checkVersionSupport",value:function(e){var t=e.prototype,r=t.supportedVersion,i=t.name;if(!r||!r.min)return fe.warn("Loader","missing version information for ".concat(i)),!1;var n=r.max?Ve.parse(r.max):Ve.parse(r.min).inc("minor"),a=Ve.parse(r.min);return!!Ve.parse(Ge).satisfies(a,n)||(fe.warn("Loader","unsupported plugin ".concat(i,": Clappr version ").concat(Ge," does not match required range [").concat(a,",").concat(n,")")),!1)}},{key:"registerPlugin",value:function(t){if(!t||!t.prototype.name)return fe.warn("Loader","missing information to register plugin: ".concat(t)),!1;e.checkVersionSupport(t);var r=je.plugins;if(!r)return!1;var i=r[t.prototype.name];return i&&fe.warn("Loader","overriding plugin entry: ".concat(t.prototype.name," - ").concat(i)),r[t.prototype.name]=t,!0}},{key:"registerPlayback",value:function(t){if(!t||!t.prototype.name)return!1;e.checkVersionSupport(t);var r=je.playbacks,i=r.findIndex((function(e){return e.prototype.name===t.prototype.name}));if(i>=0){var n=r[i];r.splice(i,1),fe.warn("Loader","overriding playback entry: ".concat(n.name," - ").concat(n))}return je.playbacks=[t].concat(w(r)),!0}},{key:"unregisterPlugin",value:function(e){if(!e)return!1;var t=je.plugins;return!!t[e]&&(delete t[e],!0)}},{key:"unregisterPlayback",value:function(e){if(!e)return!1;var t=je.playbacks,r=t.findIndex((function(t){return t.prototype.name===e}));return!(r<0||(t.splice(r,1),je.playbacks=t,0))}},{key:"clearPlugins",value:function(){je.plugins={}}},{key:"clearPlaybacks",value:function(){je.playbacks=[]}},{key:"registeredPlaybacks",get:function(){return w(je.playbacks)}},{key:"registeredPlugins",get:function(){var e=je.plugins;return{core:He(e,"core"),container:He(e,"container")}}}]),p(e,[{key:"groupPluginsByType",value:function(e){return Array.isArray(e)&&(e=e.reduce((function(e,t){return e[t.type]||(e[t.type]=[]),e[t.type].push(t),e}),{})),e}},{key:"removeDups",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=function(e,r){return e[r.prototype.name]&&t||(e[r.prototype.name]&&delete e[r.prototype.name],e[r.prototype.name]=r),e},i=e.reduceRight(r,Object.create(null)),n=[];for(var a in i)n.unshift(i[a]);return n}},{key:"addExternalPlugins",value:function(t){var r="boolean"!=typeof t.loadExternalPluginsFirst||t.loadExternalPluginsFirst,i="boolean"!=typeof t.loadExternalPlaybacksFirst||t.loadExternalPlaybacksFirst;if((t=this.groupPluginsByType(t)).playback){var n=t.playback.filter((function(t){return e.checkVersionSupport(t),!0}));this.playbackPlugins=i?this.removeDups(n.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(n),!0)}if(t.container){var a=t.container.filter((function(t){return e.checkVersionSupport(t),!0}));this.containerPlugins=r?this.removeDups(a.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(a),!0)}if(t.core){var s=t.core.filter((function(t){return e.checkVersionSupport(t),!0}));this.corePlugins=r?this.removeDups(s.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(s),!0)}}},{key:"validateExternalPluginsType",value:function(e){["playback","container","core"].forEach((function(t){(e[t]||[]).forEach((function(e){var r="external "+e.type+" plugin on "+t+" array";if(e.type!==t)throw new ReferenceError(r)}))}))}}]),e}()),ze=te().replace(/\/[^/]+$/,""),qe=function(e){y(r,e);var t=k(r);function r(e){var i;f(this,r),i=t.call(this,e);var n={playerId:J(""),persistConfig:!0,width:640,height:360,baseUrl:ze,allowUserInteraction:j.isMobile,includeResetStyle:!0,playback:{recycleVideo:!0}};return i._options=F.extend(!0,n,e),i.options.sources=i._normalizeSources(e),i.options.chromeless||(i.options.allowUserInteraction=!0),i.options.allowUserInteraction||(i.options.disableKeyboardShortcuts=!0),i._registerOptionEventListeners(i.options.events),i._coreFactory=new Ke(T(i)),i.options.parentId?i.setParentId(i.options.parentId):i.options.parent&&i.attachTo(i.options.parent),i}return p(r,[{key:"loader",set:function(e){this._loader=e},get:function(){return this._loader||(this._loader=new We(this.options.plugins||{},this.options.playerId)),this._loader}},{key:"ended",get:function(){return this.core.activeContainer.ended}},{key:"buffering",get:function(){return this.core.activeContainer.buffering}},{key:"isReady",get:function(){return!!this._ready}},{key:"eventsMapping",get:function(){return{onReady:Ae.PLAYER_READY,onResize:Ae.PLAYER_RESIZE,onPlay:Ae.PLAYER_PLAY,onPause:Ae.PLAYER_PAUSE,onStop:Ae.PLAYER_STOP,onEnded:Ae.PLAYER_ENDED,onSeek:Ae.PLAYER_SEEK,onError:Ae.PLAYER_ERROR,onTimeUpdate:Ae.PLAYER_TIMEUPDATE,onVolumeUpdate:Ae.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:Ae.PLAYER_SUBTITLE_AVAILABLE}}}]),p(r,[{key:"setParentId",value:function(e){var t=document.querySelector(e);return t&&this.attachTo(t),this}},{key:"attachTo",value:function(e){return this.options.parentElement=e,this.core=this._coreFactory.create(),this._addEventListeners(),this}},{key:"_addEventListeners",value:function(){return this.core.isReady?this._onReady():this.listenToOnce(this.core,Ae.CORE_READY,this._onReady),this.listenTo(this.core,Ae.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,Ae.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,Ae.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var e=this.core.activeContainer;return e&&(this.listenTo(e,Ae.CONTAINER_PLAY,this._onPlay),this.listenTo(e,Ae.CONTAINER_PAUSE,this._onPause),this.listenTo(e,Ae.CONTAINER_STOP,this._onStop),this.listenTo(e,Ae.CONTAINER_ENDED,this._onEnded),this.listenTo(e,Ae.CONTAINER_SEEK,this._onSeek),this.listenTo(e,Ae.CONTAINER_ERROR,this._onError),this.listenTo(e,Ae.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(e,Ae.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(e,Ae.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).length>0;return i&&Object.keys(r).forEach((function(t){var i=e.eventsMapping[t];i&&e.off(i,r[t])})),Object.keys(t).forEach((function(r){var i=e.eventsMapping[r];if(i){var n=t[r];(n="function"==typeof n&&n)&&e.on(i,n)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(Ae.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(e){this.trigger(Ae.PLAYER_FULLSCREEN,e)}},{key:"_onVolumeUpdate",value:function(e){this.trigger(Ae.PLAYER_VOLUMEUPDATE,e)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(Ae.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(e){this.trigger(Ae.PLAYER_RESIZE,e)}},{key:"_onPlay",value:function(){this.trigger(Ae.PLAYER_PLAY)}},{key:"_onPause",value:function(){this.trigger(Ae.PLAYER_PAUSE)}},{key:"_onStop",value:function(){this.trigger(Ae.PLAYER_STOP,this.getCurrentTime())}},{key:"_onEnded",value:function(){this.trigger(Ae.PLAYER_ENDED)}},{key:"_onSeek",value:function(e){this.trigger(Ae.PLAYER_SEEK,e)}},{key:"_onTimeUpdate",value:function(e){this.trigger(Ae.PLAYER_TIMEUPDATE,e)}},{key:"_onError",value:function(e){this.trigger(Ae.PLAYER_ERROR,e)}},{key:"_normalizeSources",value:function(e){var t=e.sources||(void 0!==e.source?[e.source]:[]);return 0===t.length?[{source:"",mimeType:""}]:t}},{key:"resize",value:function(e){return this.core.resize(e),this}},{key:"load",value:function(e,t,r){return void 0!==r&&this.configure({autoPlay:!!r}),this.core.load(e,t),this}},{key:"destroy",value:function(){return this.stopListening(),this.core.destroy(),this}},{key:"consent",value:function(e){this.core.getCurrentPlayback().consent(e)}},{key:"play",value:function(){return this.core.activeContainer.play(),this}},{key:"pause",value:function(){return this.core.activeContainer.pause(),this}},{key:"stop",value:function(){return this.core.activeContainer.stop(),this}},{key:"seek",value:function(e){return this.core.activeContainer.seek(e),this}},{key:"seekPercentage",value:function(e){return this.core.activeContainer.seekPercentage(e),this}},{key:"mute",value:function(){return this.core.activePlayback.mute(),this}},{key:"unmute",value:function(){return this.core.activePlayback.unmute(),this}},{key:"isPlaying",value:function(){return this.core.activeContainer.isPlaying()}},{key:"isDvrEnabled",value:function(){return this.core.activeContainer.isDvrEnabled()}},{key:"isDvrInUse",value:function(){return this.core.activeContainer.isDvrInUse()}},{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._registerOptionEventListeners(e.events,this.options.events),this.core.configure(e),this}},{key:"getPlugin",value:function(e){return this.core.plugins.concat(this.core.activeContainer.plugins).filter((function(t){return t.name===e}))[0]}},{key:"getCurrentTime",value:function(){return this.core.activeContainer.getCurrentTime()}},{key:"getStartTimeOffset",value:function(){return this.core.activeContainer.getStartTimeOffset()}},{key:"getDuration",value:function(){return this.core.activeContainer.getDuration()}}]),r}(Ee);Object.assign(qe.prototype,xe);var Xe=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return p(r,[{key:"playerError",get:function(){return this.container.playerError}}]),p(r,[{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"bindEvents",value:function(){}},{key:"destroy",value:function(){this.stopListening()}}]),r}(Ee);Object.assign(Xe.prototype,xe),Xe.extend=function(e){return X(Xe,e)},Xe.type="container";var $e=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i}return p(r,[{key:"playerError",get:function(){return this.core.playerError}}]),p(r,[{key:"bindEvents",value:function(){}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"getExternalInterface",value:function(){return{}}},{key:"destroy",value:function(){this.stopListening()}}]),r}(Ee);Object.assign($e.prototype,xe),$e.extend=function(e){return X($e,e)},$e.type="core";var Ze=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return p(r,[{key:"playerError",get:function(){return this.container.playerError}}]),p(r,[{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"bindEvents",value:function(){}}]),r}(Ie);Object.assign(Ze.prototype,xe),Ze.extend=function(e){return X(Ze,e)},Ze.type="container";var Qe={mp4:["avc1.42E01E","avc1.58A01E","avc1.4D401E","avc1.64001E","mp4v.20.8","mp4v.20.240","mp4a.40.2"].map((function(e){return'video/mp4; codecs="'+e+', mp4a.40.2"'})),ogg:['video/ogg; codecs="theora, vorbis"','video/ogg; codecs="dirac"','video/ogg; codecs="theora, speex"'],"3gpp":['video/3gpp; codecs="mp4v.20.8, samr"'],webm:['video/webm; codecs="vp8, vorbis"'],mkv:['video/x-matroska; codecs="theora, vorbis"'],m3u8:["application/x-mpegurl"]};Qe.ogv=Qe.ogg,Qe["3gp"]=Qe["3gpp"];var Je={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},et=Object.keys(Je).reduce((function(e,t){return[].concat(w(e),w(Je[t]))}),[]),tt={code:"unknown",message:"unknown"},rt=function(e){y(r,e);var t=k(r);function r(){var e;f(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];(e=t.call.apply(t,[this].concat(n)))._destroyed=!1,e._loadStarted=!1,e._isBuffering=!1,e._playheadMoving=!1,e._playheadMovingTimer=null,e._stopped=!1,e._ccTrackId=-1,e._setupSrc(e.options.src),e.options.playback||(e.options.playback=e.options||{}),e.options.playback.disableContextMenu=e.options.playback.disableContextMenu||e.options.disableVideoTagContextMenu,e._minDvrSize=e.isValidMinimumDVRSizeConfig?e.minimumDVRSizeConfig:60;var s,o=e.options.playback,l=o.preload||(j.isSafari?"auto":e.options.preload);return e.options.poster&&("string"==typeof e.options.poster?s=e.options.poster:"string"==typeof e.options.poster.url&&(s=e.options.poster.url)),F.extend(!0,e.el,{muted:e.options.mute,defaultMuted:e.options.mute,loop:e.options.loop,poster:s,preload:l||"metadata",crossOrigin:o.crossOrigin,"x-webkit-playsinline":o.playInline}),(o.controls||e.options.useVideoTagDefaultControls)&&e.$el.attr("controls",""),o.playInline&&e.$el.attr({playsinline:"playsinline"}),o.crossOrigin&&e.$el.attr({crossorigin:o.crossOrigin}),e.settings={default:["seekbar"]},e.settings.left=["playpause","position","duration"],e.settings.right=["fullscreen","volume","hd-indicator"],o.externalTracks&&e._setupExternalTracks(o.externalTracks),e.options.autoPlay&&e.attemptAutoPlay(),e}return p(r,[{key:"name",get:function(){return"html5_video"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"tagName",get:function(){return this.isAudioOnly?"audio":"video"}},{key:"isAudioOnly",get:function(){var e=this.options.src,t=r._mimeTypesForUrl(e,Je,this.options.mimeType);return this.options.playback&&this.options.playback.audioOnly||this.options.audioOnly||et.indexOf(t[0])>=0}},{key:"attributes",get:function(){return{"data-html5-video":""}}},{key:"events",get:function(){return{canplay:"_onCanPlay",canplaythrough:"_handleBufferingEvents",durationchange:"_onDurationChange",ended:"_onEnded",error:"_onError",loadeddata:"_onLoadedData",loadedmetadata:"_onLoadedMetadata",pause:"_onPause",playing:"_onPlaying",progress:"_onProgress",seeking:"_onSeeking",seeked:"_onSeeked",stalled:"_handleBufferingEvents",timeupdate:"_onTimeUpdate",waiting:"_onWaiting"}}},{key:"ended",get:function(){return this.el.ended}},{key:"buffering",get:function(){return this._isBuffering}},{key:"isLive",get:function(){return this.getPlaybackType()===Fe.LIVE}},{key:"dvrEnabled",get:function(){return this.getDuration()>=this._minDvrSize&&this.isLive}},{key:"minimumDVRSizeConfig",get:function(){return this.options.playback&&this.options.playback.minimumDvrSize}},{key:"isValidMinimumDVRSizeConfig",get:function(){return void 0!==this.minimumDVRSizeConfig&&"number"==typeof this.minimumDVRSizeConfig}}]),p(r,[{key:"configure",value:function(e){S(E(r.prototype),"configure",this).call(this,e),this.el.loop=!!e.loop}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){r&&fe.warn(e.name,"autoplay error.",{result:t,error:r}),t&&setTimeout((function(){return!e._destroyed&&e.play()}),0)}))}},{key:"canAutoPlay",value:function(e){if(this.options.disableCanAutoPlay)e(!0,null);else{var t={timeout:this.options.autoPlayTimeout||500,inline:this.options.playback.playInline||!1,muted:this.options.mute||!1};j.isMobile&&ne.options.recycleVideo&&(t.element=this.el),ie(e,t)}}},{key:"_setupExternalTracks",value:function(e){this._externalTracks=e.map((function(e){return{kind:e.kind||"subtitles",label:e.label,lang:e.lang,src:e.src}}))}},{key:"_setupSrc",value:function(e){this.el.src!==e&&(this._ccIsSetup=!1,this.el.src=e,this._src=this.el.src)}},{key:"_onLoadedMetadata",value:function(e){this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_LOADEDMETADATA,{duration:e.target.duration,data:e}),this._updateSettings();var t=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Fe.LIVE&&t&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Fe.VOD||this.getPlaybackType()===Fe.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Ae.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var e="audio"===this.tagName?Fe.AOD:Fe.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Fe.LIVE:e}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(e){var t=this;if(this.isPlaying()||this.el._consented)S(E(r.prototype),"consent",this).call(this,e);else{var i=function i(){t.el.removeEventListener("loadedmetadata",i,!1),t.el.removeEventListener("error",i,!1),t.el._consented=!0,S(E(r.prototype),"consent",t).call(t,e)};this.el.addEventListener("loadedmetadata",i,!1),this.el.addEventListener("error",i,!1),this.el.load()}}},{key:"play",value:function(){this.trigger(Ae.PLAYBACK_PLAY_INTENT),this._stopped=!1,this._setupSrc(this._src),this._handleBufferingEvents();var e=this.el.play();e&&e.catch&&e.catch((function(){}))}},{key:"pause",value:function(){this.el.pause(),this.dvrEnabled&&this._updateDvr(!0)}},{key:"stop",value:function(){this.pause(),this._stopped=!0,this.el.removeAttribute("src"),this.el.load(),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_STOP)}},{key:"volume",value:function(e){0===e?(this.$el.attr({muted:"true"}),this.el.muted=!0):(this.$el.attr({muted:null}),this.el.muted=!1,this.el.volume=e/100)}},{key:"mute",value:function(){this.el.muted=!0}},{key:"unmute",value:function(){this.el.muted=!1}},{key:"isMuted",value:function(){return!0===this.el.muted||0===this.el.volume}},{key:"isPlaying",value:function(){return!this.el.paused&&!this.el.ended}},{key:"_startPlayheadMovingChecks",value:function(){null===this._playheadMovingTimer&&(this._playheadMovingTimeOnCheck=null,this._determineIfPlayheadMoving(),this._playheadMovingTimer=setInterval(this._determineIfPlayheadMoving.bind(this),500))}},{key:"_stopPlayheadMovingChecks",value:function(){null!==this._playheadMovingTimer&&(clearInterval(this._playheadMovingTimer),this._playheadMovingTimer=null,this._playheadMoving=!1)}},{key:"_determineIfPlayheadMoving",value:function(){var e=this._playheadMovingTimeOnCheck,t=this.el.currentTime;this._playheadMoving=e!==t,this._playheadMovingTimeOnCheck=t,this._handleBufferingEvents()}},{key:"_onWaiting",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onLoadedData",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onCanPlay",value:function(){this._handleBufferingEvents()}},{key:"_onPlaying",value:function(){this._checkForClosedCaptions(),this._startPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){this.trigger(Ae.PLAYBACK_SEEK,this.getCurrentTime()),this._handleBufferingEvents()}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(Ae.PLAYBACK_ENDED,this.name)}},{key:"_handleBufferingEvents",value:function(){var e=!this.el.ended&&!this.el.paused,t=this._loadStarted&&!this.el.ended&&!this._stopped&&(e&&!this._playheadMoving||this.el.readyState<this.el.HAVE_FUTURE_DATA);this._isBuffering!==t&&(this._isBuffering=t,t?this.trigger(Ae.PLAYBACK_BUFFERING,this.name):this.trigger(Ae.PLAYBACK_BUFFERFULL,this.name))}},{key:"_onError",value:function(){var e=this.el.error||tt,t=e.code,r=e.message,i=t===tt.code,n=this.createError({code:t,description:r,raw:this.el.error,level:i?Pe.Levels.WARN:Pe.Levels.FATAL});i?fe.warn(this.name,"HTML5 unknown error: ",n):this.trigger(Ae.PLAYBACK_ERROR,n)}},{key:"destroy",value:function(){this._destroyed=!0,this.handleTextTrackChange&&this.el.textTracks.removeEventListener("change",this.handleTextTrackChange),S(E(r.prototype),"destroy",this).call(this),this.el.removeAttribute("src"),this.el.load(),this._src=null,ne.garbage(this.el)}},{key:"_updateDvr",value:function(e){this.trigger(Ae.PLAYBACK_DVR,e),this.trigger(Ae.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"seek",value:function(e){e<0&&(fe.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this.el.seekable.start(0),this.el.currentTime=e}},{key:"seekPercentage",value:function(e){var t=this.el.duration*(e/100);this.seek(t)}},{key:"_checkInitialSeek",value:function(){var e=Q();0!==e&&this.seek(e)}},{key:"getCurrentTime",value:function(){return this.el.currentTime}},{key:"getDuration",value:function(){var e=this;if(this.isLive)try{return this.el.seekable.end(0)-this.el.seekable.start(0)}catch(t){setTimeout((function(){return e._updateSettings()}),1e3)}return this.el.duration}},{key:"_onTimeUpdate",value:function(){var e=this.isLive?this.getDuration():this.el.duration;this.trigger(Ae.PLAYBACK_TIMEUPDATE,{current:this.el.currentTime,total:e},this.name)}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(w(e),[{start:this.el.buffered.start(r),end:this.el.buffered.end(r)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.el.duration};this.trigger(Ae.PLAYBACK_PROGRESS,i,e)}}},{key:"_typeFor",value:function(e){var t=r._mimeTypesForUrl(e,Qe,this.options.mimeType);return 0===t.length&&(t=r._mimeTypesForUrl(e,Je,this.options.mimeType)),(t[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(Ae.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(Ae.PLAYBACK_SUBTITLE_AVAILABLE);var e=this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this.handleTextTrackChange=this._handleTextTrackChange.bind(this),this.el.textTracks.addEventListener("change",this.handleTextTrackChange)}this._ccIsSetup=!0}}},{key:"_handleTextTrackChange",value:function(){var e=this.closedCaptionsTracks.find((function(e){return"showing"===e.track.mode}))||{id:-1};this._ccTrackId!==e.id&&(this._ccTrackId=e.id,this.trigger(Ae.PLAYBACK_SUBTITLE_CHANGED,{id:e.id}))}},{key:"render",value:function(){this.options.playback.disableContextMenu&&this.$el.on("contextmenu",(function(){return!1})),this._externalTracks&&this._externalTracks.length>0&&this.$el.html(this.template({tracks:this._externalTracks})),this._ready();var e=Oe("[data-html5-video] {\n position: absolute;\n height: 100%;\n width: 100%;\n display: block; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this}},{key:"isReady",get:function(){return this._isReadyState}},{key:"isHTML5Video",get:function(){return this.name===r.prototype.name}},{key:"closedCaptionsTracks",get:function(){var e=0;return(this.el.textTracks?Array.from(this.el.textTracks):[]).filter((function(e){return"subtitles"===e.kind||"captions"===e.kind})).map((function(t){return{id:e++,name:t.label,track:t}}))}},{key:"closedCaptionsTrackId",get:function(){return this._ccTrackId},set:function(e){if(ee(e)){var t,r=this.closedCaptionsTracks;if(-1!==e){if(!(t=r.find((function(t){return t.id===e}))))return;if("showing"===t.track.mode)return}r.filter((function(e){return"hidden"!==e.track.mode})).forEach((function(e){return e.track.mode="hidden"})),t&&(t.track.mode="showing"),this._ccTrackId=e,this.trigger(Ae.PLAYBACK_SUBTITLE_CHANGED,{id:e})}}},{key:"template",get:function(){return Ce('<% for (var i = 0; i < tracks.length; i++) { %>\n <track data-html5-video-track="<%= i %>" kind="<%= tracks[i].kind %>" label="<%= tracks[i].label %>" srclang="<%= tracks[i].lang %>" src="<%= tracks[i].src %>">\n<% }; %>\n')}}]),r}(Fe);rt._mimeTypesForUrl=function(e,t,r){var i=(e.split("?")[0].match(/.*\.(.*)$/)||[])[1],n=r||i&&t[i.toLowerCase()]||[];return n.constructor===Array?n:[n]},rt._canPlay=function(e,t,r,i){var n=rt._mimeTypesForUrl(r,t,i),a=document.createElement(e);return!!n.filter((function(e){return!!a.canPlayType(e).replace(/no/,"")}))[0]},rt.canPlay=function(e,t){return rt._canPlay("audio",Je,e,t)||rt._canPlay("video",Qe,e,t)};var it=function(e){y(r,e);var t=k(r);function r(){return f(this,r),t.apply(this,arguments)}return p(r,[{key:"updateSettings",value:function(){this.settings.left=["playpause","position","duration"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Ae.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Fe.AOD}},{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"tagName",get:function(){return"audio"}},{key:"isAudioOnly",get:function(){return!0}}]),r}(rt);it.canPlay=function(e,t){return rt._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},e,t)};var nt=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e)).el.src=e.src,i}return p(r,[{key:"getPlaybackType",value:function(){return Fe.NO_OP}},{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"tagName",get:function(){return"img"}},{key:"attributes",get:function(){return{"data-html-img":""}}},{key:"events",get:function(){return{load:"_onLoad",abort:"_onError",error:"_onError"}}}]),p(r,[{key:"render",value:function(){var e=Oe("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this.trigger(Ae.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(Ae.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(e){var t="error"===e.type?"load error":"loading aborted";this.trigger(Ae.PLAYBACK_ERROR,{message:t},this.name)}}]),r}(Fe);nt.canPlay=function(e){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(e)};var at=function(e){y(r,e);var t=k(r);function r(){var e;f(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n)))._noiseFrameNum=-1,e}return p(r,[{key:"name",get:function(){return"no_op"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"template",get:function(){return Ce("<canvas data-no-op-canvas></canvas>\n<p data-no-op-msg><%=message%></p><p>\n</p>")}},{key:"attributes",get:function(){return{"data-no-op":""}}}]),p(r,[{key:"render",value:function(){var e=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported"),t=Oe("[data-no-op] {\n position: absolute;\n height: 100%;\n width: 100%;\n text-align: center; }\n\n[data-no-op] p[data-no-op-msg] {\n position: absolute;\n text-align: center;\n font-size: 25px;\n left: 0;\n right: 0;\n color: white;\n padding: 10px;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%);\n max-height: 100%;\n overflow: auto; }\n\n[data-no-op] canvas[data-no-op-canvas] {\n background-color: #777;\n height: 100%;\n width: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});this.$el.append(t[0]),this.$el.html(this.template({message:e})),this.trigger(Ae.PLAYBACK_READY,this.name);var r=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&r||this._animate(),this}},{key:"_noise",value:function(){if(this._noiseFrameNum=(this._noiseFrameNum+1)%5,!this._noiseFrameNum){var e,t=this.context.createImageData(this.context.canvas.width,this.context.canvas.height);try{e=new Uint32Array(t.data.buffer)}catch(n){e=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var r=t.data,i=0;i<r.length;i++)e[i]=r[i]}for(var n=e.length,a=6*Math.random()+4,s=0,o=0,l=0;l<n;){if(s<0)s=a*Math.random(),o=255*Math.pow(Math.random(),.4)<<24;s-=1,e[l++]=o}this.context.putImageData(t,0,0)}}},{key:"_loop",value:function(){var e=this;this._stop||(this._noise(),this._animationHandle=W((function(){return e._loop()})))}},{key:"destroy",value:function(){this._animationHandle&&(z(this._animationHandle),this._stop=!0)}},{key:"_animate",value:function(){this.canvas=this.$el.find("canvas[data-no-op-canvas]")[0],this.context=this.canvas.getContext("2d"),this._loop()}}]),r}(Fe);at.canPlay=function(e){return!0};var st=function(e){y(r,e);var t=k(r);function r(e){var i;return f(this,r),(i=t.call(this,e))._initializeMessages(),i}return p(r,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}}]),p(r,[{key:"t",value:function(e){var t=this._language(),r=this._messages.en;return(t&&this._messages[t]||r)[e]||r[e]||e}},{key:"_language",value:function(){return this.core.options.language||re()}},{key:"_initializeMessages",value:function(){this._messages=F.extend(!0,{en:{live:"live",back_to_live:"back to live",disabled:"Disabled",playback_not_supported:"Your browser does not support the playback of this video. Please try using a different browser.",default_error_title:"Could not play video.",default_error_message:"There was a problem trying to load the video."},de:{live:"Live",back_to_live:"Zurück zum Live-Video",disabled:"Deaktiviert",playback_not_supported:"Ihr Browser unterstützt das Playback Verfahren nicht. Bitte vesuchen Sie es mit einem anderen Browser.",default_error_title:"Video kann nicht abgespielt werden",default_error_message:"Es gab ein Problem beim Laden des Videos"},pt:{live:"ao vivo",back_to_live:"voltar para o ao vivo",disabled:"Desativado",playback_not_supported:"Seu navegador não supporta a reprodução deste video. Por favor, tente usar um navegador diferente.",default_error_title:"Não foi possível reproduzir o vídeo.",default_error_message:"Ocorreu um problema ao tentar carregar o vídeo."},es:{live:"vivo",back_to_live:"volver en vivo",disabled:"Discapacitado",playback_not_supported:"Su navegador no soporta la reproducción de un video. Por favor, trate de usar un navegador diferente."},ru:{live:"прямой эфир",back_to_live:"к прямому эфиру",disabled:"Отключено",playback_not_supported:"Ваш браузер не поддерживает воспроизведение этого видео. Пожалуйста, попробуйте другой браузер."},fr:{live:"en direct",back_to_live:"retour au direct",disabled:"Désactivé",playback_not_supported:"Votre navigateur ne supporte pas la lecture de cette vidéo. Merci de tenter sur un autre navigateur.",default_error_title:"Impossible de lire la vidéo.",default_error_message:"Un problème est survenu lors du chargement de la vidéo."},tr:{live:"canlı",back_to_live:"canlı yayına dön",disabled:"Engelli",playback_not_supported:"Tarayıcınız bu videoyu oynatma desteğine sahip değil. Lütfen farklı bir tarayıcı ile deneyin."},et:{live:"Otseülekanne",back_to_live:"Tagasi otseülekande juurde",disabled:"Keelatud",playback_not_supported:"Teie brauser ei toeta selle video taasesitust. Proovige kasutada muud brauserit."},ar:{live:"مباشر",back_to_live:"الرجوع إلى المباشر",disabled:"معطّل",playback_not_supported:"المتصفح الذي تستخدمه لا يدعم تشغيل هذا الفيديو. الرجاء إستخدام متصفح آخر.",default_error_title:"غير قادر الى التشغيل.",default_error_message:"حدثت مشكلة أثناء تحميل الفيديو."}},this.core.options.strings||{}),this._messages["de-DE"]=this._messages.de,this._messages["pt-BR"]=this._messages.pt,this._messages["en-US"]=this._messages.en,this._messages["es-419"]=this._messages.es,this._messages["fr-FR"]=this._messages.fr,this._messages["tr-TR"]=this._messages.tr,this._messages["et-EE"]=this._messages.et,this._messages["ar-IQ"]=this._messages.ar}}]),r}($e),ot=function(e){y(r,e);var t=k(r);function r(){return f(this,r),t.apply(this,arguments)}return p(r,[{key:"bindEvents",value:function(){this.listenTo(this.core,Ae.CORE_CONTAINERS_CREATED,this.onContainersCreated)}},{key:"onContainersCreated",value:function(){var e=this.core.containers.filter((function(e){return"no_op"!==e.playback.name}))[0]||this.core.containers[0];e&&this.core.containers.forEach((function(t){t!==e&&t.destroy()}))}},{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}}]),r}($e);We.registerPlugin(st),We.registerPlugin(ot),We.registerPlayback(at),We.registerPlayback(nt),We.registerPlayback(it),We.registerPlayback(rt);"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function lt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ut,ct,dt={exports:{}};ut=dt,"undefined"!=typeof window&&(ct=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
1
|
+
var HlsjsPlayback=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function n(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function o(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=a(e);if(t){var n=a(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return o(this,r)}}function u(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=u(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},c.apply(this,arguments)}function d(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function f(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach((function(t){E(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function A(e,t,r){return t&&y(e.prototype,t),r&&y(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function T(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}function L(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=b(e);if(t){var n=b(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return k(this,r)}}function D(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=b(e)););return e}function R(){return R="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=D(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},R.apply(this,arguments)}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,n,a=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(i=r.next()).done)&&(a.push(i.value),!t||a.length!==t);s=!0);}catch(e){o=!0,n=e}finally{try{s||null==r.return||r.return()}finally{if(o)throw n}}return a}(e,t)||O(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(e){return function(e){if(Array.isArray(e))return w(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function P(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=O(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return a;n++}}}),Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=[t[r],e[t[r]]];return i}),Object.values||(Object.values=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=e[t[r]];return i}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},writable:!0,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return n;n++}return-1},configurable:!0,writable:!0});var x,N={mp4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE="},F=function(){var e,t,r,i,n,a,s=[],o=s.concat,l=s.filter,u=s.slice,c=window.document,d={},h={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/^(?:body|html)$/i,y=/([A-Z])/g,A=["val","css","html","text","data","width","height","offset"],E=c.createElement("table"),T=c.createElement("tr"),b={tr:c.createElement("tbody"),tbody:E,thead:E,tfoot:E,td:T,th:T,"*":c.createElement("div")},S=/complete|loaded|interactive/,_=/^[\w-]*$/,k={},L=k.toString,D={},R=c.createElement("div"),C={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},I=Array.isArray||function(e){return e instanceof Array};function O(e){return null==e?String(e):k[L.call(e)]||"object"}function w(e){return"function"==O(e)}function P(e){return null!=e&&e==e.window}function x(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function N(e){return"object"==O(e)}function F(e){return N(e)&&!P(e)&&Object.getPrototypeOf(e)==Object.prototype}function M(e){var t=!!e&&"length"in e&&e.length,i=r.type(e);return"function"!=i&&!P(e)&&("array"==i||0===t||"number"==typeof t&&t>0&&t-1 in e)}function U(e){return e.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function B(e){return e in h?h[e]:h[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function G(e,t){return"number"!=typeof t||f[U(e)]?t:t+"px"}function j(e){return"children"in e?u.call(e.children):r.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function K(e,t){var r,i=e?e.length:0;for(r=0;r<i;r++)this[r]=e[r];this.length=i,this.selector=t||""}function H(r,i,n){for(t in i)n&&(F(i[t])||I(i[t]))?(F(i[t])&&!F(r[t])&&(r[t]={}),I(i[t])&&!I(r[t])&&(r[t]=[]),H(r[t],i[t],n)):i[t]!==e&&(r[t]=i[t])}function V(e,t){return null==t?r(e):r(e).filter(t)}function Y(e,t,r,i){return w(t)?t.call(e,r,i):t}function W(e,t,r){null==r?e.removeAttribute(t):e.setAttribute(t,r)}function z(t,r){var i=t.className||"",n=i&&i.baseVal!==e;if(r===e)return n?i.baseVal:i;n?i.baseVal=r:t.className=r}function q(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?r.parseJSON(e):e):e}catch(t){return e}}function X(e,t){t(e);for(var r=0,i=e.childNodes.length;r<i;r++)X(e.childNodes[r],t)}return D.matches=function(e,t){if(!t||!e||1!==e.nodeType)return!1;var r=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.matchesSelector;if(r)return r.call(e,t);var i,n=e.parentNode,a=!n;return a&&(n=R).appendChild(e),i=~D.qsa(n,t).indexOf(e),a&&R.removeChild(e),i},n=function(e){return e.replace(/-+(.)?/g,(function(e,t){return t?t.toUpperCase():""}))},a=function(e){return l.call(e,(function(t,r){return e.indexOf(t)==r}))},D.fragment=function(t,i,n){var a,s,o;return p.test(t)&&(a=r(c.createElement(RegExp.$1))),a||(t.replace&&(t=t.replace(v,"<$1></$2>")),i===e&&(i=g.test(t)&&RegExp.$1),i in b||(i="*"),(o=b[i]).innerHTML=""+t,a=r.each(u.call(o.childNodes),(function(){o.removeChild(this)}))),F(n)&&(s=r(a),r.each(n,(function(e,t){A.indexOf(e)>-1?s[e](t):s.attr(e,t)}))),a},D.Z=function(e,t){return new K(e,t)},D.isZ=function(e){return e instanceof D.Z},D.init=function(t,i){var n,a;if(!t)return D.Z();if("string"==typeof t)if("<"==(t=t.trim())[0]&&g.test(t))n=D.fragment(t,RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=D.qsa(c,t)}else{if(w(t))return r(c).ready(t);if(D.isZ(t))return t;if(I(t))a=t,n=l.call(a,(function(e){return null!=e}));else if(N(t))n=[t],t=null;else if(g.test(t))n=D.fragment(t.trim(),RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=D.qsa(c,t)}}return D.Z(n,t)},(r=function(e,t){return D.init(e,t)}).extend=function(e){var t,r=u.call(arguments,1);return"boolean"==typeof e&&(t=e,e=r.shift()),r.forEach((function(r){H(e,r,t)})),e},D.qsa=function(e,t){var r,i="#"==t[0],n=!i&&"."==t[0],a=i||n?t.slice(1):t,s=_.test(a);return e.getElementById&&s&&i?(r=e.getElementById(a))?[r]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:u.call(s&&!i&&e.getElementsByClassName?n?e.getElementsByClassName(a):e.getElementsByTagName(t):e.querySelectorAll(t))},r.contains=c.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},r.type=O,r.isFunction=w,r.isWindow=P,r.isArray=I,r.isPlainObject=F,r.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},r.isNumeric=function(e){var t=Number(e),r=typeof e;return null!=e&&"boolean"!=r&&("string"!=r||e.length)&&!isNaN(t)&&isFinite(t)||!1},r.inArray=function(e,t,r){return s.indexOf.call(t,e,r)},r.camelCase=n,r.trim=function(e){return null==e?"":String.prototype.trim.call(e)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(e,t){var i,n,a,s,o=[];if(M(e))for(n=0;n<e.length;n++)null!=(i=t(e[n],n))&&o.push(i);else for(a in e)null!=(i=t(e[a],a))&&o.push(i);return(s=o).length>0?r.fn.concat.apply([],s):s},r.each=function(e,t){var r,i;if(M(e)){for(r=0;r<e.length;r++)if(!1===t.call(e[r],r,e[r]))return e}else for(i in e)if(!1===t.call(e[i],i,e[i]))return e;return e},r.grep=function(e,t){return l.call(e,t)},window.JSON&&(r.parseJSON=JSON.parse),r.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),(function(e,t){k["[object "+t+"]"]=t.toLowerCase()})),r.fn={constructor:D.Z,length:0,forEach:s.forEach,reduce:s.reduce,push:s.push,sort:s.sort,splice:s.splice,indexOf:s.indexOf,concat:function(){var e,t,r=[];for(e=0;e<arguments.length;e++)t=arguments[e],r[e]=D.isZ(t)?t.toArray():t;return o.apply(D.isZ(this)?this.toArray():this,r)},map:function(e){return r(r.map(this,(function(t,r){return e.call(t,r,t)})))},slice:function(){return r(u.apply(this,arguments))},ready:function(e){return S.test(c.readyState)&&c.body?e(r):c.addEventListener("DOMContentLoaded",(function(){e(r)}),!1),this},get:function(t){return t===e?u.call(this):this[t>=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(e){return s.every.call(this,(function(t,r){return!1!==e.call(t,r,t)})),this},filter:function(e){return w(e)?this.not(this.not(e)):r(l.call(this,(function(t){return D.matches(t,e)})))},add:function(e,t){return r(a(this.concat(r(e,t))))},is:function(e){return this.length>0&&D.matches(this[0],e)},not:function(t){var i=[];if(w(t)&&t.call!==e)this.each((function(e){t.call(this,e)||i.push(this)}));else{var n="string"==typeof t?this.filter(t):M(t)&&w(t.item)?u.call(t):r(t);this.forEach((function(e){n.indexOf(e)<0&&i.push(e)}))}return r(i)},has:function(e){return this.filter((function(){return N(e)?r.contains(this,e):r(this).find(e).size()}))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!N(e)?e:r(e)},last:function(){var e=this[this.length-1];return e&&!N(e)?e:r(e)},find:function(e){var t=this;return e?"object"==typeof e?r(e).filter((function(){var e=this;return s.some.call(t,(function(t){return r.contains(t,e)}))})):1==this.length?r(D.qsa(this[0],e)):this.map((function(){return D.qsa(this,e)})):r()},closest:function(e,t){var i=[],n="object"==typeof e&&r(e);return this.each((function(r,a){for(;a&&!(n?n.indexOf(a)>=0:D.matches(a,e));)a=a!==t&&!x(a)&&a.parentNode;a&&i.indexOf(a)<0&&i.push(a)})),r(i)},parents:function(e){for(var t=[],i=this;i.length>0;)i=r.map(i,(function(e){if((e=e.parentNode)&&!x(e)&&t.indexOf(e)<0)return t.push(e),e}));return V(t,e)},parent:function(e){return V(a(this.pluck("parentNode")),e)},children:function(e){return V(this.map((function(){return j(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||u.call(this.childNodes)}))},siblings:function(e){return V(this.map((function(e,t){return l.call(j(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return r.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){var e,t,r;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(e=this.nodeName,d[e]||(t=c.createElement(e),c.body.appendChild(t),r=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==r&&(r="block"),d[e]=r),d[e]))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=w(e);if(this[0]&&!t)var i=r(e).get(0),n=i.parentNode||this.length>1;return this.each((function(a){r(this).wrapAll(t?e.call(this,a):n?i.cloneNode(!0):i)}))},wrapAll:function(e){if(this[0]){var t;for(r(this[0]).before(e=r(e));(t=e.children()).length;)e=t.first();r(e).append(this)}return this},wrapInner:function(e){var t=w(e);return this.each((function(i){var n=r(this),a=n.contents(),s=t?e.call(this,i):e;a.length?a.wrapAll(s):n.append(s)}))},unwrap:function(){return this.parent().each((function(){r(this).replaceWith(r(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(t){return this.each((function(){var i=r(this);(t===e?"none"==i.css("display"):t)?i.show():i.hide()}))},prev:function(e){return r(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return r(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(t){var i=this.innerHTML;r(this).empty().append(Y(this,e,t,i))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var r=Y(this,e,t,this.textContent);this.textContent=null==r?"":""+r})):0 in this?this.pluck("textContent").join(""):null},attr:function(r,i){var n;return"string"!=typeof r||1 in arguments?this.each((function(e){if(1===this.nodeType)if(N(r))for(t in r)W(this,t,r[t]);else W(this,r,Y(this,i,e,this.getAttribute(r)))})):0 in this&&1==this[0].nodeType&&null!=(n=this[0].getAttribute(r))?n:e},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){W(this,e)}),this)}))},prop:function(e,t){return e=C[e]||e,1 in arguments?this.each((function(r){this[e]=Y(this,t,r,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=C[e]||e,this.each((function(){delete this[e]}))},data:function(t,r){var i="data-"+t.replace(y,"-$1").toLowerCase(),n=1 in arguments?this.attr(i,r):this.attr(i);return null!==n?q(n):e},val:function(e){return 0 in arguments?(null==e&&(e=""),this.each((function(t){this.value=Y(this,e,t,this.value)}))):this[0]&&(this[0].multiple?r(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each((function(t){var i=r(this),n=Y(this,e,t,i.offset()),a=i.offsetParent().offset(),s={top:n.top-a.top,left:n.left-a.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)}));if(!this.length)return null;if(c.documentElement!==this[0]&&!r.contains(c.documentElement,this[0]))return{top:0,left:0};var t=this[0].getBoundingClientRect();return{left:t.left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}},css:function(e,i){if(arguments.length<2){var a=this[0];if("string"==typeof e){if(!a)return;return a.style[n(e)]||getComputedStyle(a,"").getPropertyValue(e)}if(I(e)){if(!a)return;var s={},o=getComputedStyle(a,"");return r.each(e,(function(e,t){s[t]=a.style[n(t)]||o.getPropertyValue(t)})),s}}var l="";if("string"==O(e))i||0===i?l=U(e)+":"+G(e,i):this.each((function(){this.style.removeProperty(U(e))}));else for(t in e)e[t]||0===e[t]?l+=U(t)+":"+G(t,e[t])+";":this.each((function(){this.style.removeProperty(U(t))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(e){return e?this.indexOf(r(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&s.some.call(this,(function(e){return this.test(z(e))}),B(e))},addClass:function(e){return e?this.each((function(t){if("className"in this){i=[];var n=z(this);Y(this,e,t,n).split(/\s+/g).forEach((function(e){r(this).hasClass(e)||i.push(e)}),this),i.length&&z(this,n+(n?" ":"")+i.join(" "))}})):this},removeClass:function(t){return this.each((function(r){if("className"in this){if(t===e)return z(this,"");i=z(this),Y(this,t,r,i).split(/\s+/g).forEach((function(e){i=i.replace(B(e)," ")})),z(this,i.trim())}}))},toggleClass:function(t,i){return t?this.each((function(n){var a=r(this);Y(this,t,n,z(this)).split(/\s+/g).forEach((function(t){(i===e?!a.hasClass(t):i)?a.addClass(t):a.removeClass(t)}))})):this},scrollTop:function(t){if(this.length){var r="scrollTop"in this[0];return t===e?r?this[0].scrollTop:this[0].pageYOffset:this.each(r?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var r="scrollLeft"in this[0];return t===e?r?this[0].scrollLeft:this[0].pageXOffset:this.each(r?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),i=this.offset(),n=m.test(t[0].nodeName)?{top:0,left:0}:t.offset();return i.top-=parseFloat(r(e).css("margin-top"))||0,i.left-=parseFloat(r(e).css("margin-left"))||0,n.top+=parseFloat(r(t[0]).css("border-top-width"))||0,n.left+=parseFloat(r(t[0]).css("border-left-width"))||0,{top:i.top-n.top,left:i.left-n.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||c.body;e&&!m.test(e.nodeName)&&"static"==r(e).css("position");)e=e.offsetParent;return e}))}},r.fn.detach=r.fn.remove,["width","height"].forEach((function(t){var i=t.replace(/./,(function(e){return e[0].toUpperCase()}));r.fn[t]=function(n){var a,s=this[0];return n===e?P(s)?s["inner"+i]:x(s)?s.documentElement["scroll"+i]:(a=this.offset())&&a[t]:this.each((function(e){(s=r(this)).css(t,Y(this,n,e,s[t]()))}))}})),["after","prepend","before","append"].forEach((function(t,i){var n=i%2;r.fn[t]=function(){var t,a,s=r.map(arguments,(function(i){var n=[];return"array"==(t=O(i))?(i.forEach((function(t){return t.nodeType!==e?n.push(t):r.zepto.isZ(t)?n=n.concat(t.get()):void(n=n.concat(D.fragment(t)))})),n):"object"==t||null==i?i:D.fragment(i)})),o=this.length>1;return s.length<1?this:this.each((function(e,t){a=n?t:t.parentNode,t=0==i?t.nextSibling:1==i?t.firstChild:2==i?t:null;var l=r.contains(c.documentElement,a);s.forEach((function(e){if(o)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,t),l&&X(e,(function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var t=e.ownerDocument?e.ownerDocument.defaultView:window;t.eval.call(t,e.innerHTML)}}))}))}))},r.fn[n?t+"To":"insert"+(i?"Before":"After")]=function(e){return r(e)[t](this),this}})),D.Z.prototype=K.prototype=r.fn,D.uniq=a,D.deserializeValue=q,r.zepto=D,r}();window.Zepto=F,void 0===window.$&&(window.$=F),function(e){var t,r,i=+new Date,n=window.document,a=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,o=/^(?:text|application)\/xml/i,l="application/json",u="text/html",c=/^\s*$/,d=n.createElement("a");function h(t,r,i,a){if(t.global)return function(t,r,i){var n=e.Event(r);return e(t).trigger(n,i),!n.isDefaultPrevented()}(r||n,i,a)}function f(e,t){var r=t.context;if(!1===t.beforeSend.call(r,e,t)||!1===h(t,r,"ajaxBeforeSend",[e,t]))return!1;h(t,r,"ajaxSend",[e,t])}function g(e,t,r,i){var n=r.context,a="success";r.success.call(n,e,a,t),i&&i.resolveWith(n,[e,a,t]),h(r,n,"ajaxSuccess",[t,r,e]),v(a,t,r)}function p(e,t,r,i,n){var a=i.context;i.error.call(a,r,t,e),n&&n.rejectWith(a,[r,t,e]),h(i,a,"ajaxError",[r,i,e||t]),v(t,r,i)}function v(t,r,i){var n=i.context;i.complete.call(n,r,t),h(i,n,"ajaxComplete",[r,i]),function(t){t.global&&!--e.active&&h(t,null,"ajaxStop")}(i)}function m(){}function y(e,t){return""==t?e:(e+"&"+t).replace(/[&?]{1,2}/,"?")}function A(t,r,i,n){return e.isFunction(r)&&(n=i,i=r,r=void 0),e.isFunction(i)||(n=i,i=void 0),{url:t,data:r,success:i,dataType:n}}d.href=window.location.href,e.active=0,e.ajaxJSONP=function(t,r){if(!("type"in t))return e.ajax(t);var a,s,o=t.jsonpCallback,l=(e.isFunction(o)?o():o)||"Zepto"+i++,u=n.createElement("script"),c=window[l],d=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:d};return r&&r.promise(h),e(u).on("load error",(function(i,n){clearTimeout(s),e(u).off().remove(),"error"!=i.type&&a?g(a[0],h,t,r):p(null,n||"error",h,t,r),window[l]=c,a&&e.isFunction(c)&&c(a[0]),c=a=void 0})),!1===f(h,t)?(d("abort"),h):(window[l]=function(){a=arguments},u.src=t.url.replace(/\?(.+)=\?/,"?$1="+l),n.head.appendChild(u),t.timeout>0&&(s=setTimeout((function(){d("timeout")}),t.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:m,success:m,error:m,complete:m,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:u,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:m},e.ajax=function(i){var a,v,A=e.extend({},i||{}),E=e.Deferred&&e.Deferred();for(t in e.ajaxSettings)void 0===A[t]&&(A[t]=e.ajaxSettings[t]);!function(t){t.global&&0==e.active++&&h(t,null,"ajaxStart")}(A),A.crossDomain||((a=n.createElement("a")).href=A.url,a.href=a.href,A.crossDomain=d.protocol+"//"+d.host!=a.protocol+"//"+a.host),A.url||(A.url=window.location.toString()),(v=A.url.indexOf("#"))>-1&&(A.url=A.url.slice(0,v)),function(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=y(t.url,t.data),t.data=void 0)}(A);var T=A.dataType,b=/\?.+=\?/.test(A.url);if(b&&(T="jsonp"),!1!==A.cache&&(i&&!0===i.cache||"script"!=T&&"jsonp"!=T)||(A.url=y(A.url,"_="+Date.now())),"jsonp"==T)return b||(A.url=y(A.url,A.jsonp?A.jsonp+"=?":!1===A.jsonp?"":"callback=?")),e.ajaxJSONP(A,E);var S,_=A.accepts[T],k={},L=function(e,t){k[e.toLowerCase()]=[e,t]},D=/^([\w-]+:)\/\//.test(A.url)?RegExp.$1:window.location.protocol,R=A.xhr(),C=R.setRequestHeader;if(E&&E.promise(R),A.crossDomain||L("X-Requested-With","XMLHttpRequest"),L("Accept",_||"*/*"),(_=A.mimeType||_)&&(_.indexOf(",")>-1&&(_=_.split(",",2)[0]),R.overrideMimeType&&R.overrideMimeType(_)),(A.contentType||!1!==A.contentType&&A.data&&"GET"!=A.type.toUpperCase())&&L("Content-Type",A.contentType||"application/x-www-form-urlencoded"),A.headers)for(r in A.headers)L(r,A.headers[r]);if(R.setRequestHeader=L,R.onreadystatechange=function(){if(4==R.readyState){R.onreadystatechange=m,clearTimeout(S);var t,r=!1;if(R.status>=200&&R.status<300||304==R.status||0==R.status&&"file:"==D){if(T=T||function(e){return e&&(e=e.split(";",2)[0]),e&&(e==u?"html":e==l?"json":s.test(e)?"script":o.test(e)&&"xml")||"text"}(A.mimeType||R.getResponseHeader("content-type")),"arraybuffer"==R.responseType||"blob"==R.responseType)t=R.response;else{t=R.responseText;try{t=function(e,t,r){if(r.dataFilter==m)return e;var i=r.context;return r.dataFilter.call(i,e,t)}(t,T,A),"script"==T?(0,eval)(t):"xml"==T?t=R.responseXML:"json"==T&&(t=c.test(t)?null:e.parseJSON(t))}catch(e){r=e}if(r)return p(r,"parsererror",R,A,E)}g(t,R,A,E)}else p(R.statusText||null,R.status?"error":"abort",R,A,E)}},!1===f(R,A))return R.abort(),p(null,"abort",R,A,E),R;var I=!("async"in A)||A.async;if(R.open(A.type,A.url,I,A.username,A.password),A.xhrFields)for(r in A.xhrFields)R[r]=A.xhrFields[r];for(r in k)C.apply(R,k[r]);return A.timeout>0&&(S=setTimeout((function(){R.onreadystatechange=m,R.abort(),p(null,"timeout",R,A,E)}),A.timeout)),R.send(A.data?A.data:null),R},e.get=function(){return e.ajax(A.apply(null,arguments))},e.post=function(){var t=A.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=A.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,r,i){if(!this.length)return this;var n,s=this,o=t.split(/\s/),l=A(t,r,i),u=l.success;return o.length>1&&(l.url=o[0],n=o[1]),l.success=function(t){s.html(n?e("<div>").html(t.replace(a,"")).find(n):t),u&&u.apply(s,arguments)},e.ajax(l),this};var E=encodeURIComponent;function T(t,r,i,n){var a,s=e.isArray(r),o=e.isPlainObject(r);e.each(r,(function(r,l){a=e.type(l),n&&(r=i?n:n+"["+(o||"object"==a||"array"==a?r:"")+"]"),!n&&s?t.add(l.name,l.value):"array"==a||!i&&"object"==a?T(t,l,i,r):t.add(r,l)}))}e.param=function(t,r){var i=[];return i.add=function(t,r){e.isFunction(r)&&(r=r()),null==r&&(r=""),this.push(E(t)+"="+E(r))},T(i,t,r),i.join("&").replace(/%20/g,"+")}}(F),(x=F).Callbacks=function(e){e=x.extend({},e);var t,r,i,n,a,s,o=[],l=!e.once&&[],u=function(d){for(t=e.memory&&d,r=!0,s=n||0,n=0,a=o.length,i=!0;o&&s<a;++s)if(!1===o[s].apply(d[0],d[1])&&e.stopOnFalse){t=!1;break}i=!1,o&&(l?l.length&&u(l.shift()):t?o.length=0:c.disable())},c={add:function(){if(o){var r=o.length,s=function(t){x.each(t,(function(t,r){"function"==typeof r?e.unique&&c.has(r)||o.push(r):r&&r.length&&"string"!=typeof r&&s(r)}))};s(arguments),i?a=o.length:t&&(n=r,u(t))}return this},remove:function(){return o&&x.each(arguments,(function(e,t){for(var r;(r=x.inArray(t,o,r))>-1;)o.splice(r,1),i&&(r<=a&&--a,r<=s&&--s)})),this},has:function(e){return!(!o||!(e?x.inArray(e,o)>-1:o.length))},empty:function(){return a=o.length=0,this},disable:function(){return o=l=t=void 0,this},disabled:function(){return!o},lock:function(){return l=void 0,t||c.disable(),this},locked:function(){return!l},fireWith:function(e,t){return!o||r&&!l||(t=[e,(t=t||[]).slice?t.slice():t],i?l.push(t):u(t)),this},fire:function(){return c.fireWith(this,arguments)},fired:function(){return!!r}};return c},function(e){var t=Array.prototype.slice;function r(t){var i=[["resolve","done",e.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",e.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",e.Callbacks({memory:1})]],n="pending",a={state:function(){return n},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var t=arguments;return r((function(r){e.each(i,(function(i,n){var o=e.isFunction(t[i])&&t[i];s[n[1]]((function(){var t=o&&o.apply(this,arguments);if(t&&e.isFunction(t.promise))t.promise().done(r.resolve).fail(r.reject).progress(r.notify);else{var i=this===a?r.promise():this,s=o?[t]:arguments;r[n[0]+"With"](i,s)}}))})),t=null})).promise()},promise:function(t){return null!=t?e.extend(t,a):a}},s={};return e.each(i,(function(e,t){var r=t[2],o=t[3];a[t[1]]=r.add,o&&r.add((function(){n=o}),i[1^e][2].disable,i[2][2].lock),s[t[0]]=function(){return s[t[0]+"With"](this===s?a:this,arguments),this},s[t[0]+"With"]=r.fireWith})),a.promise(s),t&&t.call(s,s),s}e.when=function(i){var n,a,s,o=t.call(arguments),l=o.length,u=0,c=1!==l||i&&e.isFunction(i.promise)?l:0,d=1===c?i:r(),h=function(e,r,i){return function(a){r[e]=this,i[e]=arguments.length>1?t.call(arguments):a,i===n?d.notifyWith(r,i):--c||d.resolveWith(r,i)}};if(l>1)for(n=new Array(l),a=new Array(l),s=new Array(l);u<l;++u)o[u]&&e.isFunction(o[u].promise)?o[u].promise().done(h(u,s,o)).fail(d.reject).progress(h(u,a,n)):--c;return c||d.resolveWith(s,o),d.promise()},e.Deferred=r}(F),function(e){var t,r=1,i=Array.prototype.slice,n=e.isFunction,a=function(e){return"string"==typeof e},s={},o={},l="onfocusin"in window,u={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};function d(e){return e._zid||(e._zid=r++)}function h(e,t,r,i){if((t=f(t)).ns)var n=(a=t.ns,new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)"));var a;return(s[d(e)]||[]).filter((function(e){return e&&(!t.e||e.e==t.e)&&(!t.ns||n.test(e.ns))&&(!r||d(e.fn)===d(r))&&(!i||e.sel==i)}))}function f(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function g(e,t){return e.del&&!l&&e.e in u||!!t}function p(e){return c[e]||l&&u[e]||e}function v(r,i,n,a,o,l,u){var h=d(r),v=s[h]||(s[h]=[]);i.split(/\s/).forEach((function(i){if("ready"==i)return e(document).ready(n);var s=f(i);s.fn=n,s.sel=o,s.e in c&&(n=function(t){var r=t.relatedTarget;if(!r||r!==this&&!e.contains(this,r))return s.fn.apply(this,arguments)}),s.del=l;var d=l||n;s.proxy=function(e){if(!(e=b(e)).isImmediatePropagationStopped()){e.data=a;var i=d.apply(r,e._args==t?[e]:[e].concat(e._args));return!1===i&&(e.preventDefault(),e.stopPropagation()),i}},s.i=v.length,v.push(s),"addEventListener"in r&&r.addEventListener(p(s.e),s.proxy,g(s,u))}))}function m(e,t,r,i,n){var a=d(e);(t||"").split(/\s/).forEach((function(t){h(e,t,r,i).forEach((function(t){delete s[a][t.i],"removeEventListener"in e&&e.removeEventListener(p(t.e),t.proxy,g(t,n))}))}))}o.click=o.mousedown=o.mouseup=o.mousemove="MouseEvents",e.event={add:v,remove:m},e.proxy=function(t,r){var s=2 in arguments&&i.call(arguments,2);if(n(t)){var o=function(){return t.apply(r,s?s.concat(i.call(arguments)):arguments)};return o._zid=d(t),o}if(a(r))return s?(s.unshift(t[r],t),e.proxy.apply(null,s)):e.proxy(t[r],t);throw new TypeError("expected function")},e.fn.bind=function(e,t,r){return this.on(e,t,r)},e.fn.unbind=function(e,t){return this.off(e,t)},e.fn.one=function(e,t,r,i){return this.on(e,t,r,i,1)};var y=function(){return!0},A=function(){return!1},E=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,T={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function b(r,i){return!i&&r.isDefaultPrevented||(i||(i=r),e.each(T,(function(e,t){var n=i[e];r[e]=function(){return this[t]=y,n&&n.apply(i,arguments)},r[t]=A})),r.timeStamp||(r.timeStamp=Date.now()),(i.defaultPrevented!==t?i.defaultPrevented:"returnValue"in i?!1===i.returnValue:i.getPreventDefault&&i.getPreventDefault())&&(r.isDefaultPrevented=y)),r}function S(e){var r,i={originalEvent:e};for(r in e)E.test(r)||e[r]===t||(i[r]=e[r]);return b(i,e)}e.fn.delegate=function(e,t,r){return this.on(t,e,r)},e.fn.undelegate=function(e,t,r){return this.off(t,e,r)},e.fn.live=function(t,r){return e(document.body).delegate(this.selector,t,r),this},e.fn.die=function(t,r){return e(document.body).undelegate(this.selector,t,r),this},e.fn.on=function(r,s,o,l,u){var c,d,h=this;return r&&!a(r)?(e.each(r,(function(e,t){h.on(e,s,o,t,u)})),h):(a(s)||n(l)||!1===l||(l=o,o=s,s=t),l!==t&&!1!==o||(l=o,o=t),!1===l&&(l=A),h.each((function(t,n){u&&(c=function(e){return m(n,e.type,l),l.apply(this,arguments)}),s&&(d=function(t){var r,a=e(t.target).closest(s,n).get(0);if(a&&a!==n)return r=e.extend(S(t),{currentTarget:a,liveFired:n}),(c||l).apply(a,[r].concat(i.call(arguments,1)))}),v(n,r,l,o,s,d||c)})))},e.fn.off=function(r,i,s){var o=this;return r&&!a(r)?(e.each(r,(function(e,t){o.off(e,i,t)})),o):(a(i)||n(s)||!1===s||(s=i,i=t),!1===s&&(s=A),o.each((function(){m(this,r,s,i)})))},e.fn.trigger=function(t,r){return(t=a(t)||e.isPlainObject(t)?e.Event(t):b(t))._args=r,this.each((function(){t.type in u&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,r)}))},e.fn.triggerHandler=function(t,r){var i,n;return this.each((function(s,o){(i=S(a(t)?e.Event(t):t))._args=r,i.target=o,e.each(h(o,t.type||t),(function(e,t){if(n=t.proxy(i),i.isImmediatePropagationStopped())return!1}))})),n},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}})),e.Event=function(e,t){a(e)||(e=(t=e).type);var r=document.createEvent(o[e]||"Events"),i=!0;if(t)for(var n in t)"bubbles"==n?i=!!t[n]:r[n]=t[n];return r.initEvent(e,i,!0),b(r)}}(F),function(){try{getComputedStyle(void 0)}catch(t){var e=getComputedStyle;window.getComputedStyle=function(t,r){try{return e(t,r)}catch(e){return null}}}}(),function(e){var t=e.zepto,r=t.qsa,i=t.matches;function n(t){return!(!(t=e(t)).width()&&!t.height())&&"none"!==t.css("display")}var a=e.expr[":"]={visible:function(){if(n(this))return this},hidden:function(){if(!n(this))return this},selected:function(){if(this.selected)return this},checked:function(){if(this.checked)return this},parent:function(){return this.parentNode},first:function(e){if(0===e)return this},last:function(e,t){if(e===t.length-1)return this},eq:function(e,t,r){if(e===r)return this},contains:function(t,r,i){if(e(this).text().indexOf(i)>-1)return this},has:function(e,r,i){if(t.qsa(this,i).length)return this}},s=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),o=/^\s*>/,l="Zepto"+ +new Date;function u(e,t){e=e.replace(/=#\]/g,'="#"]');var r,i,n=s.exec(e);if(n&&n[2]in a&&(r=a[n[2]],i=n[3],e=n[1],i)){var o=Number(i);i=isNaN(o)?i.replace(/^["']|["']$/g,""):o}return t(e,r,i)}t.qsa=function(i,n){return u(n,(function(a,s,u){try{var c;!a&&s?a="*":o.test(a)&&(c=e(i).addClass(l),a="."+l+" "+a);var d=r(i,a)}catch(e){throw console.error("error performing selector: %o",n),e}finally{c&&c.removeClass(l)}return s?t.uniq(e.map(d,(function(e,t){return s.call(e,t,d,u)}))):d}))},t.matches=function(e,t){return u(t,(function(t,r,n){return(!t||i(e,t))&&(!r||r.call(e,null,n)===e)}))}}(F);var M,U,B,G=F,j=[{name:"Chromium",group:"Chrome",identifier:"Chromium/([0-9.]*)"},{name:"Chrome Mobile",group:"Chrome",identifier:"Chrome/([0-9.]*) Mobile",versionIdentifier:"Chrome/([0-9.]*)"},{name:"Chrome",group:"Chrome",identifier:"Chrome/([0-9.]*)"},{name:"Chrome for iOS",group:"Chrome",identifier:"CriOS/([0-9.]*)"},{name:"Android Browser",group:"Chrome",identifier:"CrMo/([0-9.]*)"},{name:"Firefox",group:"Firefox",identifier:"Firefox/([0-9.]*)"},{name:"Opera Mini",group:"Opera",identifier:"Opera Mini/([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera ([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"},{name:"IEMobile",group:"Explorer",identifier:"IEMobile/([0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"MSIE ([a-zA-Z0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"Trident/([0-9.]*)",versionIdentifier:"rv:([0-9.]*)"},{name:"Spartan",group:"Spartan",identifier:"Edge/([0-9.]*)",versionIdentifier:"Edge/([0-9.]*)"},{name:"Safari",group:"Safari",identifier:"Safari/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"}],K=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X High Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])13([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])12([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],H={},V=function(e,t){var r=e.split(".",2);t.fullVersion=e,r[0]&&(t.majorVersion=parseInt(r[0])),r[1]&&(t.minorVersion=parseInt(r[1]))},Y=function(e,t,r){var i="["==t.substr(0,1)?new RegExp(t,"g"):t,n=e.split(i,2);"."!=t&&(e=e.replace(new RegExp(t,"g"),".")),r.fullVersion=e,n&&n[0]&&(r.majorVersion=parseInt(n[0])),n&&n[1]&&(r.minorVersion=parseInt(n[1]))},W=function(e){var t,r=e.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(r[1]))return t=/\brv[ :]+(\d+)/g.exec(e)||[],{name:"IE",version:parseInt(t[1]||"")};if("Chrome"===r[1]){if(null!=(t=e.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:parseInt(t[1])};if(null!=(t=e.match(/\bEdge\/(\d+)/)))return{name:"Edge",version:parseInt(t[1])}}else/android/i.test(e)&&(t=e.match(/version\/(\d+)/i))&&(r.splice(1,1,"Android WebView"),r.splice(2,1,t[1]));return{name:(r=r[2]?[r[1],r[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(r[1])}}(navigator.userAgent);H.isEdge=/Edg|EdgiOS|EdgA/i.test(navigator.userAgent),H.isChrome=/Chrome|CriOS/i.test(navigator.userAgent)&&!H.isEdge,H.isSafari=/Safari/i.test(navigator.userAgent)&&!H.isChrome&&!H.isEdge,H.isFirefox=/Firefox/i.test(navigator.userAgent),H.isLegacyIE=!!window.ActiveXObject,H.isIE=H.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),H.isIE11=/trident.*rv:11/i.test(navigator.userAgent),H.isChromecast=H.isChrome&&/CrKey/i.test(navigator.userAgent),H.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),H.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),H.isAndroid=/Android/i.test(navigator.userAgent),H.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),H.isWin8App=/MSAppHost/i.test(navigator.userAgent),H.isWiiU=/WiiU/i.test(navigator.userAgent),H.isPS4=/PlayStation 4/i.test(navigator.userAgent),H.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(e){return!1}}(),H.hasFlash=function(){try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){return!(!navigator.mimeTypes||void 0===navigator.mimeTypes["application/x-shockwave-flash"]||!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)}}(),H.name=W.name,H.version=W.version,H.userAgent=navigator.userAgent,H.data=function(){var e,t={},r=H.userAgent.toLowerCase(),i=P(j);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a&&a[1]){if(t.name=n.name,t.group=n.group,n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&V(s[1],t)}else V(a[1],t);break}}}catch(e){i.e(e)}finally{i.f()}return t}(),H.os=function(){var e,t={},r=H.userAgent.toLowerCase(),i=P(K);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a){if(t.name=n.name,t.group=n.group,n.version)Y(n.version,n.versionSeparator?n.versionSeparator:".",t);else if(a[1])Y(a[1],n.versionSeparator?n.versionSeparator:".",t);else if(n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&Y(s[1],n.versionSeparator?n.versionSeparator:".",t)}break}}}catch(e){i.e(e)}finally{i.f()}return t}(),H.isWindows=/^Windows$/i.test(H.os.group),H.isMacOS=/^Mac OS$/i.test(H.os.group),H.isLinux=/^Linux$/i.test(H.os.group),H.viewport=((M={}).width=G(window).width(),M.height=G(window).height(),M),H.device=(U=H.userAgent,(B=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(U))&&(B[1]||B[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:H.viewport.orientation="landscape";break;default:H.viewport.orientation="portrait"}}();var z={},q=[],X=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}).bind(window),$=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function Z(e,t){if(t)for(var r in t){var i=Object.getOwnPropertyDescriptor(t,r);i?Object.defineProperty(e,r,i):e[r]=t[r]}return e}function Q(e,t){var r=function(e){T(i,e);var r=L(i);function i(){var e;m(this,i);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return e=r.call.apply(r,[this].concat(a)),t.initialize&&t.initialize.apply(_(e),a),e}return A(i)}(e);return Z(r.prototype,t),r}var J={fullscreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullscreen:function(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen){if("function"==typeof e.then)return e.webkitRequestFullscreen();e.webkitRequestFullscreen()}else{if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();e.querySelector&&e.querySelector("video")&&e.querySelector("video").webkitEnterFullScreen?e.querySelector("video").webkitEnterFullScreen():e.webkitEnterFullScreen&&e.webkitEnterFullScreen()}},cancelFullscreen:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;e.exitFullscreen?e.exitFullscreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.webkitExitFullscreen?e.webkitExitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.msExitFullscreen&&e.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},ee=function(){function e(){m(this,e)}return A(e,null,[{key:"params",get:function(){var e=window.location.search.substring(1);return e!==this.query&&(this._urlParams=this.parse(e),this.query=e),this._urlParams}},{key:"hashParams",get:function(){var e=window.location.hash.substring(1);return e!==this.hash&&(this._hashParams=this.parse(e),this.hash=e),this._hashParams}},{key:"parse",value:function(e){for(var t,r=/\+/g,i=/([^&=]+)=?([^&]*)/g,n=function(e){return decodeURIComponent(e.replace(r," "))},a={};t=i.exec(e);)a[n(t[1]).toLowerCase()]=n(t[2]);return a}}]),e}();function te(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",t=0,r=ee.params[e]||ee.hashParams[e]||"",i=r.match(/[0-9]+[hms]+/g)||[];if(i.length>0){var n={h:3600,m:60,s:1};i.forEach((function(e){if(e){var r=e[e.length-1],i=parseInt(e.slice(0,e.length-1),10);t+=i*n[r]}}))}else r&&(t=parseInt(r,10));return t}function re(e){return z[e]||(z[e]=0),e+ ++z[e]}function ie(e){return e-parseFloat(e)+1>=0}function ne(){var e=document.getElementsByTagName("script");return e.length?e[e.length-1].src:""}function ae(){return window.navigator&&window.navigator.language}function se(e,t){var r=(t=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:N.mp4,element:null},t)).element?t.element:document.createElement(t.type);r.muted=t.muted,!0===t.muted&&r.setAttribute("muted","muted"),!0===t.inline&&r.setAttribute("playsinline","playsinline"),r.src=t.source;var i=r.play(),n=setTimeout((function(){a(!1,new Error("Timeout ".concat(t.timeout," ms has been reached")))}),t.timeout),a=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(n),e(t,r)};void 0!==i?i.then((function(){return a(!0)})).catch((function(e){return a(!1,e)})):a(!0)}var oe=function(){function e(){m(this,e)}return A(e,null,[{key:"configure",value:function(e){this.options=G.extend(!0,this.options,e)}},{key:"create",value:function(e){return this.options.recycleVideo&&"video"===e&&q.length>0?q.shift():document.createElement(e)}},{key:"garbage",value:function(e){this.options.recycleVideo&&"VIDEO"===e.tagName.toUpperCase()&&(G(e).children().remove(),Object.values(e.attributes).forEach((function(t){return e.removeAttribute(t.name)})),q.push(e))}}]),e}();oe.options={recycleVideo:!1};var le=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;m(this,e),this.delay=t,this.lastTime=0}return A(e,[{key:"handle",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(new Date).getTime(),n=i-this.lastTime;n<this.delay&&n>0&&(t(),r&&e.preventDefault()),this.lastTime=i}}]),e}(),ue=function(){return window.performance&&window.performance.now?performance.now():Date.now()},ce=function(e,t){return void 0!==e&&void 0!==t&&void 0!==t.find((function(t){return e.toLowerCase()===t.toLowerCase()}))},de="font-weight: bold; font-size: 13px;",he="color: #ff8000;"+de,fe="color: #ff0000;"+de,ge=["color: #0000ff;"+de,"color: #006600;"+de,he,fe,fe],pe=["debug","info","warn","error","disabled"],ve=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;m(this,e),this.EXCLUDE_LIST=["timeupdate","playback:timeupdate","playback:progress","container:hover","container:timeupdate","container:progress"],this.level=t,this.previousLevel=this.level,this.offLevel=r}return A(e,[{key:"level",get:function(){return this._level},set:function(e){this._level=e}},{key:"debug",value:function(e){this.log(e,0,Array.prototype.slice.call(arguments,1))}},{key:"info",value:function(e){this.log(e,1,Array.prototype.slice.call(arguments,1))}},{key:"warn",value:function(e){this.log(e,2,Array.prototype.slice.call(arguments,1))}},{key:"error",value:function(e){this.log(e,3,Array.prototype.slice.call(arguments,1))}},{key:"onOff",value:function(){this.level===this.offLevel?this.level=this.previousLevel:(this.previousLevel=this.level,this.level=this.offLevel),window.console&&window.console.log&&window.console.log("%c[Clappr.Log] set log level to "+pe[this.level],he)}},{key:"log",value:function(e,t,r){if(!(this.EXCLUDE_LIST.indexOf(r[0])>=0||t<this.level)){r||(r=e,e=null);var i=ge[t],n="";e&&(n="["+e+"]"),window.console&&window.console.log&&window.console.log.apply(console,["%c["+pe[t]+"]"+n,i].concat(r))}}}]),e}();ve.LEVEL_DEBUG=0,ve.LEVEL_INFO=1,ve.LEVEL_WARN=2,ve.LEVEL_ERROR=3,ve.getInstance=function(){return void 0===this._instance&&(this._instance=new this),this._instance},ve.setLevel=function(e){this.getInstance().level=e},ve.debug=function(){this.getInstance().debug.apply(this.getInstance(),arguments)},ve.info=function(){this.getInstance().info.apply(this.getInstance(),arguments)},ve.warn=function(){this.getInstance().warn.apply(this.getInstance(),arguments)},ve.error=function(){this.getInstance().error.apply(this.getInstance(),arguments)};var me=Array.prototype.slice,ye=/\s+/,Ae=function(e,t,r,i){if(!r)return!0;if("object"===v(r)){for(var n in r)e[t].apply(e,[n,r[n]].concat(i));return!1}if(ye.test(r)){for(var a=r.split(ye),s=0,o=a.length;s<o;s++)e[t].apply(e,[a[s]].concat(i));return!1}return!0},Ee=function(e,t,r,i){var n,a=-1,s=e.length,o=t[0],l=t[1],u=t[2];!function c(){try{switch(t.length){case 0:for(;++a<s;)(n=e[a]).callback.call(n.ctx);return;case 1:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o);return;case 2:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l);return;case 3:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l,u);return;default:for(;++a<s;)(n=e[a]).callback.apply(n.ctx,t);return}}catch(e){ve.error.apply(ve,[r,"error on event",i,"trigger","-",e]),c()}}()},Te=function(){function e(){m(this,e)}return A(e,[{key:"on",value:function(e,t,r){return Ae(this,"on",e,[t,r])&&t?(this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t,context:r,ctx:r||this}),this):this}},{key:"once",value:function(e,t,r){var i,n=this;if(!Ae(this,"once",e,[t,r])||!t)return this;var a=function(){return n.off(e,i)};return i=function(){a(),t.apply(this,arguments)},this.on(e,i,r)}},{key:"off",value:function(e,t,r){var i,n,a,s,o,l,u,c;if(!this._events||!Ae(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;for(o=0,l=(s=e?[e]:Object.keys(this._events)).length;o<l;o++)if(e=s[o],a=this._events[e]){if(this._events[e]=i=[],t||r)for(u=0,c=a.length;u<c;u++)n=a[u],(t&&t!==n.callback&&t!==n.callback._callback||r&&r!==n.context)&&i.push(n);i.length||delete this._events[e]}return this}},{key:"trigger",value:function(e){var t=this.name||this.constructor.name;if(ve.debug.apply(ve,[t].concat(Array.prototype.slice.call(arguments))),!this._events)return this;var r=me.call(arguments,1);if(!Ae(this,"trigger",e,r))return this;var i=this._events[e],n=this._events.all;return i&&Ee(i,r,t,e),n&&Ee(n,arguments,t,e),this}},{key:"stopListening",value:function(e,t,r){var i=this._listeningTo;if(!i)return this;var n=!t&&!r;for(var a in r||"object"!==v(t)||(r=this),e&&((i={})[e._listenId]=e),i)(e=i[a]).off(t,r,this),(n||0===Object.keys(e._events).length)&&delete this._listeningTo[a];return this}}],[{key:"register",value:function(t){e.Custom||(e.Custom={});var r="string"==typeof t&&t.toUpperCase().trim();r&&!e.Custom[r]?e.Custom[r]=r.toLowerCase().split("_").map((function(e,t){return 0===t?e:e=e[0].toUpperCase()+e.slice(1)})).join(""):ve.error("Events","Error when register event: "+t)}},{key:"listAvailableCustomEvents",value:function(){return e.Custom||(e.Custom={}),Object.keys(e.Custom).filter((function(t){return"string"==typeof e.Custom[t]}))}}]),e}(),be={listenTo:"on",listenToOnce:"once"};Object.keys(be).forEach((function(e){Te.prototype[e]=function(t,r,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=re("l"))]=t,i||"object"!==v(r)||(i=this),t[be[e]](r,i,this),this}})),Te.PLAYER_READY="ready",Te.PLAYER_RESIZE="resize",Te.PLAYER_FULLSCREEN="fullscreen",Te.PLAYER_PLAY="play",Te.PLAYER_PAUSE="pause",Te.PLAYER_STOP="stop",Te.PLAYER_ENDED="ended",Te.PLAYER_SEEK="seek",Te.PLAYER_ERROR="playererror",Te.ERROR="error",Te.PLAYER_TIMEUPDATE="timeupdate",Te.PLAYER_VOLUMEUPDATE="volumeupdate",Te.PLAYER_SUBTITLE_AVAILABLE="subtitleavailable",Te.PLAYBACK_PROGRESS="playback:progress",Te.PLAYBACK_TIMEUPDATE="playback:timeupdate",Te.PLAYBACK_READY="playback:ready",Te.PLAYBACK_BUFFERING="playback:buffering",Te.PLAYBACK_BUFFERFULL="playback:bufferfull",Te.PLAYBACK_SETTINGSUPDATE="playback:settingsupdate",Te.PLAYBACK_LOADEDMETADATA="playback:loadedmetadata",Te.PLAYBACK_HIGHDEFINITIONUPDATE="playback:highdefinitionupdate",Te.PLAYBACK_BITRATE="playback:bitrate",Te.PLAYBACK_LEVELS_AVAILABLE="playback:levels:available",Te.PLAYBACK_LEVEL_SWITCH_START="playback:levels:switch:start",Te.PLAYBACK_LEVEL_SWITCH_END="playback:levels:switch:end",Te.PLAYBACK_PLAYBACKSTATE="playback:playbackstate",Te.PLAYBACK_DVR="playback:dvr",Te.PLAYBACK_MEDIACONTROL_DISABLE="playback:mediacontrol:disable",Te.PLAYBACK_MEDIACONTROL_ENABLE="playback:mediacontrol:enable",Te.PLAYBACK_ENDED="playback:ended",Te.PLAYBACK_PLAY_INTENT="playback:play:intent",Te.PLAYBACK_PLAY="playback:play",Te.PLAYBACK_PAUSE="playback:pause",Te.PLAYBACK_SEEK="playback:seek",Te.PLAYBACK_SEEKED="playback:seeked",Te.PLAYBACK_STOP="playback:stop",Te.PLAYBACK_ERROR="playback:error",Te.PLAYBACK_STATS_ADD="playback:stats:add",Te.PLAYBACK_FRAGMENT_LOADED="playback:fragment:loaded",Te.PLAYBACK_LEVEL_SWITCH="playback:level:switch",Te.PLAYBACK_SUBTITLE_AVAILABLE="playback:subtitle:available",Te.PLAYBACK_SUBTITLE_CHANGED="playback:subtitle:changed",Te.PLAYBACK_AUDIO_AVAILABLE="playback:audio:available",Te.PLAYBACK_AUDIO_CHANGED="playback:audio:changed",Te.CORE_CONTAINERS_CREATED="core:containers:created",Te.CORE_ACTIVE_CONTAINER_CHANGED="core:active:container:changed",Te.CORE_OPTIONS_CHANGE="core:options:change",Te.CORE_READY="core:ready",Te.CORE_FULLSCREEN="core:fullscreen",Te.CORE_RESIZE="core:resize",Te.CORE_SCREEN_ORIENTATION_CHANGED="core:screen:orientation:changed",Te.CORE_MOUSE_MOVE="core:mousemove",Te.CORE_MOUSE_LEAVE="core:mouseleave",Te.CONTAINER_PLAYBACKSTATE="container:playbackstate",Te.CONTAINER_PLAYBACKDVRSTATECHANGED="container:dvr",Te.CONTAINER_BITRATE="container:bitrate",Te.CONTAINER_STATS_REPORT="container:stats:report",Te.CONTAINER_DESTROYED="container:destroyed",Te.CONTAINER_READY="container:ready",Te.CONTAINER_RESIZE="container:resize",Te.CONTAINER_ERROR="container:error",Te.CONTAINER_LOADEDMETADATA="container:loadedmetadata",Te.CONTAINER_SUBTITLE_AVAILABLE="container:subtitle:available",Te.CONTAINER_SUBTITLE_CHANGED="container:subtitle:changed",Te.CONTAINER_AUDIO_AVAILABLE="container:audio:available",Te.CONTAINER_AUDIO_CHANGED="container:audio:changed",Te.CONTAINER_TIMEUPDATE="container:timeupdate",Te.CONTAINER_PROGRESS="container:progress",Te.CONTAINER_PLAY="container:play",Te.CONTAINER_STOP="container:stop",Te.CONTAINER_PAUSE="container:pause",Te.CONTAINER_ENDED="container:ended",Te.CONTAINER_CLICK="container:click",Te.CONTAINER_DBLCLICK="container:dblclick",Te.CONTAINER_CONTEXTMENU="container:contextmenu",Te.CONTAINER_MOUSE_ENTER="container:mouseenter",Te.CONTAINER_MOUSE_LEAVE="container:mouseleave",Te.CONTAINER_MOUSE_UP="container:mouseup",Te.CONTAINER_MOUSE_DOWN="container:mousedown",Te.CONTAINER_SEEK="container:seek",Te.CONTAINER_SEEKED="container:seeked",Te.CONTAINER_VOLUME="container:volume",Te.CONTAINER_FULLSCREEN="container:fullscreen",Te.CONTAINER_STATE_BUFFERING="container:state:buffering",Te.CONTAINER_STATE_BUFFERFULL="container:state:bufferfull",Te.CONTAINER_SETTINGSUPDATE="container:settingsupdate",Te.CONTAINER_HIGHDEFINITIONUPDATE="container:highdefinitionupdate",Te.CONTAINER_MEDIACONTROL_SHOW="container:mediacontrol:show",Te.CONTAINER_MEDIACONTROL_HIDE="container:mediacontrol:hide",Te.CONTAINER_MEDIACONTROL_DISABLE="container:mediacontrol:disable",Te.CONTAINER_MEDIACONTROL_ENABLE="container:mediacontrol:enable",Te.CONTAINER_STATS_ADD="container:stats:add",Te.CONTAINER_OPTIONS_CHANGE="container:options:change",Te.MEDIACONTROL_RENDERED="mediacontrol:rendered",Te.MEDIACONTROL_FULLSCREEN="mediacontrol:fullscreen",Te.MEDIACONTROL_SHOW="mediacontrol:show",Te.MEDIACONTROL_HIDE="mediacontrol:hide",Te.MEDIACONTROL_MOUSEMOVE_SEEKBAR="mediacontrol:mousemove:seekbar",Te.MEDIACONTROL_MOUSELEAVE_SEEKBAR="mediacontrol:mouseleave:seekbar",Te.MEDIACONTROL_PLAYING="mediacontrol:playing",Te.MEDIACONTROL_NOTPLAYING="mediacontrol:notplaying",Te.MEDIACONTROL_CONTAINERCHANGED="mediacontrol:containerchanged",Te.MEDIACONTROL_OPTIONS_CHANGE="mediacontrol:options:change";var Se=function(e){T(r,e);var t=L(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return m(this,r),(e=t.call(this,i))._options=i,e.uniqueId=re("o"),e}return A(r,[{key:"options",get:function(){return this._options}}]),r}(Te),_e={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},ke=/(.)^/,Le={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},De=/\\|'|\r|\n|\t|\u2028|\u2029/g,Re={"&":"&","<":"<",">":">",'"':""","'":"'"},Ce=new RegExp("[&<>\"']","g"),Ie=function(e){return null===e?"":(""+e).replace(Ce,(function(e){return Re[e]}))},Oe=0,we=function(e,t){var r,i=new RegExp([(_e.escape||ke).source,(_e.interpolate||ke).source,(_e.evaluate||ke).source].join("|")+"|$","g"),n=0,a="__p+='";e.replace(i,(function(t,r,i,s,o){return a+=e.slice(n,o).replace(De,(function(e){return"\\"+Le[e]})),r&&(a+="'+\n((__t=("+r+"))==null?'':escapeExpr(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),s&&(a+="';\n"+s+"\n__p+='"),n=o+t.length,t})),a+="';\n",_e.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n//# sourceURL=/microtemplates/source["+Oe+++"]";try{r=new Function(_e.variable||"obj","escapeExpr",a)}catch(e){throw e.source=a,e}if(t)return r(t,Ie);var s=function(e){return r.call(this,e,Ie)};return s.source="function("+(_e.variable||"obj")+"){\n"+a+"}",s};we.settings=_e;var Pe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return G('<style class="clappr-style"></style>').html(we(e.toString())(t))},xe=/^(\S+)\s*(.*)$/,Ne=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e)).cid=re("c"),i._ensureElement(),i.delegateEvents(),i}return A(r,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}},{key:"$",value:function(e){return this.$el.find(e)}},{key:"render",value:function(){return this}},{key:"destroy",value:function(){return this.$el.remove(),this.stopListening(),this.undelegateEvents(),this}},{key:"setElement",value:function(e,t){return this.$el&&this.undelegateEvents(),this.$el=G.zepto.isZ(e)?e:G(e),this.el=this.$el[0],!1!==t&&this.delegateEvents(),this}},{key:"delegateEvents",value:function(e){for(var t in e||(e=this.events),this.undelegateEvents(),e){var r=e[t];if(r&&r.constructor!==Function&&(r=this[e[t]]),r){var i=t.match(xe),n=i[1],a=i[2];n+=".delegateEvents"+this.cid,""===a?this.$el.on(n,r.bind(this)):this.$el.on(n,a,r.bind(this))}}return this}},{key:"undelegateEvents",value:function(){return this.$el.off(".delegateEvents"+this.cid),this}},{key:"_ensureElement",value:function(){if(this.el)this.setElement(this.el,!1);else{var e=G.extend(!0,{},this.attributes);this.id&&(e.id=this.id),this.className&&(e.class=this.className);var t=G(oe.create(this.tagName)).attr(e);this.setElement(t,!1)}}}]),r}(Se),Fe=function(e){T(r,e);var t=L(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return m(this,r),(e=t.call(this,i)).core=n,e}return A(r,[{key:"name",get:function(){return"error"}},{key:"createError",value:function(e){this.core?this.core.trigger(Te.ERROR,e):ve.warn(this.name,"Core is not set. Error: ",e)}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}]),r}(Se),Me={createError:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},r=this.constructor&&this.constructor.type||"",i=this.name||r,n=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,a="".concat(i,":").concat(e&&e.code||"unknown"),s={description:"",level:Fe.Levels.FATAL,origin:i,scope:r,raw:{}},o=Object.assign({},s,e,{code:t.useCodePrefix?a:e.code});if(n&&o.level==Fe.Levels.FATAL&&!o.UI){var l={title:n.t("default_error_title"),message:n.t("default_error_message")};o.UI=l}return this.playerError?this.playerError.createError(o):ve.warn(i,"PlayerError is not defined. Error: ",o),o}},Ue=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i.render(),i}return A(r,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"getExternalInterface",value:function(){return{}}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"render",value:function(){return this}}]),r}(Ne);Object.assign(Ue.prototype,Me),Ue.extend=function(e){return Q(Ue,e)},Ue.type="core";var Be=function(e){T(r,e);var t=L(r);function r(e,i,n){var a;return m(this,r),(a=t.call(this,e))._i18n=i,a.currentTime=0,a.volume=100,a.playback=e.playback,a.playerError=n,a.settings=G.extend(!0,{},a.playback.settings),a.isReady=!1,a.mediaControlDisabled=!1,a.plugins=[a.playback],a.dblTapHandler=new le(500),a.clickTimer=null,a.clickDelay=200,a.actionsMetadata={},a.bindEvents(),a}return A(r,[{key:"name",get:function(){return"Container"}},{key:"attributes",get:function(){return{class:"container","data-container":""}}},{key:"events",get:function(){return{click:"clicked",dblclick:"dblClicked",touchend:"dblTap",contextmenu:"onContextMenu",mouseenter:"mouseEnter",mouseleave:"mouseLeave",mouseup:"onMouseUp",mousedown:"onMouseDown"}}},{key:"ended",get:function(){return this.playback.ended}},{key:"buffering",get:function(){return this.playback.buffering}},{key:"i18n",get:function(){return this._i18n}},{key:"hasClosedCaptionsTracks",get:function(){return this.playback.hasClosedCaptionsTracks}},{key:"closedCaptionsTracks",get:function(){return this.playback.closedCaptionsTracks}},{key:"closedCaptionsTrackId",get:function(){return this.playback.closedCaptionsTrackId},set:function(e){this.playback.closedCaptionsTrackId=e}},{key:"audioTracks",get:function(){return this.playback.audioTracks}},{key:"currentAudioTrack",get:function(){return this.playback.currentAudioTrack}},{key:"bindEvents",value:function(){this.listenTo(this.playback,Te.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,Te.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,Te.PLAYBACK_READY,this.ready),this.listenTo(this.playback,Te.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,Te.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,Te.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,Te.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,Te.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,Te.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,Te.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,Te.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,Te.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,Te.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,Te.PLAYBACK_SEEK,this.onSeek),this.listenTo(this.playback,Te.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,Te.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,Te.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,Te.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,Te.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,Te.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,Te.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,Te.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged),this.listenTo(this.playback,Te.PLAYBACK_AUDIO_AVAILABLE,this.audioAvailable),this.listenTo(this.playback,Te.PLAYBACK_AUDIO_CHANGED,this.audioChanged)}},{key:"subtitleAvailable",value:function(){this.trigger(Te.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(e){this.trigger(Te.CONTAINER_SUBTITLE_CHANGED,e)}},{key:"audioAvailable",value:function(e){this.trigger(Te.CONTAINER_AUDIO_AVAILABLE,e)}},{key:"audioChanged",value:function(e){this.trigger(Te.CONTAINER_AUDIO_CHANGED,e)}},{key:"playbackStateChanged",value:function(e){this.trigger(Te.CONTAINER_PLAYBACKSTATE,e)}},{key:"playbackDvrStateChanged",value:function(e){this.settings=this.playback.settings,this.dvrInUse=e,this.trigger(Te.CONTAINER_PLAYBACKDVRSTATECHANGED,e)}},{key:"updateBitrate",value:function(e){this.trigger(Te.CONTAINER_BITRATE,e)}},{key:"statsReport",value:function(e){this.trigger(Te.CONTAINER_STATS_REPORT,e)}},{key:"getPlaybackType",value:function(){return this.playback.getPlaybackType()}},{key:"isDvrEnabled",value:function(){return!!this.playback.dvrEnabled}},{key:"isDvrInUse",value:function(){return!!this.dvrInUse}},{key:"destroy",value:function(){this.disableResizeObserver(),this.trigger(Te.CONTAINER_DESTROYED,this,this.name),this.stopListening(),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove()}},{key:"setStyle",value:function(e){this.$el.css(e)}},{key:"animate",value:function(e,t){return this.$el.animate(e,t).promise()}},{key:"ready",value:function(){this.isReady=!0,this.trigger(Te.CONTAINER_READY,this.name)}},{key:"isPlaying",value:function(){return this.playback.isPlaying()}},{key:"getStartTimeOffset",value:function(){return this.playback.getStartTimeOffset()}},{key:"getCurrentTime",value:function(){return this.currentTime}},{key:"getDuration",value:function(){return this.playback.getDuration()}},{key:"error",value:function(e){this.isReady||this.ready(),this.trigger(Te.CONTAINER_ERROR,e,this.name)}},{key:"loadedMetadata",value:function(e){this.trigger(Te.CONTAINER_LOADEDMETADATA,e)}},{key:"timeUpdated",value:function(e){this.currentTime=e.current,this.trigger(Te.CONTAINER_TIMEUPDATE,e,this.name)}},{key:"onProgress",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.trigger.apply(this,[Te.CONTAINER_PROGRESS].concat(t,[this.name]))}},{key:"playing",value:function(){this.trigger(Te.CONTAINER_PLAY,this.name,this.actionsMetadata.playEvent||{}),this.actionsMetadata.playEvent={}}},{key:"paused",value:function(){this.trigger(Te.CONTAINER_PAUSE,this.name,this.actionsMetadata.pauseEvent||{}),this.actionsMetadata.pauseEvent={}}},{key:"stopped",value:function(){this.trigger(Te.CONTAINER_STOP,this.actionsMetadata.stopEvent||{}),this.actionsMetadata.stopEvent={}}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.playEvent=e,this.playback.play(e)}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.stopEvent=e,this.playback.stop(e),this.currentTime=0}},{key:"switchAudioTrack",value:function(e){this.playback.switchAudioTrack(e)}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.pauseEvent=e,this.playback.pause(e)}},{key:"onEnded",value:function(){this.trigger(Te.CONTAINER_ENDED,this,this.name),this.currentTime=0}},{key:"clicked",value:function(){var e=this;this.options.chromeless&&!this.options.allowUserInteraction||(this.clickTimer=setTimeout((function(){e.clickTimer&&e.trigger(Te.CONTAINER_CLICK,e,e.name)}),this.clickDelay))}},{key:"cancelClicked",value:function(){clearTimeout(this.clickTimer),this.clickTimer=null}},{key:"dblClicked",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||(this.cancelClicked(),this.trigger(Te.CONTAINER_DBLCLICK,this,this.name))}},{key:"dblTap",value:function(e){var t=this;this.options.chromeless&&!this.options.allowUserInteraction||this.dblTapHandler.handle(e,(function(){t.cancelClicked(),t.trigger(Te.CONTAINER_DBLCLICK,t,t.name)}))}},{key:"onContextMenu",value:function(e){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Te.CONTAINER_CONTEXTMENU,e,this.name)}},{key:"seek",value:function(e){this.playback.seek(e)}},{key:"onSeek",value:function(e){this.trigger(Te.CONTAINER_SEEK,e,this.name)}},{key:"onSeeked",value:function(){this.trigger(Te.CONTAINER_SEEKED,this.name)}},{key:"seekPercentage",value:function(e){var t=this.getDuration();if(e>=0&&e<=100){var r=t*(e/100);this.seek(r)}}},{key:"setVolume",value:function(e){this.volume=parseFloat(e),this.trigger(Te.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(Te.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(Te.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(Te.CONTAINER_STATE_BUFFERFULL,this.name)}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"mouseEnter",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Te.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Te.CONTAINER_MOUSE_LEAVE)}},{key:"mouseUp",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Te.CONTAINER_MOUSE_UP)}},{key:"mouseDown",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(Te.CONTAINER_MOUSE_DOWN)}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(Te.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(e){this.trigger(Te.CONTAINER_HIGHDEFINITIONUPDATE,e)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(Te.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(Te.CONTAINER_MEDIACONTROL_ENABLE))}},{key:"updateStyle",value:function(){!this.options.chromeless||this.options.allowUserInteraction?this.$el.removeClass("chromeless"):this.$el.addClass("chromeless")}},{key:"enableResizeObserver",value:function(){var e=this;this.disableResizeObserver(),this.resizeObserverInterval=setInterval((function(){return e.checkResize()}),500)}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval)}},{key:"checkResize",value:function(){var e={width:this.el.clientWidth,height:this.el.clientHeight},t=this.currentSize||{},r=t.width;(t.height!==e.height||r!==e.width)&&(this.currentSize=e,this.trigger(Te.CONTAINER_RESIZE,e))}},{key:"configure",value:function(e){this._options=G.extend(!0,this._options,e),this.updateStyle(),this.playback.configure(this.options),this.trigger(Te.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){var e=Pe(".container[data-container] {\n position: absolute;\n background-color: black;\n height: 100%;\n width: 100%;\n max-width: 100%; }\n .container[data-container] .chromeless {\n cursor: default; }\n\n[data-player]:not(.nocursor) .container[data-container]:not(.chromeless).pointer-enabled {\n cursor: pointer; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}]),r}(Ne);Object.assign(Be.prototype,Me);var Ge=function(e){T(r,e);var t=L(r);function r(e,i,n){var a;return m(this,r),(a=t.call(this,e)).settings={},a._i18n=i,a.playerError=n,a._consented=!1,a}return A(r,[{key:"isAudioOnly",get:function(){return!1}},{key:"isAdaptive",get:function(){return!1}},{key:"ended",get:function(){return!1}},{key:"i18n",get:function(){return this._i18n}},{key:"buffering",get:function(){return!1}},{key:"consent",value:function(e){"function"==typeof e&&e()}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"stop",value:function(){}},{key:"seek",value:function(e){}},{key:"seekPercentage",value:function(e){}},{key:"getStartTimeOffset",value:function(){return 0}},{key:"getDuration",value:function(){return 0}},{key:"isPlaying",value:function(){return!1}},{key:"isReady",get:function(){return!1}},{key:"hasClosedCaptionsTracks",get:function(){return this.closedCaptionsTracks.length>0}},{key:"closedCaptionsTracks",get:function(){return[]}},{key:"closedCaptionsTrackId",get:function(){return-1},set:function(e){}},{key:"audioTracks",get:function(){return[]}},{key:"currentAudioTrack",get:function(){return null}},{key:"switchAudioTrack",value:function(e){}},{key:"getPlaybackType",value:function(){return r.NO_OP}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"mute",value:function(){}},{key:"unmute",value:function(){}},{key:"volume",value:function(e){}},{key:"configure",value:function(e){this._options=G.extend(!0,this._options,e)}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){t&&e.play()}))}},{key:"canAutoPlay",value:function(e){e(!0,null)}}]),r}(Ne);Object.assign(Ge.prototype,Me),Ge.extend=function(e){return Q(Ge,e)},Ge.canPlay=function(e,t){return!1},Ge.VOD="vod",Ge.AOD="aod",Ge.LIVE="live",Ge.NO_OP="no_op",Ge.type="playback";var je=function(e){T(r,e);var t=L(r);function r(e,i,n,a){var s;return m(this,r),(s=t.call(this,e))._i18n=n,s.loader=i,s.playerError=a,s}return A(r,[{key:"options",get:function(){return this._options},set:function(e){this._options=e}},{key:"createContainers",value:function(){var e=this;return G.Deferred((function(t){t.resolve(e.options.sources.map((function(t){return e.createContainer(t)})))}))}},{key:"findPlaybackPlugin",value:function(e,t){return this.loader.playbackPlugins.filter((function(r){return r.canPlay(e,t)}))[0]}},{key:"createContainer",value:function(e){var t=null,r=this.options.mimeType;"object"===v(e)?(t=e.source.toString(),e.mimeType&&(r=e.mimeType)):t=e.toString(),t.match(/^\/\//)&&(t=window.location.protocol+t);var i=p(p({},this.options),{},{src:t,mimeType:r}),n=this.findPlaybackPlugin(t,r),a=n?new n(i,this._i18n,this.playerError):new Ge;i=p(p({},i),{},{playback:a});var s=new Be(i,this._i18n,this.playerError),o=G.Deferred();return o.promise(s),this.addContainerPlugins(s),this.listenToOnce(s,Te.CONTAINER_READY,(function(){return o.resolve(s)})),s}},{key:"addContainerPlugins",value:function(e){this.loader.containerPlugins.forEach((function(t){e.addPlugin(new t(e))}))}}]),r}(Se),Ke=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e)).playerError=new Fe(e,_(i)),i.configureDomRecycler(),i.firstResize=!0,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},G(document).bind("fullscreenchange",i._boundFullscreenHandler),G(document).bind("MSFullscreenChange",i._boundFullscreenHandler),G(document).bind("mozfullscreenchange",i._boundFullscreenHandler),H.isMobile&&G(window).bind("resize",(function(e){i.handleWindowResize(e)})),i}return A(r,[{key:"events",get:function(){return{webkitfullscreenchange:"handleFullscreenChange",mousemove:"onMouseMove",mouseleave:"onMouseLeave"}}},{key:"attributes",get:function(){return{"data-player":"",tabindex:9999}}},{key:"isReady",get:function(){return!!this.ready}},{key:"i18n",get:function(){return this.getPlugin("strings")||{t:function(e){return e}}}},{key:"mediaControl",get:function(){return this._mediaControl||(this._mediaControl=this.getPlugin("media_control"))||this.dummyMediaControl}},{key:"dummyMediaControl",get:function(){return this._dummyMediaControl||(this._dummyMediaControl=new Ue(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(e){this._activeContainer=e,this.trigger(Te.CORE_ACTIVE_CONTAINER_CHANGED,this._activeContainer)}},{key:"activePlayback",get:function(){return this.activeContainer&&this.activeContainer.playback}},{key:"activePlaybackEl",get:function(){if(this.activePlayback)return this.activePlayback.$el?this.activePlayback.$el.find("video")[0]:this.activePlayback.el}},{key:"configureDomRecycler",value:function(){var e=this.options&&this.options.playback&&this.options.playback.recycleVideo;oe.configure({recycleVideo:e})}},{key:"createContainers",value:function(e){this.defer=G.Deferred(),this.defer.promise(this),this.containerFactory=new je(e,e.loader,this.i18n,this.playerError),this.prepareContainers()}},{key:"prepareContainers",value:function(){var e=this;this.containerFactory.createContainers().then((function(t){return e.setupContainers(t)})).then((function(t){return e.resolveOnContainersReady(t)}))}},{key:"updateSize",value:function(){this.isFullscreen()?this.setFullscreen():this.setPlayerSize()}},{key:"setFullscreen",value:function(){H.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:G(window).width(),height:G(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:G(window).width(),height:G(window).height()},this.resize(this.currentSize)}},{key:"resize",value:function(e){ie(e.height)||ie(e.width)?(this.el.style.height="".concat(e.height,"px"),this.el.style.width="".concat(e.width,"px")):(this.el.style.height="".concat(e.height),this.el.style.width="".concat(e.width)),this.previousSize={width:this.options.width,height:this.options.height},this.options.width=e.width,this.options.height=e.height,this.currentSize=e,this.triggerResize(this.currentSize)}},{key:"enableResizeObserver",value:function(){var e=this;this.disableResizeObserver();this.resizeObserverInterval=setInterval((function(){e.triggerResize({width:e.el.clientWidth,height:e.el.clientHeight})}),500)}},{key:"triggerResize",value:function(e){(this.firstResize||this.oldHeight!==e.height||this.oldWidth!==e.width)&&(this.oldHeight=e.height,this.oldWidth=e.width,this.computedSize=e,this.firstResize=!1,this.trigger(Te.CORE_RESIZE,e))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(e){var t=this;G.when.apply(G,e).done((function(){t.defer.resolve(t),t.ready=!0,t.trigger(Te.CORE_READY)}))}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"load",value:function(e,t){this.options.mimeType=t,e=e&&e.constructor===Array?e:[e],this.options.sources=e,this.containers.forEach((function(e){return e.destroy()})),this.containerFactory.options=G.extend(!0,this.options,{sources:e}),this.prepareContainers()}},{key:"destroy",value:function(){this.disableResizeObserver(),this.containers.forEach((function(e){return e.destroy()})),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove(),G(document).unbind("fullscreenchange",this._boundFullscreenHandler),G(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),G(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),this.stopListening()}},{key:"handleFullscreenChange",value:function(){this.trigger(Te.CORE_FULLSCREEN,this.isFullscreen()),this.updateSize()}},{key:"handleWindowResize",value:function(e){var t=window.innerWidth>window.innerHeight?"landscape":"portrait";this._screenOrientation!==t&&(this._screenOrientation=t,this.triggerResize({width:this.el.clientWidth,height:this.el.clientHeight}),this.trigger(Te.CORE_SCREEN_ORIENTATION_CHANGED,{event:e,orientation:this._screenOrientation}))}},{key:"removeContainer",value:function(e){this.stopListening(e),this.containers=this.containers.filter((function(t){return t!==e}))}},{key:"setupContainer",value:function(e){this.listenTo(e,Te.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(e)}},{key:"setupContainers",value:function(e){return e.forEach(this.setupContainer.bind(this)),this.trigger(Te.CORE_CONTAINERS_CREATED),this.renderContainers(),this.activeContainer=e[0],this.render(),this.appendToParent(),this.containers}},{key:"renderContainers",value:function(){var e=this;this.containers.forEach((function(t){return e.el.appendChild(t.render().el)}))}},{key:"createContainer",value:function(e,t){var r=this.containerFactory.createContainer(e,t);return this.setupContainer(r),this.el.appendChild(r.render().el),r}},{key:"getCurrentContainer",value:function(){return this.activeContainer}},{key:"getCurrentPlayback",value:function(){return this.activePlayback}},{key:"getPlaybackType",value:function(){return this.activeContainer&&this.activeContainer.getPlaybackType()}},{key:"isFullscreen",value:function(){var e=J.fullscreenElement();return e&&e===this.el||e&&e===this.activePlaybackEl||this.activePlaybackEl&&this.activePlaybackEl.webkitDisplayingFullscreen||!1}},{key:"toggleFullscreen",value:function(){var e=this;if(this.isFullscreen()){var t=H.isiOS?this.activePlaybackEl:document;J.cancelFullscreen(t),!H.isiOS&&this.$el.removeClass("fullscreen nocursor")}else{var r=H.isiOS?this.activePlaybackEl:this.el;if(!r)return;H.isSafari||H.isiOS?J.requestFullscreen(r):J.requestFullscreen(r).then((function(e){return e}),(function(t){return setTimeout((function(){if(!e.isFullscreen())throw new ReferenceError(t)}),600)})),!H.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(e){this.trigger(Te.CORE_MOUSE_MOVE,e)}},{key:"onMouseLeave",value:function(e){this.trigger(Te.CORE_MOUSE_LEAVE,e)}},{key:"configure",value:function(e){var t=this;this._options=G.extend(!0,this._options,e),this.configureDomRecycler();var r=e.source||e.sources;r&&this.load(r,e.mimeType||this.options.mimeType),this.trigger(Te.CORE_OPTIONS_CHANGE,e),this.containers.forEach((function(e){return e.configure(t.options)}))}},{key:"appendToParent",value:function(){var e=Pe('[data-player] {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n user-select: none;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n transform: translate3d(0, 0, 0);\n position: relative;\n margin: 0;\n padding: 0;\n border: 0;\n font-style: normal;\n font-weight: normal;\n text-align: center;\n overflow: hidden;\n font-size: 100%;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-shadow: 0 0 0;\n box-sizing: border-box; }\n [data-player]:focus {\n outline: 0; }\n [data-player] * {\n box-sizing: inherit; }\n [data-player] > * {\n float: none;\n max-width: none; }\n [data-player] > div {\n display: block; }\n [data-player].fullscreen {\n width: 100% !important;\n height: 100% !important;\n top: 0;\n left: 0; }\n [data-player].nocursor {\n cursor: none; }\n\n.clappr-style {\n display: none !important; }\n'.toString(),{baseUrl:this.options.baseUrl}),t=Pe('[data-player] div, [data-player] span, [data-player] applet, [data-player] object, [data-player] iframe,\n[data-player] h1, [data-player] h2, [data-player] h3, [data-player] h4, [data-player] h5, [data-player] h6, [data-player] p, [data-player] blockquote, [data-player] pre,\n[data-player] a, [data-player] abbr, [data-player] acronym, [data-player] address, [data-player] big, [data-player] cite, [data-player] code,\n[data-player] del, [data-player] dfn, [data-player] em, [data-player] img, [data-player] ins, [data-player] kbd, [data-player] q, [data-player] s, [data-player] samp,\n[data-player] small, [data-player] strike, [data-player] strong, [data-player] sub, [data-player] sup, [data-player] tt, [data-player] var,\n[data-player] b, [data-player] u, [data-player] i, [data-player] center,\n[data-player] dl, [data-player] dt, [data-player] dd, [data-player] ol, [data-player] ul, [data-player] li,\n[data-player] fieldset, [data-player] form, [data-player] label, [data-player] legend,\n[data-player] table, [data-player] caption, [data-player] tbody, [data-player] tfoot, [data-player] thead, [data-player] tr, [data-player] th, [data-player] td,\n[data-player] article, [data-player] aside, [data-player] canvas, [data-player] details, [data-player] embed,\n[data-player] figure, [data-player] figcaption, [data-player] footer, [data-player] header, [data-player] hgroup,\n[data-player] menu, [data-player] nav, [data-player] output, [data-player] ruby, [data-player] section, [data-player] summary,\n[data-player] time, [data-player] mark, [data-player] audio, [data-player] video {\n margin: 0;\n padding: 0;\n border: 0;\n font: inherit;\n font-size: 100%;\n vertical-align: baseline; }\n\n[data-player] table {\n border-collapse: collapse;\n border-spacing: 0; }\n\n[data-player] caption, [data-player] th, [data-player] td {\n text-align: left;\n font-weight: normal;\n vertical-align: middle; }\n\n[data-player] q, [data-player] blockquote {\n quotes: none; }\n [data-player] q:before, [data-player] q:after, [data-player] blockquote:before, [data-player] blockquote:after {\n content: "";\n content: none; }\n\n[data-player] a img {\n border: none; }\n'.toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0]),this.options.includeResetStyle&&this.$el.append(t[0]),!(this.$el.parent()&&this.$el.parent().length)&&this.$el.appendTo(this.options.parentElement)}},{key:"render",value:function(){this.options.width=this.options.width||this.$el.width(),this.options.height=this.options.height||this.$el.height();var e={width:this.options.width,height:this.options.height};return this.previousSize=this.currentSize=this.computedSize=e,this.updateSize(),this.enableResizeObserver(),this}}]),r}(Ne);Object.assign(Ke.prototype,Me);var He,Ve,Ye=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e.options)).player=e,i}return A(r,[{key:"loader",get:function(){return this.player.loader}},{key:"create",value:function(){return this.options.loader=this.loader,this.core=new Ke(this.options),this.addCorePlugins(),this.core.createContainers(this.options),this.core}},{key:"addCorePlugins",value:function(){var e=this;return this.loader.corePlugins.forEach((function(t){var r=new t(e.core);e.core.addPlugin(r),e.setupExternalInterface(r)})),this.core}},{key:"setupExternalInterface",value:function(e){var t=e.getExternalInterface();for(var r in t)this.player[r]=t[r].bind(e)}}]),r}(Se),We=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,ze=function(){function e(t,r,i){m(this,e),this.major=parseInt(t||0,10),this.minor=parseInt(r||0,10),this.patch=parseInt(i||0,10)}return A(e,[{key:"compare",value:function(e){var t=this.major-e.major;return t=(t=t||this.minor-e.minor)||this.patch-e.patch}},{key:"inc",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"patch";return void 0!==this[e]&&(this[e]+=1),this}},{key:"satisfies",value:function(e,t){return this.compare(e)>=0&&(!t||this.compare(t)<0)}},{key:"toString",value:function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.patch)}}],[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=t.match(We)||[],i=C(r,4),n=i[1],a=i[2],s=i[3];return void 0===n?null:new e(n,a,s)}}]),e}(),qe=function(e,t){return e&&t?Object.entries(e).filter((function(e){return C(e,2)[1].type===t})).reduce((function(e,t){var r=C(t,2),i=r[0],n=r[1];return e[i]=n,e}),{}):{}},Xe=(He={plugins:{},playbacks:[]},Ve="0.4.27",function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;m(this,e),this.playerId=r,this.playbackPlugins=I(He.playbacks);var i=e.registeredPlugins,n=i.core,a=i.container;this.containerPlugins=Object.values(a),this.corePlugins=Object.values(n),Array.isArray(t)||this.validateExternalPluginsType(t),this.addExternalPlugins(t)}return A(e,[{key:"groupPluginsByType",value:function(e){return Array.isArray(e)&&(e=e.reduce((function(e,t){return e[t.type]||(e[t.type]=[]),e[t.type].push(t),e}),{})),e}},{key:"removeDups",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=function(e,r){return e[r.prototype.name]&&t||(e[r.prototype.name]&&delete e[r.prototype.name],e[r.prototype.name]=r),e},i=e.reduceRight(r,Object.create(null)),n=[];for(var a in i)n.unshift(i[a]);return n}},{key:"addExternalPlugins",value:function(t){var r="boolean"!=typeof t.loadExternalPluginsFirst||t.loadExternalPluginsFirst,i="boolean"!=typeof t.loadExternalPlaybacksFirst||t.loadExternalPlaybacksFirst;if((t=this.groupPluginsByType(t)).playback){var n=t.playback.filter((function(t){return e.checkVersionSupport(t),!0}));this.playbackPlugins=i?this.removeDups(n.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(n),!0)}if(t.container){var a=t.container.filter((function(t){return e.checkVersionSupport(t),!0}));this.containerPlugins=r?this.removeDups(a.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(a),!0)}if(t.core){var s=t.core.filter((function(t){return e.checkVersionSupport(t),!0}));this.corePlugins=r?this.removeDups(s.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(s),!0)}}},{key:"validateExternalPluginsType",value:function(e){["playback","container","core"].forEach((function(t){(e[t]||[]).forEach((function(e){var r="external "+e.type+" plugin on "+t+" array";if(e.type!==t)throw new ReferenceError(r)}))}))}}],[{key:"registeredPlaybacks",get:function(){return I(He.playbacks)}},{key:"registeredPlugins",get:function(){var e=He.plugins;return{core:qe(e,"core"),container:qe(e,"container")}}},{key:"checkVersionSupport",value:function(e){var t=e.prototype,r=t.supportedVersion,i=t.name;if(!r||!r.min)return ve.warn("Loader","missing version information for ".concat(i)),!1;var n=r.max?ze.parse(r.max):ze.parse(r.min).inc("minor"),a=ze.parse(r.min);return!!ze.parse(Ve).satisfies(a,n)||(ve.warn("Loader","unsupported plugin ".concat(i,": Clappr version ").concat(Ve," does not match required range [").concat(a,",").concat(n,")")),!1)}},{key:"registerPlugin",value:function(t){if(!t||!t.prototype.name)return ve.warn("Loader","missing information to register plugin: ".concat(t)),!1;e.checkVersionSupport(t);var r=He.plugins;if(!r)return!1;var i=r[t.prototype.name];return i&&ve.warn("Loader","overriding plugin entry: ".concat(t.prototype.name," - ").concat(i)),r[t.prototype.name]=t,!0}},{key:"registerPlayback",value:function(t){if(!t||!t.prototype.name)return!1;e.checkVersionSupport(t);var r=He.playbacks,i=r.findIndex((function(e){return e.prototype.name===t.prototype.name}));if(i>=0){var n=r[i];r.splice(i,1),ve.warn("Loader","overriding playback entry: ".concat(n.name," - ").concat(n))}return He.playbacks=[t].concat(I(r)),!0}},{key:"unregisterPlugin",value:function(e){if(!e)return!1;var t=He.plugins;return!!t[e]&&(delete t[e],!0)}},{key:"unregisterPlayback",value:function(e){if(!e)return!1;var t=He.playbacks,r=t.findIndex((function(t){return t.prototype.name===e}));return!(r<0||(t.splice(r,1),He.playbacks=t,0))}},{key:"clearPlugins",value:function(){He.plugins={}}},{key:"clearPlaybacks",value:function(){He.playbacks=[]}}]),e}()),$e=ne().replace(/\/[^/]+$/,""),Ze=function(e){T(r,e);var t=L(r);function r(e){var i;m(this,r),i=t.call(this,e);var n={playerId:re(""),persistConfig:!0,width:640,height:360,baseUrl:$e,allowUserInteraction:H.isMobile,includeResetStyle:!0,playback:{recycleVideo:!0}};i._options=G.extend(!0,n,e),i.options.sources=i._normalizeSources(e),i.options.chromeless||(i.options.allowUserInteraction=!0),i.options.allowUserInteraction||(i.options.disableKeyboardShortcuts=!0),i._registerOptionEventListeners(i.options.events),i._coreFactory=new Ye(_(i));var a=i._getParentElement(i.options);return a&&i.attachTo(a),i}return A(r,[{key:"loader",get:function(){return this._loader||(this._loader=new Xe(this.options.plugins||{},this.options.playerId)),this._loader},set:function(e){this._loader=e}},{key:"ended",get:function(){return this.core.activeContainer.ended}},{key:"buffering",get:function(){return this.core.activeContainer.buffering}},{key:"isReady",get:function(){return!!this._ready}},{key:"eventsMapping",get:function(){return{onReady:Te.PLAYER_READY,onResize:Te.PLAYER_RESIZE,onPlay:Te.PLAYER_PLAY,onPause:Te.PLAYER_PAUSE,onStop:Te.PLAYER_STOP,onEnded:Te.PLAYER_ENDED,onSeek:Te.PLAYER_SEEK,onError:Te.PLAYER_ERROR,onTimeUpdate:Te.PLAYER_TIMEUPDATE,onVolumeUpdate:Te.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:Te.PLAYER_SUBTITLE_AVAILABLE}}},{key:"_getParentElement",value:function(e){var t=e.parentId,r=e.parent;return t?document.querySelector(t):r}},{key:"attachTo",value:function(e){return this.options.parentElement=e,this.core=this._coreFactory.create(),this._addEventListeners(),this}},{key:"_addEventListeners",value:function(){return this.core.isReady?this._onReady():this.listenToOnce(this.core,Te.CORE_READY,this._onReady),this.listenTo(this.core,Te.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,Te.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,Te.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var e=this.core.activeContainer;return e&&(this.listenTo(e,Te.CONTAINER_PLAY,this._onPlay),this.listenTo(e,Te.CONTAINER_PAUSE,this._onPause),this.listenTo(e,Te.CONTAINER_STOP,this._onStop),this.listenTo(e,Te.CONTAINER_ENDED,this._onEnded),this.listenTo(e,Te.CONTAINER_SEEK,this._onSeek),this.listenTo(e,Te.CONTAINER_ERROR,this._onError),this.listenTo(e,Te.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(e,Te.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(e,Te.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).length>0;return i&&Object.keys(r).forEach((function(t){var i=e.eventsMapping[t];i&&e.off(i,r[t])})),Object.keys(t).forEach((function(r){var i=e.eventsMapping[r];if(i){var n=t[r];(n="function"==typeof n&&n)&&e.on(i,n)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(Te.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(e){this.trigger(Te.PLAYER_FULLSCREEN,e)}},{key:"_onVolumeUpdate",value:function(e){this.trigger(Te.PLAYER_VOLUMEUPDATE,e)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(Te.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(e){this.trigger(Te.PLAYER_RESIZE,e)}},{key:"_onPlay",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(Te.PLAYER_PLAY,t)}},{key:"_onPause",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(Te.PLAYER_PAUSE,t)}},{key:"_onStop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.trigger(Te.PLAYER_STOP,this.getCurrentTime(),e)}},{key:"_onEnded",value:function(){this.trigger(Te.PLAYER_ENDED)}},{key:"_onSeek",value:function(e){this.trigger(Te.PLAYER_SEEK,e)}},{key:"_onTimeUpdate",value:function(e){this.trigger(Te.PLAYER_TIMEUPDATE,e)}},{key:"_onError",value:function(e){this.trigger(Te.PLAYER_ERROR,e)}},{key:"_normalizeSources",value:function(e){var t=e.sources||(void 0!==e.source?[e.source]:[]);return 0===t.length?[{source:"",mimeType:""}]:t}},{key:"resize",value:function(e){return this.core.resize(e),this}},{key:"load",value:function(e,t,r){return void 0!==r&&this.configure({autoPlay:!!r}),this.core.load(e,t),this}},{key:"destroy",value:function(){return this.stopListening(),this.core.destroy(),this}},{key:"consent",value:function(e){this.core.getCurrentPlayback().consent(e)}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.play(e),this}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.pause(e),this}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.stop(e),this}},{key:"seek",value:function(e){return this.core.activeContainer.seek(e),this}},{key:"seekPercentage",value:function(e){return this.core.activeContainer.seekPercentage(e),this}},{key:"mute",value:function(){return this.core.activePlayback.mute(),this}},{key:"unmute",value:function(){return this.core.activePlayback.unmute(),this}},{key:"isPlaying",value:function(){return this.core.activeContainer.isPlaying()}},{key:"isDvrEnabled",value:function(){return this.core.activeContainer.isDvrEnabled()}},{key:"isDvrInUse",value:function(){return this.core.activeContainer.isDvrInUse()}},{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._registerOptionEventListeners(e.events,this.options.events),this.core.configure(e),this}},{key:"getPlugin",value:function(e){return this.core.plugins.concat(this.core.activeContainer.plugins).filter((function(t){return t.name===e}))[0]}},{key:"getCurrentTime",value:function(){return this.core.activeContainer.getCurrentTime()}},{key:"getStartTimeOffset",value:function(){return this.core.activeContainer.getStartTimeOffset()}},{key:"getDuration",value:function(){return this.core.activeContainer.getDuration()}}]),r}(Se);Object.assign(Ze.prototype,Me);var Qe=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return A(r,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"bindEvents",value:function(){}},{key:"destroy",value:function(){this.stopListening()}}]),r}(Se);Object.assign(Qe.prototype,Me),Qe.extend=function(e){return Q(Qe,e)},Qe.type="container";var Je=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i}return A(r,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"getExternalInterface",value:function(){return{}}},{key:"destroy",value:function(){this.stopListening()}}]),r}(Se);Object.assign(Je.prototype,Me),Je.extend=function(e){return Q(Je,e)},Je.type="core";var et=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return A(r,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"bindEvents",value:function(){}}]),r}(Ne);Object.assign(et.prototype,Me),et.extend=function(e){return Q(et,e)},et.type="container";var tt={mp4:["avc1.42E01E","avc1.58A01E","avc1.4D401E","avc1.64001E","mp4v.20.8","mp4v.20.240","mp4a.40.2"].map((function(e){return'video/mp4; codecs="'+e+', mp4a.40.2"'})),ogg:['video/ogg; codecs="theora, vorbis"','video/ogg; codecs="dirac"','video/ogg; codecs="theora, speex"'],"3gpp":['video/3gpp; codecs="mp4v.20.8, samr"'],webm:['video/webm; codecs="vp8, vorbis"'],mkv:['video/x-matroska; codecs="theora, vorbis"'],m3u8:["application/x-mpegurl"]};tt.ogv=tt.ogg,tt["3gp"]=tt["3gpp"];var rt={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},it=Object.keys(rt).reduce((function(e,t){return[].concat(I(e),I(rt[t]))}),[]),nt={code:"unknown",message:"unknown"},at=function(e){T(r,e);var t=L(r);function r(){var e;m(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];(e=t.call.apply(t,[this].concat(n)))._destroyed=!1,e._loadStarted=!1,e._isBuffering=!1,e._playheadMoving=!1,e._playheadMovingTimer=null,e._stopped=!1,e._ccTrackId=-1,e._setupSrc(e.options.src),e.options.playback||(e.options.playback=e.options||{}),e.options.playback.disableContextMenu=e.options.playback.disableContextMenu||e.options.disableVideoTagContextMenu,e._minDvrSize=e.isValidMinimumDVRSizeConfig?e.minimumDVRSizeConfig:60;var s,o=e.options.playback,l=o.preload||(H.isSafari?"auto":e.options.preload);return e.options.poster&&("string"==typeof e.options.poster?s=e.options.poster:"string"==typeof e.options.poster.url&&(s=e.options.poster.url)),G.extend(!0,e.el,{muted:e.options.mute,defaultMuted:e.options.mute,loop:e.options.loop,poster:s,preload:l||"metadata",crossOrigin:o.crossOrigin,"x-webkit-playsinline":o.playInline}),(o.controls||e.options.useVideoTagDefaultControls)&&e.$el.attr("controls",""),o.playInline&&e.$el.attr({playsinline:"playsinline"}),o.crossOrigin&&e.$el.attr({crossorigin:o.crossOrigin}),e.settings={default:["seekbar"]},e.settings.left=["playpause","position","duration"],e.settings.right=["fullscreen","volume","hd-indicator"],o.externalTracks&&e._setupExternalTracks(o.externalTracks),e.options.autoPlay&&e.attemptAutoPlay(),e}return A(r,[{key:"name",get:function(){return"html5_video"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"tagName",get:function(){return this.isAudioOnly?"audio":"video"}},{key:"isAudioOnly",get:function(){var e=this.options.src,t=r._mimeTypesForUrl(e,rt,this.options.mimeType);return this.options.playback&&this.options.playback.audioOnly||this.options.audioOnly||it.indexOf(t[0])>=0}},{key:"attributes",get:function(){return{"data-html5-video":""}}},{key:"events",get:function(){return{canplay:"_onCanPlay",canplaythrough:"_handleBufferingEvents",durationchange:"_onDurationChange",ended:"_onEnded",error:"_onError",loadeddata:"_onLoadedData",loadedmetadata:"_onLoadedMetadata",pause:"_onPause",playing:"_onPlaying",progress:"_onProgress",seeking:"_onSeeking",seeked:"_onSeeked",stalled:"_handleBufferingEvents",timeupdate:"_onTimeUpdate",waiting:"_onWaiting"}}},{key:"ended",get:function(){return this.el.ended}},{key:"buffering",get:function(){return this._isBuffering}},{key:"isLive",get:function(){return this.getPlaybackType()===Ge.LIVE}},{key:"dvrEnabled",get:function(){return this.getDuration()>=this._minDvrSize&&this.isLive}},{key:"minimumDVRSizeConfig",get:function(){return this.options.playback&&this.options.playback.minimumDvrSize}},{key:"isValidMinimumDVRSizeConfig",get:function(){return void 0!==this.minimumDVRSizeConfig&&"number"==typeof this.minimumDVRSizeConfig}},{key:"configure",value:function(e){R(b(r.prototype),"configure",this).call(this,e),this.el.loop=!!e.loop}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){r&&ve.warn(e.name,"autoplay error.",{result:t,error:r}),t&&setTimeout((function(){return!e._destroyed&&e.play()}),0)}))}},{key:"canAutoPlay",value:function(e){if(this.options.disableCanAutoPlay)e(!0,null);else{var t={timeout:this.options.autoPlayTimeout||500,inline:this.options.playback.playInline||!1,muted:this.options.mute||!1};H.isMobile&&oe.options.recycleVideo&&(t.element=this.el),se(e,t)}}},{key:"_setupExternalTracks",value:function(e){this._externalTracks=e.map((function(e){return{kind:e.kind||"subtitles",label:e.label,lang:e.lang,src:e.src}}))}},{key:"_setupSrc",value:function(e){this.el.src!==e&&(this._ccIsSetup=!1,this.el.src=e,this._src=this.el.src)}},{key:"_onLoadedMetadata",value:function(e){this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_LOADEDMETADATA,{duration:e.target.duration,data:e}),this._updateSettings();var t=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Ge.LIVE&&t&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Ge.VOD||this.getPlaybackType()===Ge.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Te.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var e="audio"===this.tagName?Ge.AOD:Ge.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Ge.LIVE:e}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(e){var t=this;if(this.isPlaying()||this.el._consented)R(b(r.prototype),"consent",this).call(this,e);else{var i=function i(){t.el.removeEventListener("loadedmetadata",i,!1),t.el.removeEventListener("error",i,!1),t.el._consented=!0,R(b(r.prototype),"consent",t).call(t,e)};this.el.addEventListener("loadedmetadata",i,!1),this.el.addEventListener("error",i,!1),this.el.load()}}},{key:"play",value:function(){this.trigger(Te.PLAYBACK_PLAY_INTENT),this._stopped=!1,this._setupSrc(this._src),this._handleBufferingEvents();var e=this.el.play();e&&e.catch&&e.catch((function(){}))}},{key:"pause",value:function(){this.el.pause(),this.dvrEnabled&&this._updateDvr(!0)}},{key:"stop",value:function(){this.pause(),this._stopped=!0,this.el.removeAttribute("src"),this.el.load(),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_STOP)}},{key:"volume",value:function(e){0===e?(this.$el.attr({muted:"true"}),this.el.muted=!0):(this.$el.attr({muted:null}),this.el.muted=!1,this.el.volume=e/100)}},{key:"mute",value:function(){this.el.muted=!0}},{key:"unmute",value:function(){this.el.muted=!1}},{key:"isMuted",value:function(){return!0===this.el.muted||0===this.el.volume}},{key:"isPlaying",value:function(){return!this.el.paused&&!this.el.ended}},{key:"isReady",get:function(){return this._isReadyState}},{key:"_startPlayheadMovingChecks",value:function(){null===this._playheadMovingTimer&&(this._playheadMovingTimeOnCheck=null,this._determineIfPlayheadMoving(),this._playheadMovingTimer=setInterval(this._determineIfPlayheadMoving.bind(this),500))}},{key:"_stopPlayheadMovingChecks",value:function(){null!==this._playheadMovingTimer&&(clearInterval(this._playheadMovingTimer),this._playheadMovingTimer=null,this._playheadMoving=!1)}},{key:"_determineIfPlayheadMoving",value:function(){var e=this._playheadMovingTimeOnCheck,t=this.el.currentTime;this._playheadMoving=e!==t,this._playheadMovingTimeOnCheck=t,this._handleBufferingEvents()}},{key:"_onWaiting",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onLoadedData",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onCanPlay",value:function(){this._handleBufferingEvents()}},{key:"_onPlaying",value:function(){this._checkForClosedCaptions(),this._startPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){this.trigger(Te.PLAYBACK_SEEK,this.getCurrentTime()),this._handleBufferingEvents()}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(Te.PLAYBACK_ENDED,this.name)}},{key:"_handleBufferingEvents",value:function(){var e=!this.el.ended&&!this.el.paused,t=this._loadStarted&&!this.el.ended&&!this._stopped&&(e&&!this._playheadMoving||this.el.readyState<this.el.HAVE_FUTURE_DATA);this._isBuffering!==t&&(this._isBuffering=t,t?this.trigger(Te.PLAYBACK_BUFFERING,this.name):this.trigger(Te.PLAYBACK_BUFFERFULL,this.name))}},{key:"_onError",value:function(){var e=this.el.error||nt,t=e.code,r=e.message,i=t===nt.code,n=this.createError({code:t,description:r,raw:this.el.error,level:i?Fe.Levels.WARN:Fe.Levels.FATAL});i?ve.warn(this.name,"HTML5 unknown error: ",n):this.trigger(Te.PLAYBACK_ERROR,n)}},{key:"destroy",value:function(){this._destroyed=!0,this.handleTextTrackChange&&this.el.textTracks.removeEventListener("change",this.handleTextTrackChange),R(b(r.prototype),"destroy",this).call(this),this.el.removeAttribute("src"),this.el.load(),this._src=null,oe.garbage(this.el)}},{key:"_updateDvr",value:function(e){this.trigger(Te.PLAYBACK_DVR,e),this.trigger(Te.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"seek",value:function(e){e<0&&(ve.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this.el.seekable.start(0),this.el.currentTime=e}},{key:"seekPercentage",value:function(e){var t=this.el.duration*(e/100);this.seek(t)}},{key:"_checkInitialSeek",value:function(){var e=te();0!==e&&this.seek(e)}},{key:"getCurrentTime",value:function(){return this.el.currentTime}},{key:"getDuration",value:function(){if(this.isLive){if(this.el.seekable.length>0)return this.el.seekable.end(0)-this.el.seekable.start(0);this._scheduleUpdateSettingsCheck()}return this.el.duration}},{key:"_scheduleUpdateSettingsCheck",value:function(){var e=this;this._updateSettingsCheckInFlight||(this._updateSettingsCheckInFlight=setTimeout((function(){e._updateSettings(),e._updateSettingsCheckInFlight=null}),1e3))}},{key:"_onTimeUpdate",value:function(){var e=this.isLive?this.getDuration():this.el.duration;this.trigger(Te.PLAYBACK_TIMEUPDATE,{current:this.el.currentTime,total:e},this.name)}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(I(e),[{start:this.el.buffered.start(r),end:this.el.buffered.end(r)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.el.duration};this.trigger(Te.PLAYBACK_PROGRESS,i,e)}}},{key:"_typeFor",value:function(e){var t=r._mimeTypesForUrl(e,tt,this.options.mimeType);return 0===t.length&&(t=r._mimeTypesForUrl(e,rt,this.options.mimeType)),(t[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(Te.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(Te.PLAYBACK_SUBTITLE_AVAILABLE);var e=this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this.handleTextTrackChange=this._handleTextTrackChange.bind(this),this.el.textTracks.addEventListener("change",this.handleTextTrackChange)}this._ccIsSetup=!0}}},{key:"_handleTextTrackChange",value:function(){var e=this.closedCaptionsTracks.find((function(e){return"showing"===e.track.mode}))||{id:-1};this._ccTrackId!==e.id&&(this._ccTrackId=e.id,this.trigger(Te.PLAYBACK_SUBTITLE_CHANGED,{id:e.id}))}},{key:"isHTML5Video",get:function(){return this.name===r.prototype.name}},{key:"closedCaptionsTracks",get:function(){var e=0;return(this.el.textTracks?Array.from(this.el.textTracks):[]).filter((function(e){return"subtitles"===e.kind||"captions"===e.kind})).map((function(t){return{id:e++,name:t.label,track:t}}))}},{key:"closedCaptionsTrackId",get:function(){return this._ccTrackId},set:function(e){if(ie(e)){var t,r=this.closedCaptionsTracks;if(-1!==e){if(!(t=r.find((function(t){return t.id===e}))))return;if("showing"===t.track.mode)return}r.filter((function(e){return"hidden"!==e.track.mode})).forEach((function(e){return e.track.mode="hidden"})),t&&(t.track.mode="showing"),this._ccTrackId=e,this.trigger(Te.PLAYBACK_SUBTITLE_CHANGED,{id:e})}}},{key:"template",get:function(){return we('<% for (var i = 0; i < tracks.length; i++) { %>\n <track data-html5-video-track="<%= i %>" kind="<%= tracks[i].kind %>" label="<%= tracks[i].label %>" srclang="<%= tracks[i].lang %>" src="<%= tracks[i].src %>">\n<% }; %>\n')}},{key:"render",value:function(){this.options.playback.disableContextMenu&&this.$el.on("contextmenu",(function(){return!1})),this._externalTracks&&this._externalTracks.length>0&&this.$el.html(this.template({tracks:this._externalTracks})),this._ready();var e=Pe("[data-html5-video] {\n position: absolute;\n height: 100%;\n width: 100%;\n display: block; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this}}]),r}(Ge);at._mimeTypesForUrl=function(e,t,r){var i=(e.split("?")[0].match(/.*\.(.*)$/)||[])[1],n=r||i&&t[i.toLowerCase()]||[];return n.constructor===Array?n:[n]},at._canPlay=function(e,t,r,i){var n=at._mimeTypesForUrl(r,t,i),a=document.createElement(e);return!!n.filter((function(e){return!!a.canPlayType(e).replace(/no/,"")}))[0]},at.canPlay=function(e,t){return at._canPlay("audio",rt,e,t)||at._canPlay("video",tt,e,t)};var st=function(e){T(r,e);var t=L(r);function r(){return m(this,r),t.apply(this,arguments)}return A(r,[{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"tagName",get:function(){return"audio"}},{key:"isAudioOnly",get:function(){return!0}},{key:"updateSettings",value:function(){this.settings.left=["playpause","position","duration"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Te.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Ge.AOD}}]),r}(at);st.canPlay=function(e,t){return at._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},e,t)};var ot=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e)).el.src=e.src,i}return A(r,[{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"tagName",get:function(){return"img"}},{key:"attributes",get:function(){return{"data-html-img":""}}},{key:"events",get:function(){return{load:"_onLoad",abort:"_onError",error:"_onError"}}},{key:"getPlaybackType",value:function(){return Ge.NO_OP}},{key:"render",value:function(){var e=Pe("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this.trigger(Te.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(Te.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(e){var t="error"===e.type?"load error":"loading aborted";this.trigger(Te.PLAYBACK_ERROR,{message:t},this.name)}}]),r}(Ge);ot.canPlay=function(e){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(e)};var lt=function(e){T(r,e);var t=L(r);function r(){var e;m(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n)))._noiseFrameNum=-1,e}return A(r,[{key:"name",get:function(){return"no_op"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return we("<canvas data-no-op-canvas></canvas>\n<p data-no-op-msg><%=message%></p><p>\n</p>")}},{key:"attributes",get:function(){return{"data-no-op":""}}},{key:"render",value:function(){var e=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported"),t=Pe("[data-no-op] {\n position: absolute;\n height: 100%;\n width: 100%;\n text-align: center; }\n\n[data-no-op] p[data-no-op-msg] {\n position: absolute;\n text-align: center;\n font-size: 25px;\n left: 0;\n right: 0;\n color: white;\n padding: 10px;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%);\n max-height: 100%;\n overflow: auto; }\n\n[data-no-op] canvas[data-no-op-canvas] {\n background-color: #777;\n height: 100%;\n width: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});this.$el.append(t[0]),this.$el.html(this.template({message:e})),this.trigger(Te.PLAYBACK_READY,this.name);var r=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&r||this._animate(),this}},{key:"_noise",value:function(){if(this._noiseFrameNum=(this._noiseFrameNum+1)%5,!this._noiseFrameNum){var e,t=this.context.createImageData(this.context.canvas.width,this.context.canvas.height);try{e=new Uint32Array(t.data.buffer)}catch(n){e=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var r=t.data,i=0;i<r.length;i++)e[i]=r[i]}for(var n=e.length,a=6*Math.random()+4,s=0,o=0,l=0;l<n;){if(s<0)s=a*Math.random(),o=255*Math.pow(Math.random(),.4)<<24;s-=1,e[l++]=o}this.context.putImageData(t,0,0)}}},{key:"_loop",value:function(){var e=this;this._stop||(this._noise(),this._animationHandle=X((function(){return e._loop()})))}},{key:"destroy",value:function(){this._animationHandle&&($(this._animationHandle),this._stop=!0)}},{key:"_animate",value:function(){this.canvas=this.$el.find("canvas[data-no-op-canvas]")[0],this.context=this.canvas.getContext("2d"),this._loop()}}]),r}(Ge);lt.canPlay=function(e){return!0};var ut=function(e){T(r,e);var t=L(r);function r(e){var i;return m(this,r),(i=t.call(this,e))._initializeMessages(),i}return A(r,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"t",value:function(e){var t=this._language(),r=this._messages.en;return(t&&this._messages[t]||r)[e]||r[e]||e}},{key:"_language",value:function(){return this.core.options.language||ae()}},{key:"_initializeMessages",value:function(){this._messages=G.extend(!0,{en:{live:"live",back_to_live:"back to live",disabled:"Disabled",playback_not_supported:"Your browser does not support the playback of this video. Please try using a different browser.",default_error_title:"Could not play video.",default_error_message:"There was a problem trying to load the video."},de:{live:"Live",back_to_live:"Zurück zum Live-Video",disabled:"Deaktiviert",playback_not_supported:"Ihr Browser unterstützt das Playback Verfahren nicht. Bitte vesuchen Sie es mit einem anderen Browser.",default_error_title:"Video kann nicht abgespielt werden",default_error_message:"Es gab ein Problem beim Laden des Videos"},pt:{live:"ao vivo",back_to_live:"voltar para o ao vivo",disabled:"Desativado",playback_not_supported:"Seu navegador não supporta a reprodução deste video. Por favor, tente usar um navegador diferente.",default_error_title:"Não foi possível reproduzir o vídeo.",default_error_message:"Ocorreu um problema ao tentar carregar o vídeo."},es_am:{live:"vivo",back_to_live:"volver en vivo",disabled:"No disponible",playback_not_supported:"Su navegador no soporta la reproducción de este video. Por favor, utilice un navegador diferente.",default_error_title:"No se puede reproducir el video.",default_error_message:"Se ha producido un error al cargar el video."},es:{live:"en directo",back_to_live:"volver al directo",disabled:"No disponible",playback_not_supported:"Este navegador no es compatible para reproducir este vídeo. Utilice un navegador diferente.",default_error_title:"No se puede reproducir el vídeo.",default_error_message:"Se ha producido un problema al cargar el vídeo."},ru:{live:"прямой эфир",back_to_live:"к прямому эфиру",disabled:"Отключено",playback_not_supported:"Ваш браузер не поддерживает воспроизведение этого видео. Пожалуйста, попробуйте другой браузер."},bg:{live:"на живо",back_to_live:"Върни на живо",disabled:"Изключено",playback_not_supported:"Вашият браузър не поддържа възпроизвеждането на това видео. Моля, пробвайте с друг браузър.",default_error_title:"Видеото не може да се възпроизведе.",default_error_message:"Възникна проблем при зареждането на видеото."},fr:{live:"en direct",back_to_live:"retour au direct",disabled:"Désactivé",playback_not_supported:"Votre navigateur ne supporte pas la lecture de cette vidéo. Merci de tenter sur un autre navigateur.",default_error_title:"Impossible de lire la vidéo.",default_error_message:"Un problème est survenu lors du chargement de la vidéo."},tr:{live:"canlı",back_to_live:"canlı yayına dön",disabled:"Engelli",playback_not_supported:"Tarayıcınız bu videoyu oynatma desteğine sahip değil. Lütfen farklı bir tarayıcı ile deneyin."},et:{live:"Otseülekanne",back_to_live:"Tagasi otseülekande juurde",disabled:"Keelatud",playback_not_supported:"Teie brauser ei toeta selle video taasesitust. Proovige kasutada muud brauserit."},ar:{live:"مباشر",back_to_live:"الرجوع إلى المباشر",disabled:"معطّل",playback_not_supported:"المتصفح الذي تستخدمه لا يدعم تشغيل هذا الفيديو. الرجاء إستخدام متصفح آخر.",default_error_title:"غير قادر الى التشغيل.",default_error_message:"حدثت مشكلة أثناء تحميل الفيديو."},zh:{live:"直播",back_to_live:"返回直播",disabled:"已禁用",playback_not_supported:"您的浏览器不支持该视频的播放。请尝试使用另一个浏览器。",default_error_title:"无法播放视频。",default_error_message:"在尝试加载视频时出现了问题。"}},this.core.options.strings||{}),this._messages["de-DE"]=this._messages.de,this._messages["pt-BR"]=this._messages.pt,this._messages["en-US"]=this._messages.en,this._messages["bg-BG"]=this._messages.bg,this._messages["es-419"]=this._messages.es_am,this._messages["es-ES"]=this._messages.es,this._messages["fr-FR"]=this._messages.fr,this._messages["tr-TR"]=this._messages.tr,this._messages["et-EE"]=this._messages.et,this._messages["ar-IQ"]=this._messages.ar,this._messages["zh-CN"]=this._messages.zh}}]),r}(Je),ct=function(e){T(r,e);var t=L(r);function r(){return m(this,r),t.apply(this,arguments)}return A(r,[{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,Te.CORE_CONTAINERS_CREATED,this.onContainersCreated)}},{key:"onContainersCreated",value:function(){var e=this.core.containers.filter((function(e){return"no_op"!==e.playback.name}))[0]||this.core.containers[0];e&&this.core.containers.forEach((function(t){t!==e&&t.destroy()}))}}]),r}(Je);Xe.registerPlugin(ut),Xe.registerPlugin(ct),Xe.registerPlayback(lt),Xe.registerPlayback(ot),Xe.registerPlayback(st),Xe.registerPlayback(at);"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function dt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ht,ft,gt={exports:{}};ht=gt,"undefined"!=typeof window&&(ft=()=>(()=>{var e={"./src/config.ts":
|
|
2
|
+
/*!***********************!*\
|
|
3
|
+
!*** ./src/config.ts ***!
|
|
4
|
+
\***********************/(e,t,r)=>{r.r(t),r.d(t,{enableStreamingMode:()=>k,hlsDefaultConfig:()=>S,mergeConfig:()=>_});var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),a=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),d=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),h=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),g=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),p=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function A(){return A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},A.apply(this,arguments)}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var S=T(T({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:l.default,capLevelController:c.default,fpsController:d.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:v.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:s.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:n.default,audioTrackController:a.default,emeController:h.default,cmcdController:f.default});function _(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return A({},e,t)}function k(e){var t=e.loader;t!==p.default&&t!==g.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):(0,p.fetchSupported)()&&(e.loader=p.default,e.progressive=!0,e.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
5
|
+
/*!******************************************!*\
|
|
6
|
+
!*** ./src/controller/abr-controller.ts ***!
|
|
7
|
+
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../types/loader */"./src/types/loader.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var c=function(){function e(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new n.default(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t,r,c,d=e.prototype;return d.registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(e,t){var r,i=t.frag;i.type===o.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},d.onLevelLoaded=function(e,t){var r=this.hls.config;t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.autoLevelEnabled;r.config;var s=r.media;if(e&&s){var o=t?t.stats:e.stats,u=t?t.duration:e.duration;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!s.paused&&s.playbackRate&&s.readyState){var c=r.mainForwardBufferInfo;if(null!==c){var d=performance.now()-o.loading.start,h=Math.abs(s.playbackRate);if(!(d<=500*u/h)){var f=o.loaded&&o.loading.first,g=this.bwEstimator.getEstimate(),p=r.levels,v=r.minAutoLevel,m=p[e.level],y=o.total||Math.max(o.loaded,Math.round(u*m.maxBitrate/8)),A=f?1e3*o.loaded/d:0,E=A?(y-o.loaded)/A:8*y/g,T=c.len/h;if(!(E<=T)){var b,S=Number.POSITIVE_INFINITY;for(b=e.level-1;b>v;b--){var _=p[b].maxBitrate;if((S=A?u*_/(6.4*A):u*_/g)<T)break}S>=E||(l.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+((0,i.isFiniteNumber)(g)?(g/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+E.toFixed(3)+" s\n Estimated load time for the next fragment: "+S.toFixed(3)+" s\n Time to underbuffer: "+T.toFixed(3)+" s"),r.nextLoadLevel=b,f&&this.bwEstimator.sample(d,o.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),r.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}}}}}},d.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if(r.type===o.PlaylistLevelType.MAIN&&(0,i.isFiniteNumber)(r.sn)){var s=n?n.stats:r.stats,l=n?n.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,d=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:d},u.realBitrate=Math.round(8*c/d)}if(r.bitrateTest){var h={stats:s,frag:r,part:n,id:r.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,h)}}},d.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===o.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var a=n.parsing.end-n.loading.start;this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},d.onError=function(e,t){switch(t.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=r.media,o=t?t.duration:e?e.duration:0;s&&s.currentTime;var u=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,h=(d?d.len:0)/u,f=this.findBestLevel(c,a,i,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;l.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,p=n.abrBandWidthFactor,v=n.abrBandWidthUpFactor;if(!h){var m=this.bitrateTestDelay;m&&(g=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-m,l.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),p=v=1)}return f=this.findBestLevel(c,a,i,h+g,p,v),Math.max(f,0)},d.findBestLevel=function(e,t,r,n,a,s){for(var o,u=this.fragCurrent,c=this.partCurrent,d=this.lastLoadedFragLevel,h=this.hls.levels,f=h[d],g=!(null==f||null===(o=f.details)||void 0===o||!o.live),p=null==f?void 0:f.codecSet,v=c?c.duration:u?u.duration:0,m=r;m>=t;m--){var y=h[m];if(y&&(!p||y.codecSet===p)){var A=y.details,E=(c?null==A?void 0:A.partTarget:null==A?void 0:A.averagetargetduration)||v,T=void 0;T=m<=d?a*e:s*e;var b=h[m].maxBitrate,S=b*E/T;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(T)+"/"+b+"/"+E+"/"+n+"/"+S),T>b&&(0===S||!(0,i.isFiniteNumber)(S)||g&&!this.bitrateTestDelay||S<n))return m}}return-1},t=e,(r=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();return-1!==e&&this.hls.levels[r].loadError?e:(-1!==e&&(r=Math.min(e,r)),r)},set:function(e){this._nextAutoLevel=e}}])&&u(t.prototype,r),c&&u(t,c),Object.defineProperty(t,"prototype",{writable:!1}),e}();const d=c},"./src/controller/audio-stream-controller.ts":
|
|
8
|
+
/*!***************************************************!*\
|
|
9
|
+
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
10
|
+
\***************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>E});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),h=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),g=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=r(/*! ../errors */"./src/errors.ts");function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},m.apply(this,arguments)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}var A=function(e){var t,r;function A(t,r){var i;return(i=e.call(this,t,r,"[audio-stream-controller]")||this).videoBuffer=null,i.videoTrackCC=-1,i.waitingVideoCC=-1,i.audioSwitch=!1,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i.bufferFlushed=!1,i.cachedTrackLoadedData=null,i._registerListeners(),i}r=e,(t=A).prototype=Object.create(r.prototype),t.prototype.constructor=t,y(t,r);var E=A.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._registerListeners=function(){var e=this.hls;e.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(a.Events.ERROR,this.onError,this),e.on(a.Events.BUFFER_RESET,this.onBufferReset,this),e.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var e=this.hls;e.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(a.Events.ERROR,this.onError,this),e.off(a.Events.BUFFER_RESET,this.onBufferReset,this),e.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(e,t){var r=t.frag,i=t.id,a=t.initPTS;if("main"===i){var s=r.cc;this.initPTS[r.cc]=a,this.log("InitPTS for cc: "+s+" found from main: "+a),this.videoTrackCC=s,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},E.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=n.State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},E.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var t,r=this.levels,i=this.trackId,a=null==r||null===(t=r[i])||void 0===t?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var c=this.waitingData;if(c){var d=c.frag,h=c.part,f=c.cache,p=c.complete;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var v={frag:d,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),p&&e.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),y=s.BufferHelper.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);(0,g.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,d)<0&&(this.log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},E.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},E.resetLoadingState=function(){this.clearWaitingFragment(),e.prototype.resetLoadingState.call(this)},E.onTickEnd=function(){var e=this.media;e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},E.doTickIdle=function(){var e,t,r=this.hls,i=this.levels,s=this.media,o=this.trackId,l=r.config;if(i&&i[o]&&(s||!this.startFragRequested&&l.startFragPrefetch)){var d=i[o].details;if(!d||d.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(d))this.state=n.State.WAITING_TRACK;else{var h=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&h&&(this.bufferFlushed=!1,this.afterBufferFlushed(h,c.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(h,u.PlaylistLevelType.AUDIO);if(null!==f){var g=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN),p=f.len,v=this.getMaxBufferLength(null==g?void 0:g.len),m=this.audioSwitch;if(!(p>=v)||m){if(!m&&this._streamEnded(f,d))return r.trigger(a.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var y=d.fragments[0].start,A=f.end;if(m&&s){var E=this.getLoadPosition();A=E,d.PTSKnown&&E<y&&(f.end>y||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=y+.05)}if(!(g&&A>g.end+d.targetduration)&&(g&&g.len||!f.len)){var T=this.getNextFragment(A,d);T?"identity"!==(null===(e=T.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=T.decryptdata)&&void 0!==t&&t.key?this.loadFragment(T,d,A):this.loadKey(T,d):this.bufferFlushed=!0}}}}}},E.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},E.onMediaDetaching=function(){this.videoBuffer=null,e.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(e){return new l.Level(e)}))},E.onAudioTrackSwitching=function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;null!=i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(a.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},E.onAudioTrackLoaded=function(e,t){var r;if(null!=this.mainDetails){var i=this.levels,a=t.details,s=t.id;if(i){this.log("Track "+s+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var o=i[s],l=0;if(a.live||null!==(r=o.details)&&void 0!==r&&r.live){var u=this.mainDetails;if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed||!u)return;!o.details&&a.hasProgramDateTime&&u.hasProgramDateTime?((0,p.alignMediaPlaylistByPDT)(a,u),l=a.fragments[0].start):l=this.alignPlaylists(a,o.details)}o.details=a,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(o.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=n.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)}else this.cachedTrackLoadedData=t},E._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,a=e.payload,s=this.config,o=this.trackId,l=this.levels;if(l){var c=l[o];console.assert(c,"Audio track is defined on fragment load progress");var g=c.details;console.assert(g,"Audio track details are defined on fragment load progress");var p=s.defaultAudioCodec||c.audioCodec||"mp4a.40.2",v=this.transmuxer;v||(v=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],y=null===(t=r.initSegment)||void 0===t?void 0:t.data;if(void 0!==m){var A=i?i.index:-1,E=-1!==A,T=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,A,E);v.push(a,y,p,"",r,i,g.totalduration,!1,T,m)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+g.startSN+" ,"+g.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new d.default,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},E._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)},E.onFragBuffered=function(e,t){var r,i=t.frag,n=t.part;i.type===u.PlaylistLevelType.AUDIO?this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(n?" p: "+n.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,n)):this.loadedmetadata||i.type!==u.PlaylistLevelType.MAIN||null!==(r=this.videoBuffer||this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},E.onError=function(t,r){switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=r.fatal?n.State.ERROR:n.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var i=!0,a=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);a&&a.len>.5&&(i=!this.reduceMaxBufferLength(a.len)),i&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},E.onBufferFlushed=function(e,t){t.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(e){var t,r="audio",i=this.hls,s=e.remuxResult,o=e.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(o.level);var u=l.frag,d=l.part,h=l.level.details,f=s.audio,g=s.text,p=s.id3,v=s.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=n.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=v&&v.tracks&&(this._bufferInitSegment(v.tracks,u,o),i.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:v.tracks})),f){var y=f.startPTS,A=f.endPTS,E=f.startDTS,T=f.endDTS;d&&(d.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:y,endPTS:A,startDTS:E,endDTS:T}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,y,A,E,T),this.bufferFragmentData(f,u,d,o)}if(null!=p&&null!==(t=p.samples)&&void 0!==t&&t.length){var b=m({id:r,frag:u,details:h},p);i.trigger(a.Events.FRAG_PARSING_METADATA,b)}if(g){var S=m({id:r,frag:u,details:h},g);i.trigger(a.Events.FRAG_PARSING_USERDATA,S)}}},E._bufferInitSegment=function(e,t,r){if(this.state===n.State.PARSING){e.video&&delete e.video;var i=e.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:"+i.container+", codecs[parsed]=["+i.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e);var s=i.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:s};this.hls.trigger(a.Events.BUFFER_APPENDING,o)}this.tick()}}},E.loadFragment=function(t,r,a){var s=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||s===o.FragmentState.NOT_LOADED||s===o.FragmentState.PARTIAL)&&("initSegment"===t.sn?this._loadInitSegment(t):r.live&&!(0,i.isFiniteNumber)(this.initPTS[t.cc])?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,a)))},E.completeAudioSwitch=function(){var t=this.hls,r=this.media,i=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:i})},A}(n.default);const E=A},"./src/controller/audio-track-controller.ts":
|
|
11
|
+
/*!**************************************************!*\
|
|
12
|
+
!*** ./src/controller/audio-track-controller.ts ***!
|
|
13
|
+
\**************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,c,d,h=a.prototype;return h.registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(i.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(i.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,e.prototype.destroy.call(this)},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},h.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},h.onAudioTrackLoaded=function(e,t){var r=t.id,i=t.details,n=this.tracksInGroup[r];if(n){var a=n.details;n.details=t.details,this.log("audioTrack "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,a))}else this.warn("Invalid audio track id "+r)},h.onLevelLoading=function(e,t){this.switchLevel(t.level)},h.onLevelSwitching=function(e,t){this.switchLevel(t.level)},h.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r;var n=this.tracks.filter((function(e){return!r||e.groupId===r}));this.selectDefaultTrack&&!n.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var a={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},h.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},h.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=t[this.trackId];this.log("Now switching to audio-track index "+e);var n=t[e],a=n.id,s=n.groupId,o=void 0===s?"":s,l=n.name,u=n.type,c=n.url;if(this.trackId=e,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(i.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:l,type:u,url:c}),!n.details||n.details.live){var d=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(d)}}},h.selectInitialTrack=function(){var e=this.tracksInGroup;console.assert(e.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,r=this.findTrackId(t)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},h.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1},h.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,n=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(i.Events.AUDIO_TRACK_LOADING,{url:a,id:r,groupId:n,deliveryDirectives:e||null})}},u=a,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}])&&o(u.prototype,c),d&&o(u,d),Object.defineProperty(u,"prototype",{writable:!1}),a}(a.default);const c=u},"./src/controller/base-playlist-controller.ts":
|
|
14
|
+
/*!****************************************************!*\
|
|
15
|
+
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
16
|
+
\****************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/level */"./src/types/level.ts"),a=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,t+":"),this.warn=s.logger.warn.bind(s.logger,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){t.fatal&&t.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var r=null==t?void 0:t.renditionReports;if(r)for(var a=0;a<r.length;a++){var s=r[a],o=""+s.URI;if(o===e.slice(-o.length)){var l=parseInt(s["LAST-MSN"]),u=parseInt(s["LAST-PART"]);if(t&&this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);void 0!==u&&c>t.partTarget&&(u+=1)}if((0,i.isFiniteNumber)(l))return new n.HlsUrlParameters(l,(0,i.isFiniteNumber)(u)?u:void 0,n.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,s=t.stats,o=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&n.fragments.length>0&&(0,a.mergeDetails)(r,n),!this.canLoad||!n.live)return;var l,u=void 0,c=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var d=this.hls.config.lowLatencyMode,h=n.lastPartSn,f=n.endSN,g=n.lastPartIndex,p=h===f;-1!==g?(u=p?f+1:h,c=p?d?0:g:g+1):u=f+1;var v=n.age,m=v+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var A=Math.floor(y/n.targetduration);u+=A,void 0!==c&&(c+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+y+" skip sn "+A+" to part "+c)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,t.deliveryDirectives,u,c),d||!p)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,t.deliveryDirectives,u,c);var E=(0,a.computeReloadInterval)(n,s);void 0!==u&&n.canBlockReload&&(E-=n.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(E)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),E)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var a=(0,n.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=n.HlsSkip.No),new n.HlsUrlParameters(r,i,a)},t.retryLoadingOrFail=function(e){var t,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n)if(this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&null!==(t=e.context)&&void 0!==t&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return n},e}()},"./src/controller/base-stream-controller.ts":
|
|
17
|
+
/*!**************************************************!*\
|
|
18
|
+
!*** ./src/controller/base-stream-controller.ts ***!
|
|
19
|
+
\**************************************************/(e,t,r)=>{r.r(t),r.d(t,{State:()=>b,default:()=>S});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../task-loop */"./src/task-loop.ts"),a=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ./level-helper */"./src/controller/level-helper.ts"),p=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function A(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}var b={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},S=function(e){var t,r;function n(t,r,i){var n;return(n=e.call(this)||this).hls=void 0,n.fragPrevious=null,n.fragCurrent=null,n.fragmentTracker=void 0,n.transmuxer=null,n._state=b.STOPPED,n.media=null,n.mediaBuffer=null,n.config=void 0,n.bitrateTest=!1,n.lastCurrentTime=0,n.nextLoadPosition=0,n.startPosition=0,n.loadedmetadata=!1,n.fragLoadError=0,n.retryDate=0,n.levels=null,n.fragmentLoader=void 0,n.levelLastLoaded=null,n.startFragRequested=!1,n.decrypter=void 0,n.initPTS=[],n.onvseeking=null,n.onvended=null,n.logPrefix="",n.log=void 0,n.warn=void 0,n.logPrefix=i,n.log=o.logger.log.bind(o.logger,i+":"),n.warn=o.logger.warn.bind(o.logger,i+":"),n.hls=t,n.fragmentLoader=new p.default(t.config),n.fragmentTracker=r,n.config=t.config,n.decrypter=new v.default(t,t.config),t.on(l.Events.KEY_LOADED,n.onKeyLoaded,E(n)),t.on(l.Events.LEVEL_SWITCHING,n.onLevelSwitching,E(n)),n}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,T(t,r);var S,_,k,L=n.prototype;return L.doTick=function(){this.onTickEnd()},L.onTickEnd=function(){},L.startLoad=function(e){},L.stopLoad=function(){this.fragmentLoader.abort();var e=this.fragCurrent;e&&this.fragmentTracker.removeFragment(e),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=b.STOPPED},L._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&this.media&&r.sn>=t.endSN&&!e.nextStart){var n=t.partList;if(null!=n&&n.length){var o=n[n.length-1];return s.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var l=i.getState(r);return l===a.FragmentState.PARTIAL||l===a.FragmentState.OK}return!1},L.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===b.STOPPED&&this.startLoad(i.startPosition)},L.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},L.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,n=this.mediaBuffer,a=this.state,o=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(n||r,o,e.maxBufferHole);if(this.log("media seeking to "+((0,i.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+a),a===b.ENDED)this.resetLoadingState();else if(t){var u=e.maxFragLookUpTolerance,c=t.start-u,d=t.start+t.duration+u;if(!l.len||d<l.start||c>l.end){var h=o>d;(o<c||h)&&(h&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.loader.abort()),this.resetLoadingState())}}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},L.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},L.onKeyLoaded=function(e,t){if(this.state===b.KEY_LOADING&&t.frag===this.fragCurrent&&this.levels){this.state=b.IDLE;var r=this.levels[t.frag.level].details;r&&this.loadFragment(t.frag,r,t.frag.start)}},L.onLevelSwitching=function(e,t){this.fragLoadError=0},L.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},L.onHandlerDestroyed=function(){this.state=b.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},L.loadKey=function(e,t){this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=b.KEY_LOADING,this.fragCurrent=e,this.hls.trigger(l.Events.KEY_LOADING,{frag:e})},L.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},L._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){i.fragLoadError=0;var r=i.state;i.fragContextChanged(e)?(r===b.FRAG_LOADING||!i.fragCurrent&&r===b.PARSING)&&(i.fragmentTracker.removeFragment(e),i.state=b.IDLE):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(l.Events.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==b.STOPPED&&i.state!==b.ERROR&&(i.warn(t),i.resetFragmentLoading(e))}))},L.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},L._loadInitSegment=function(e){var t=this;this._doFragLoad(e).then((function(r){if(!r||t.fragContextChanged(e)||!t.levels)throw new Error("init load aborted");return r})).then((function(r){var i=t.hls,n=r.payload,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return t.decrypter.webCryptoDecrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).then((function(t){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:s,tdecrypt:n}}),r.payload=t,r}))}return r})).then((function(r){var i=t.fragCurrent,n=t.hls,a=t.levels;if(!a)throw new Error("init load aborted, missing levels");var s=a[e.level].details;console.assert(s,"Level details are defined when init segment is loaded");var o=e.stats;t.state=b.IDLE,t.fragLoadError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:e.type}),t.tick()})).catch((function(r){t.state!==b.STOPPED&&t.state!==b.ERROR&&(t.warn(r),t.resetFragmentLoading(e))}))},L.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},L.fragBufferedComplete=function(e,t){var r,i,n=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" "+(n?m.default.toString(s.BufferHelper.getBuffered(n)):"(detached)")),this.state=b.IDLE,n&&(!this.loadedmetadata&&e.type==y.PlaylistLevelType.MAIN&&n.buffered.length&&(null===(r=this.fragCurrent)||void 0===r?void 0:r.sn)===(null===(i=this.fragPrevious)||void 0===i?void 0:i.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},L.seekToStartPos=function(){},L._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new c.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},L._handleFragmentLoadProgress=function(e){},L._doFragLoad=function(e,t,r,n){var a=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var s=t.partList;if(s&&n){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var o=this.getNextPart(s,e,r);if(o>-1){var u=s[o];return this.log("Loading part sn: "+e.sn+" p: "+u.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+o+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=b.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,part:s[o],targetBufferTime:r}),this.doFragPartsLoad(e,s,o,n).catch((function(e){return a.handleFragLoadError(e)}))}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}return this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),(0,i.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=b.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragmentLoader.load(e,n).catch((function(e){return a.handleFragLoadError(e)}))},L.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o=[];!function r(u){var c=t[u];n.fragmentLoader.loadPart(e,c,i).then((function(i){o[c.index]=i;var s=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var d=t[u+1];if(!d||d.fragment!==e)return a({frag:e,part:s,partsLoaded:o});r(u+1)})).catch(s)}(r)}))},L.handleFragLoadError=function(e){var t=e.data;return t&&t.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(l.Events.ERROR,t),null},L._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===b.PARSING){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||(this.state=b.IDLE)},L.getCurrentContext=function(e){var t=this.levels,r=e.level,i=e.sn,n=e.part;if(!t||!t[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var a=t[r],s=n>-1?(0,g.getPartWith)(a,i,n):null,o=s?s.fragment:(0,g.getFragmentWithSN)(a,i,this.fragCurrent);return o?{frag:o,part:s,level:a}:null},L.bufferFragmentData=function(e,t,r,i){if(e&&this.state===b.PARSING){var n=e.data1,a=e.data2,s=n;if(n&&a&&(s=(0,d.appendUint8Array)(n,a)),s&&s.length){var o={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,o),e.dropped&&e.independent&&!r&&this.flushBufferGap(t)}}},L.flushBufferGap=function(e){var t=this.media;if(t)if(s.BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,i=s.BufferHelper.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},L.getFwdBufferInfo=function(e,t){var r=this.config,n=this.getLoadPosition();if(!(0,i.isFiniteNumber)(n))return null;var a=s.BufferHelper.bufferInfo(e,n,r.maxBufferHole);if(0===a.len&&void 0!==a.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,t);if(o&&a.nextStart<o.end)return s.BufferHelper.bufferInfo(e,n,Math.max(a.nextStart,r.maxBufferHole))}return a},L.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},L.reduceMaxBufferLength=function(e){var t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},L.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(t,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var l=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(n)},L.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},L.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;!u&&(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i},L.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},L.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=(0,f.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=(0,f.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},L.getFragmentAtPosition=function(e,t,r){var i,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=n.maxFragLookUpTolerance,d=!!(n.lowLatencyMode&&r.partList&&u);if(d&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),e<t){var h=e>t-c?0:c;i=(0,f.findFragmentByPTS)(s,o,e,h)}else i=o[o.length-1];if(i){var g=i.sn-r.startSN;if(this.fragmentTracker.getState(i)===a.FragmentState.OK&&(s=i),s&&i.sn===s.sn&&!d&&s&&i.level===s.level){var p=o[g+1];i.sn<l&&this.fragmentTracker.getState(p)!==a.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+p.sn),i=p):i=null}}return i},L.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},L.alignPlaylists=function(e,t){var r=this.levels,n=this.levelLastLoaded,a=this.fragPrevious,s=null!==n?r[n]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=e.fragments[0].start,u=!t,c=e.alignedSliding&&(0,i.isFiniteNumber)(l);if(u||!c&&!l){(0,h.alignStream)(a,s,e);var d=e.fragments[0].start;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o),d}return l},L.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},L.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=e.startTimeOffset;(0,i.isFiniteNumber)(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},L.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},L.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part"+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},L.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===b.FRAG_LOADING_WAITING_RETRY)||(this.state=b.IDLE)},L.onFragmentOrKeyLoadError=function(e,t){if(!t.fatal){var r=t.frag;if(r&&r.type===e){var i=this.fragCurrent;console.assert(i&&r.sn===i.sn&&r.level===i.level&&r.urlId===i.urlId,"Frag load error must match current frag to retry");var n=this.config;if(this.fragLoadError+1<=n.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var a=Math.min(Math.pow(2,this.fragLoadError)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=b.FRAG_LOADING_WAITING_RETRY}else t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=b.IDLE):(o.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=b.ERROR)}}},L.afterBufferFlushed=function(e,t,r){if(e){var i=s.BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===b.ENDED&&this.resetLoadingState()}},L.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=b.IDLE},L.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},L.updateLevelTiming=function(e,t,r,i){var n=this,a=r.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return n.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+u+")"),t||!1;var c=i?0:(0,g.updateFragPTSDTS)(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:r,drift:c,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)||(this.warn("Found no media in fragment "+e.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=b.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:e,part:t})},L.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S=n,(_=[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])&&A(S.prototype,_),k&&A(S,k),Object.defineProperty(S,"prototype",{writable:!1}),n}(n.default)},"./src/controller/buffer-controller.ts":
|
|
2
20
|
/*!*********************************************!*\
|
|
3
|
-
!*** ./
|
|
4
|
-
\*********************************************/
|
|
5
|
-
/*! no static exports found */
|
|
6
|
-
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){var i=Object.prototype.hasOwnProperty,n="~";function a(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new s(r,i||e,a),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function u(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,s=new Array(a);i<a;i++)s[i]=r[i].fn;return s},u.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,i,a,s){var o=n?n+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,r),!0;case 4:return c.fn.call(c.context,t,r,i),!0;case 5:return c.fn.call(c.context,t,r,i,a),!0;case 6:return c.fn.call(c.context,t,r,i,a,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var h,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,r);break;case 4:c[u].fn.call(c[u].context,t,r,i);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c[u].fn.apply(c[u].context,l)}}return!0},u.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,i){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return l(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||i&&!s.once||r&&s.context!==r||l(this,a);else{for(var o=0,u=[],c=s.length;o<c;o++)(s[o].fn!==t||i&&!s[o].once||r&&s[o].context!==r)&&u.push(s[o]);u.length?this._events[a]=1===u.length?u[0]:u:l(this,a)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&l(this,t)):(this._events=new a,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=n,u.EventEmitter=u,e.exports=u},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
7
|
-
/*!*****************************************************!*\
|
|
8
|
-
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
9
|
-
\*****************************************************/
|
|
10
|
-
/*! no static exports found */
|
|
11
|
-
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){var i,n,a,s,o;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=o.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=n.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var c=s.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=o.normalizePath(d)}else u.path=s.path,a.params||(u.params=s.params,a.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(a.path):a.path),o.buildURLFromParts(u)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o},"./node_modules/webworkify-webpack/index.js":
|
|
21
|
+
!*** ./src/controller/buffer-controller.ts ***!
|
|
22
|
+
\*********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),d=(0,l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.hls,r=t.media,i=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),r&&(t.updateMediaElementDuration(),e.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.BUFFER_RESET,this.onBufferReset,this),e.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(n.Events.BUFFER_EOS,this.onBufferEos,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(n.Events.FRAG_PARSED,this.onFragParsed,this),e.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.BUFFER_RESET,this.onBufferReset,this),e.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(n.Events.BUFFER_EOS,this.onBufferEos,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(n.Events.FRAG_PARSED,this.onFragParsed,this),e.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&d){var i=this.mediaSource=new d;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(e){a.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var s=t[e],o=s.id,l=s.codec,u=s.levelCodec,c=s.container,d=s.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),g=(u||l).replace(h,"$1");if(f!==g){var p=c+";codecs="+(u||l);r.appendChangeType(e,p),a.logger.log("[buffer-controller]: switching codec "+f+" to "+g),r.tracks[e]={buffer:n.buffer,codec:l,container:c,levelCodec:u,metadata:d,id:o}}}}else r.pendingTracks[e]=t[e]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e)},t.onBufferAppending=function(e,t){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,c=t.data,d=t.type,h=t.frag,f=t.part,g=t.chunkMeta,p=g.buffering[d],v=self.performance.now();p.start=v;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);var A=u.audio,E="audio"===d&&1===g.id&&"audio/mpeg"===(null==A?void 0:A.container),T={execute:function(){if(p.executeStart=self.performance.now(),E){var e=r.sourceBuffer[d];if(e){var t=h.start-e.timestampOffset;Math.abs(t)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+t+") sn: "+h.sn+")"),e.timestampOffset=h.start)}}r.appendExecutor(c,d)},onStart:function(){},onComplete:function(){var e=self.performance.now();p.executeEnd=p.end=e,0===m.first&&(m.first=e),y&&0===y.first&&(y.first=e);var t=r.sourceBuffer,i={};for(var a in t)i[a]=o.BufferHelper.getBuffered(t[a]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:d,frag:h,part:f,chunkMeta:g,parent:h.type,timeRanges:i})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",e);var t={type:s.ErrorTypes.MEDIA_ERROR,parent:h.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,t.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0,i.stopLoad())),i.trigger(n.Events.ERROR,t)}};l.append(T,d)},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,s=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(s(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})}),o)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return t.type&&t.type!==i||n&&!n.ended&&(n.ended=!0,a.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),e&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var e=r.mediaSource;e&&"open"===e.readyState&&e.endOfStream()}))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==t){var s=this.getSourceBufferTypes();if(s.length){var l=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,i.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,c=t.levelTargetDuration,d=Math.max(l,c),h=Math.floor(u/c)*c-d;s.forEach((function(r){var i=a[r];if(i){var s=o.BufferHelper.getBuffered(i);s.length>0&&h>s.start(0)&&(e.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),t.live&&e.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),e.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:r}))}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,n=this.mediaSource,s=e.fragments[0].start+e.totalduration,o=r.duration,l=(0,i.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(s>l&&s>o||!(0,i.isFiniteNumber)(o))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),n.duration=s)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(0===a.length)return void this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(e){t.executeNext(e)}))}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in e)if(!t[o]){var l=e[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,c=l.container+";codecs="+u;a.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var d=t[o]=r.addSourceBuffer(c),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:d,codec:u,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id},i++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:c})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(e);r&&r.onError(t)},t.removeExecutor=function(e,t,r){var n=this.media,s=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!n||!s||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=(0,i.isFiniteNumber)(n.duration)?n.duration:1/0,c=(0,i.isFiniteNumber)(s.duration)?s.duration:1/0,d=Math.max(0,t),h=Math.min(r,u,c);h>d?(a.logger.log("[buffer-controller]: Removing ["+d+","+h+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(d,h)):o.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,console.assert(!i.updating,t+" sourceBuffer must not be updating"),i.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}()},"./src/controller/buffer-operation-queue.ts":
|
|
12
23
|
/*!**************************************************!*\
|
|
13
|
-
!*** ./
|
|
14
|
-
\**************************************************/
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
25
|
+
\**************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t){var r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.buffers,r=this.queues,n=t[e],a=r[e];if(a.length){var s=a[0];try{s.execute()}catch(t){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(t),n&&n.updating||(a.shift(),this.executeNext(e))}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}()},"./src/controller/cap-level-controller.ts":
|
|
26
|
+
/*!************************************************!*\
|
|
27
|
+
!*** ./src/controller/cap-level-controller.ts ***!
|
|
28
|
+
\************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t,r,a,s=e.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){e.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(i,n){return e.isLevelAllowed(n,r.restrictedLevels)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},e.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},e.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,n,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(i=o,!(n=e[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},t=e,(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();const s=a},"./src/controller/cmcd-controller.ts":
|
|
29
|
+
/*!*******************************************!*\
|
|
30
|
+
!*** ./src/controller/cmcd-controller.ts ***!
|
|
31
|
+
\*******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}var h=function(){function e(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:n.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(e){s.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,i=r.hls.levels[t.level],a=r.getObjectType(t),o={d:1e3*t.duration,ot:a};a!==n.CMCDObjectType.VIDEO&&a!==n.CMCDObjectType.AUDIO&&a!=n.CMCDObjectType.MUXED||(o.br=i.bitrate/1e3,o.tb=r.getTopBandwidth(a)/1e3,o.bl=r.getBufferLength(a)),r.apply(e,o)}catch(e){s.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,a=i.cmcd;null!=a&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||e.uuid(),this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(i.Events.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(i.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},t.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var r,i;this.audioBuffer=null===(r=t.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(i=t.tracks.video)||void 0===i?void 0:i.buffer},t.createData=function(){var e;return{v:n.CMCDVersion,sf:n.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(e=this.media)||void 0===e?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(t,r){void 0===r&&(r={}),d(r,this.createData());var i=r.ot===n.CMCDObjectType.INIT||r.ot===n.CMCDObjectType.VIDEO||r.ot===n.CMCDObjectType.MUXED;if(this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var a=e.toHeaders(r);if(!Object.keys(a).length)return;t.headers||(t.headers={}),d(t.headers,a)}else{var s=e.toQuery(r);if(!s)return;t.url=e.appendQueryToUri(t.url,s)}},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?n.CMCDObjectType.TIMED_TEXT:"initSegment"===e.sn?n.CMCDObjectType.INIT:"audio"===t?n.CMCDObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?n.CMCDObjectType.VIDEO:n.CMCDObjectType.MUXED:void 0},t.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===n.CMCDObjectType.AUDIO)t=i.audioTracks;else{var a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=i.levels.slice(0,s)}for(var o,l=u(t);!(o=l()).done;){var c=o.value;c.bitrate>r&&(r=c.bitrate)}return r>0?r:NaN},t.getBufferLength=function(e){var t=this.hls.media,r=e===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*a.BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var i=e.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(e,r,i){t(e),this.loader.load(e,r,i)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var i=e.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(e,r,i){t(e),this.loader.load(e,r,i)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},e.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},e.serialize=function(e){for(var t,r=[],i=function(e){return!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e},n=function(e){return Math.round(e)},a=function(e){return 100*n(e/100)},s={br:n,d:n,bl:a,dl:a,mtp:a,nor:function(e){return encodeURIComponent(e)},rtp:a,tb:n},o=u(Object.keys(e||{}).sort());!(t=o()).done;){var l=t.value,c=e[l];if(i(c)&&!("v"===l&&1===c||"pr"==l&&1===c)){var d=s[l];d&&(c=d(c));var h=typeof c,f=void 0;f="ot"===l||"sf"===l||"st"===l?l+"="+c:"boolean"===h?l:"number"===h?l+"="+c:l+"="+JSON.stringify(c),r.push(f)}}return r.join(",")},e.toHeaders=function(t){for(var r={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},s=0,o=Object.keys(t);s<o.length;s++){var l=o[s];n[null!=a[l]?a[l]:1][l]=t[l]}for(var u=0;u<n.length;u++){var c=e.serialize(n[u]);c&&(r["CMCD-"+i[u]]=c)}return r},e.toQuery=function(t){return"CMCD="+encodeURIComponent(e.serialize(t))},e.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},e}()},"./src/controller/eme-controller.ts":
|
|
32
|
+
/*!******************************************!*\
|
|
33
|
+
!*** ./src/controller/eme-controller.ts ***!
|
|
34
|
+
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var l=function(){function e(e){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=e,this._config=e.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var t,r,l,u=e.prototype;return u.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},u._registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u._unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u.getLicenseServerUrl=function(e){switch(e){case s.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},u._attemptKeySystemAccess=function(e,t,r){var i=this,n=function(e,t,r,i){if(e===s.KeySystems.WIDEVINE)return function(e,t,r){var i={audioCapabilities:[],videoCapabilities:[]};return e.forEach((function(e){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||""})})),t.forEach((function(e){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||""})})),[i]}(t,r,i);throw new Error("Unknown key-system: "+e)}(e,t,r,this._drmSystemOptions);a.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(e,n);this.mediaKeysPromise=o.then((function(t){return i._onMediaKeySystemAccessObtained(e,t)})),o.catch((function(t){a.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))},u._onMediaKeySystemAccessObtained=function(e,t){var r=this;a.logger.log('Access for key-system "'+e+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(i);var n=Promise.resolve().then((function(){return t.createMediaKeys()})).then((function(t){return i.mediaKeys=t,a.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated(),t}));return n.catch((function(e){a.logger.error("Failed to create media-keys:",e)})),n},u._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},u._onNewMediaKeySession=function(e){var t=this;a.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},u._onKeySessionMessage=function(e,t){a.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){a.logger.log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t).catch((function(e){a.logger.warn("Updating key-session failed: "+e)}))}))},u.onMediaEncrypted=function(e){var t=this;if(a.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),!this.mediaKeysPromise)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){t._media&&(t._attemptSetMediaKeys(r),t._generateRequestWithPreferredKeySession(e.initDataType,e.initData))};this.mediaKeysPromise.then(r).catch(r)},u._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});a.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},u._generateRequestWithPreferredKeySession=function(e,t){var r=this,s=this._mediaKeysList[0];if(!s)return a.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(s.mediaKeysSessionInitialized)a.logger.warn("Key-Session already initialized but requested again");else{var o=s.mediaKeysSession;if(!o)return a.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return a.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});a.logger.log('Generating key-session request for "'+e+'" init data type'),s.mediaKeysSessionInitialized=!0,o.generateRequest(e,t).then((function(){a.logger.debug("Key-session generation succeeded")})).catch((function(e){a.logger.error("Error generating key-session request:",e),r.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},u._createLicenseXhr=function(e,t,r){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,e,t,r);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,i,e),n=void 0}catch(e){a.logger.error(e)}try{i.readyState||i.open("POST",e,!0),n&&n.call(this.hls,i,e)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return i},u._onLicenseRequestReadyStageChange=function(e,t,r,s){if(4===e.readyState)if(200===e.status){this._requestLicenseFailureCount=0,a.logger.log("License request succeeded");var o=e.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,e,t)}catch(e){a.logger.error(e)}s(o)}else{if(a.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var u=3-this._requestLicenseFailureCount+1;a.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(r,s)}},u._generateLicenseRequestChallenge=function(e,t){if(e.mediaKeySystemDomain===s.KeySystems.WIDEVINE)return t;throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},u._requestLicense=function(e,t){a.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return a.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var s=this.getLicenseServerUrl(r.mediaKeySystemDomain),o=this._createLicenseXhr(s,e,t);a.logger.log("Sending license request to URL: "+s);var l=this._generateLicenseRequestChallenge(r,e);o.send(l)}catch(e){a.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},u.onMediaAttached=function(e,t){if(this._emeEnabled){var r=t.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},u.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},u.onManifestParsed=function(e,t){if(this._emeEnabled){var r=t.levels.map((function(e){return e.audioCodec})).filter((function(e){return!!e})),i=t.levels.map((function(e){return e.videoCodec})).filter((function(e){return!!e}));this._attemptKeySystemAccess(s.KeySystems.WIDEVINE,r,i)}},t=e,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(t.prototype,r),l&&o(t,l),Object.defineProperty(t,"prototype",{writable:!1}),e}();const u=l},"./src/controller/fps-controller.ts":
|
|
35
|
+
/*!******************************************!*\
|
|
36
|
+
!*** ./src/controller/fps-controller.ts ***!
|
|
37
|
+
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var a=performance.now();if(t){if(this.lastTime){var s=a-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/s,c=this.hls;if(c.trigger(i.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>c.config.fpsDroppedMonitoringThreshold*l){var d=c.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===c.autoLevelCapping||c.autoLevelCapping>=d)&&(d-=1,c.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}();const s=a},"./src/controller/fragment-finders.ts":
|
|
17
38
|
/*!********************************************!*\
|
|
18
|
-
!*** ./src/
|
|
19
|
-
\********************************************/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/*!
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/*!
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/*!
|
|
35
|
-
|
|
36
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.ts */function(e,t,r){r.r(t);var i=r("./src/events.js"),n=r("./src/errors.ts"),a=r("./src/crypt/decrypter.js"),s=r("./src/polyfills/number.js"),o=r("./src/utils/logger.js"),l=r("./src/utils/get-self-scope.js");function u(e,t){return 255===e[t]&&240==(246&e[t+1])}function c(e,t){return 1&e[t+1]?7:9}function d(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function h(e,t){return!!(t+1<e.length&&u(e,t))}function f(e,t){if(h(e,t)){var r=c(e,t);if(t+r>=e.length)return!1;var i=d(e,t);if(i<=r)return!1;var n=t+i;if(n===e.length||n+1<e.length&&u(e,n))return!0}return!1}function g(e,t,r,a,s){if(!e.samplerate){var l=function(e,t,r,a){var s,l,u,c,d,h=navigator.userAgent.toLowerCase(),f=a,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(s=1+((192&t[r+2])>>>6),!((l=(60&t[r+2])>>>2)>g.length-1))return c=(1&t[r+2])<<2,c|=(192&t[r+3])>>>6,o.logger.log("manifest codec:"+a+",ADTS data:type:"+s+",sampleingIndex:"+l+"["+g[l]+"Hz],channelConfig:"+c),/firefox/i.test(h)?l>=6?(s=5,d=new Array(4),u=l-3):(s=2,d=new Array(2),u=l):-1!==h.indexOf("android")?(s=2,d=new Array(2),u=l):(s=5,d=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&l>=6?u=l-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(l>=6&&1===c||/vivaldi/i.test(h))||!a&&1===c)&&(s=2,d=new Array(2)),u=l)),d[0]=s<<3,d[0]|=(14&l)>>1,d[1]|=(1&l)<<7,d[1]|=c<<3,5===s&&(d[1]|=(14&u)>>1,d[2]=(1&u)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[l],channelCount:c,codec:"mp4a.40."+s,manifestCodec:f};e.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+l})}(t,r,a,s);e.config=l.config,e.samplerate=l.samplerate,e.channelCount=l.channelCount,e.codec=l.codec,e.manifestCodec=l.manifestCodec,o.logger.log("parsed codec:"+e.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)}}function p(e){return 9216e4/e}function v(e,t,r,i,n){var a=function(e,t,r,i,n){var a,s,o=e.length;if(a=c(e,t),s=d(e,t),(s-=a)>0&&t+a+s<=o)return{headerLength:a,frameLength:s,stamp:r+i*n}}(t,r,i,n,p(e.samplerate));if(a){var s=a.stamp,o=a.headerLength,l=a.frameLength,u={unit:t.subarray(r+o,r+o+l),pts:s,dts:s};return e.samples.push(u),{sample:u,length:l+o}}}var m=r("./src/demux/id3.js"),A=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(m.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(f(e,t))return o.logger.log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,r,i){for(var n=this._audioTrack,a=m.default.getID3Data(e,0)||[],l=m.default.getTimeStamp(a),u=Object(s.isFiniteNumber)(l)?90*l:9e4*t,c=0,d=u,f=e.length,p=a.length,A=[{pts:d,dts:d,data:a}];p<f-1;)if(h(e,p)&&p+5<f){g(n,this.observer,e,p,n.manifestCodec);var y=v(n,e,p,u,c);if(!y){o.logger.log("Unable to parse AAC frame");break}p+=y.length,d=y.sample.pts,c++}else m.default.isHeader(e,p)?(a=m.default.getID3Data(e,p),A.push({pts:d,dts:d,data:a}),p+=a.length):p++;this.remuxer.remux(n,{samples:[]},{samples:A,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),y=r("./src/demux/mp4demuxer.js"),E={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(e,t,r,i,n){if(!(r+24>t.length)){var a=this.parseHeader(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==a){var o=3===r?3-i:3===i?3:4,l=1e3*E.BitratesMap[14*o+n-1],u=3===r?0:2===r?1:2,c=E.SamplingRateMap[3*u+a],d=e[t+3]>>6==3?1:2,h=E.SamplesCoefficients[r][i],f=E.BytesInSlot[i],g=8*h*f;return{sampleRate:c,channelCount:d,frameLength:parseInt(h*l/c+s,10)*f,samplesPerFrame:g}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=this.parseHeader(e,t),i=4;r&&r.frameLength&&(i=r.frameLength);var n=t+i;if(n===e.length||n+1<e.length&&this.isHeaderPattern(e,n))return!0}return!1}},_=E,T=function(){function e(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&o.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){var t,r=8,i=8;for(t=0;t<e;t++)0!==i&&(i=(r+this.readEG()+256)%256),r=0===i?r:i},t.readSPS=function(){var e,t,r,i,n,a,s,o=0,l=0,u=0,c=0,d=this.readUByte.bind(this),h=this.readBits.bind(this),f=this.readUEG.bind(this),g=this.readBoolean.bind(this),p=this.skipBits.bind(this),v=this.skipEG.bind(this),m=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);if(d(),e=d(),h(5),p(3),d(),m(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var y=f();if(3===y&&p(1),m(),m(),p(1),g())for(a=3!==y?8:12,s=0;s<a;s++)g()&&A(s<6?16:64)}m();var E=f();if(0===E)f();else if(1===E)for(p(1),v(),v(),t=f(),s=0;s<t;s++)v();m(),p(1),r=f(),i=f(),0===(n=h(1))&&p(1),p(1),g()&&(o=f(),l=f(),u=f(),c=f());var _=[1,1];if(g()&&g())switch(d()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(r+1)-2*o-2*l),height:(2-n)*(i+1)*16-(n?2:4)*(u+c),pixelRatio:_}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),b=function(){function e(e,t,r,i){this.decryptdata=r,this.discardEPB=i,this.decrypter=new a.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)},t.decryptAacSample=function(e,t,r,i){var n=e[t].unit,a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(s,(function(a){a=new Uint8Array(a),n.set(a,16),i||o.decryptAacSamples(e,t+1,r)}))},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<=e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(e,t,r,i,n,a){var s=this.discardEPB(n.data),o=this.getAvcEncryptedData(s),l=this;this.decryptBuffer(o.buffer,(function(o){n.data=l.getAvcDecryptedUnit(s,o),a||l.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,a,s),!s)return}}}},e}(),k={video:1,audio:2,id3:3,text:4},S=function(){function e(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null,this.pmtUnknownTypes={}}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new b(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0||(r&&o.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},e._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:k[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}},t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this.pmtUnknownTypes={},this._avcTrack=e.createTrack("video",n),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3",n),this._txtTrack=e.createTrack("text",n),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.append=function(t,r,a,s){var l,u,c,d,h,f=t.length,g=!1;this.pmtUnknownTypes={},this.contiguous=a;var p=this.pmtParsed,v=this._avcTrack,m=this._audioTrack,A=this._id3Track,y=v.pid,E=m.pid,_=A.pid,T=this._pmtId,b=v.pesData,k=m.pesData,S=A.pesData,R=this._parsePAT,w=this._parsePMT.bind(this),L=this._parsePES,C=this._parseAVCPES.bind(this),O=this._parseAACPES.bind(this),D=this._parseMPEGPES.bind(this),I=this._parseID3PES.bind(this),P=e._syncOffset(t);for(f-=(f+P)%188,l=P;l<f;l+=188)if(71===t[l]){if(u=!!(64&t[l+1]),c=((31&t[l+1])<<8)+t[l+2],(48&t[l+3])>>4>1){if((d=l+5+t[l+4])===l+188)continue}else d=l+4;switch(c){case y:u&&(b&&(h=L(b))&&C(h,!1),b={data:[],size:0}),b&&(b.data.push(t.subarray(d,l+188)),b.size+=l+188-d);break;case E:u&&(k&&(h=L(k))&&(m.isAAC?O(h):D(h)),k={data:[],size:0}),k&&(k.data.push(t.subarray(d,l+188)),k.size+=l+188-d);break;case _:u&&(S&&(h=L(S))&&I(h),S={data:[],size:0}),S&&(S.data.push(t.subarray(d,l+188)),S.size+=l+188-d);break;case 0:u&&(d+=t[d]+1),T=this._pmtId=R(t,d);break;case T:u&&(d+=t[d]+1);var x=w(t,d,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(y=x.avc)>0&&(v.pid=y),(E=x.audio)>0&&(m.pid=E,m.isAAC=x.isAAC),(_=x.id3)>0&&(A.pid=_),g&&!p&&(o.logger.log("reparse from beginning"),g=!1,l=P-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=!0}}else this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b&&(h=L(b))?(C(h,!0),v.pesData=null):v.pesData=b,k&&(h=L(k))?(m.isAAC?O(h):D(h),m.pesData=null):(k&&k.size&&o.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=k),S&&(h=L(S))?(I(h),A.pesData=null):A.pesData=S,null==this.sampleAes?this.remuxer.remux(m,v,A,this._txtTrack,r,a,s):this.decryptAndRemux(m,v,A,this._txtTrack,r,a,s)},t.decryptAndRemux=function(e,t,r,i,n,a,s){if(e.samples&&e.isAAC){var o=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){o.decryptAndRemuxAvc(e,t,r,i,n,a,s)}))}else this.decryptAndRemuxAvc(e,t,r,i,n,a,s)},t.decryptAndRemuxAvc=function(e,t,r,i,n,a,s){if(t.samples){var o=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){o.remuxer.remux(e,t,r,i,n,a,s)}))}else this.remuxer.remux(e,t,r,i,n,a,s)},t.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._trackUnknownPmt=function(e,t,r){var i=this.pmtUnknownTypes[e]||0;return 0===i&&(this.pmtUnknownTypes[e]=0,t.call(o.logger,r)),this.pmtUnknownTypes[e]++,i},t._parsePMT=function(e,t,r,i){var n,a,s={audio:-1,avc:-1,id3:-1,isAAC:!0};for(n=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<n;){switch(a=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!i){this._trackUnknownPmt(e[t],o.logger.warn,"ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===s.audio&&(s.audio=a);break;case 21:-1===s.id3&&(s.id3=a);break;case 219:if(!i){this._trackUnknownPmt(e[t],o.logger.warn,"H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===s.avc&&(s.avc=a);break;case 3:case 4:r?-1===s.audio&&(s.audio=a,s.isAAC=!1):this._trackUnknownPmt(e[t],o.logger.warn,"MPEG audio found, not supported in this browser");break;case 36:this._trackUnknownPmt(e[t],o.logger.warn,"Unsupported HEVC stream type found");break;default:this._trackUnknownPmt(e[t],o.logger.log,"Unknown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return s},t._parsePES=function(e){var t,r,i,n,a,s,l,u,c=0,d=e.data;if(!e||0===e.size)return null;for(;d[0].length<19&&d.length>1;){var h=new Uint8Array(d[0].length+d[1].length);h.set(d[0]),h.set(d[1],d[0].length),d[0]=h,d.splice(1,1)}if(1===((t=d[0])[0]<<16)+(t[1]<<8)+t[2]){if((i=(t[4]<<8)+t[5])&&i>e.size-6)return null;if(192&(r=t[7])&&(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&r?s-(l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(o.logger.warn(Math.round((s-l)/9e4)+"s delta between PTS and DTS, align them"),s=l):l=s),u=(n=t[8])+9,e.size<=u)return null;e.size-=u,a=new Uint8Array(e.size);for(var f=0,g=d.length;f<g;f++){var p=(t=d[f]).byteLength;if(u){if(u>p){u-=p;continue}t=t.subarray(u),p-=u,u=0}a.set(t,c),c+=p}return i&&(i-=n+3),{data:a,pts:s,dts:l,len:i}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;if(isNaN(e.pts)){if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&o.logger.log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var r,i,n,a=this,s=this._avcTrack,o=this._parseAVCNALu(e.data),l=this.avcSample,u=!1,c=this.pushAccesUnit.bind(this),d=function(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}};e.data=null,l&&o.length&&!s.audFound&&(c(l,s),l=this.avcSample=d(!1,e.pts,e.dts,"")),o.forEach((function(t){switch(t.type){case 1:i=!0,l||(l=a.avcSample=d(!0,e.pts,e.dts,"")),l.frame=!0;var o=t.data;if(u&&o.length>4){var h=new T(o).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(l.key=!0)}break;case 5:i=!0,l||(l=a.avcSample=d(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0,(r=new T(a.discardEPB(t.data))).readUByte();for(var f=0,g=0,p=!1,v=0;!p&&r.bytesAvailable>1;){f=0;do{f+=v=r.readUByte()}while(255===v);g=0;do{g+=v=r.readUByte()}while(255===v);if(4===f&&0!==r.bytesAvailable){if(p=!0,181===r.readUByte()&&49===r.readUShort()&&1195456820===r.readUInt()&&3===r.readUByte()){var A=r.readUByte(),y=31&A,E=[A,r.readUByte()];for(n=0;n<y;n++)E.push(r.readUByte()),E.push(r.readUByte()),E.push(r.readUByte());a._insertSampleInOrder(a._txtTrack.samples,{type:3,pts:e.pts,bytes:E})}}else if(5===f&&0!==r.bytesAvailable){if(p=!0,g>16){var _=[];for(n=0;n<16;n++)_.push(r.readUByte().toString(16)),3!==n&&5!==n&&7!==n&&9!==n||_.push("-");var b=g-16,k=new Uint8Array(b);for(n=0;n<b;n++)k[n]=r.readUByte();a._insertSampleInOrder(a._txtTrack.samples,{pts:e.pts,payloadType:f,uuid:_.join(""),userDataBytes:k,userData:Object(m.utf8ArrayToStr)(k.buffer)})}}else if(g<r.bytesAvailable)for(n=0;n<g;n++)r.readUByte()}break;case 7:if(i=!0,u=!0,!s.sps){var S=(r=new T(t.data)).readSPS();s.width=S.width,s.height=S.height,s.pixelRatio=S.pixelRatio,s.sps=[t.data],s.duration=a._duration;var R=t.data.subarray(1,4),w="avc1.";for(n=0;n<3;n++){var L=R[n].toString(16);L.length<2&&(L="0"+L),w+=L}s.codec=w}break;case 8:i=!0,s.pps||(s.pps=[t.data]);break;case 9:i=!1,s.audFound=!0,l&&c(l,s),l=a.avcSample=d(!1,e.pts,e.dts,"");break;case 12:i=!1;break;default:i=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}l&&i&&l.units.push(t)})),t&&l&&(c(l,s),this.avcSample=null)},t._insertSampleInOrder=function(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts<e[i].pts){e.splice(i,0,t);break}}else e.push(t)},t._getLastNalUnit=function(){var e,t=this.avcSample;if(!t||0===t.units.length){var r=this._avcTrack.samples;t=r[r.length-1]}if(t){var i=t.units;e=i[i.length-1]}return e},t._parseAVCNALu=function(e){var t,r,i,n,a=0,s=e.byteLength,o=this._avcTrack,l=o.naluState||0,u=l,c=[],d=-1;for(-1===l&&(d=0,n=31&e[0],l=0,a=1);a<s;)if(t=e[a++],l)if(1!==l)if(t)if(1===t){if(d>=0)i={data:e.subarray(d,a-l-1),type:n},c.push(i);else{var h=this._getLastNalUnit();if(h&&(u&&a<=4-u&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-u)),(r=a-l-1)>0)){var f=new Uint8Array(h.data.byteLength+r);f.set(h.data,0),f.set(e.subarray(0,r),h.data.byteLength),h.data=f}}a<s?(d=a,n=31&e[a],l=0):l=-1}else l=0;else l=3;else l=t?0:2;else l=t?0:1;if(d>=0&&l>=0&&(i={data:e.subarray(d,s),type:n,state:l},c.push(i)),0===c.length){var g=this._getLastNalUnit();if(g){var p=new Uint8Array(g.data.byteLength+e.byteLength);p.set(g.data,0),p.set(e,g.data.byteLength),g.data=p}}return o.naluState=l,c},t.discardEPB=function(e){for(var t,r,i=e.byteLength,n=[],a=1;a<i-2;)0===e[a]&&0===e[a+1]&&3===e[a+2]?(n.push(a+2),a+=2):a++;if(0===n.length)return e;t=i-n.length,r=new Uint8Array(t);var s=0;for(a=0;a<t;s++,a++)s===n[0]&&(s++,n.shift()),r[a]=e[s];return r},t._parseAACPES=function(e){var t,r,a,s,l,u,c,d=this._audioTrack,f=e.data,m=e.pts,A=this.aacOverFlow,y=this.aacLastPTS;if(A){var E=new Uint8Array(A.byteLength+f.byteLength);E.set(A,0),E.set(f,A.byteLength),f=E}for(a=0,l=f.length;a<l-1&&!h(f,a);a++);if(!a||(a<l-1?(u="AAC PES did not start with ADTS header,offset:"+a,c=!1):(u="no ADTS header found in AAC PES",c=!0),o.logger.warn("parsing error:"+u),this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:c,reason:u}),!c)){if(g(d,this.observer,f,a,this.audioCodec),r=0,t=p(d.samplerate),A&&y){var _=y+t;Math.abs(_-m)>1&&(o.logger.log("AAC: align PTS for overlapping frames by "+Math.round((_-m)/90)),m=_)}for(;a<l;){if(h(f,a)){if(a+5<l){var T=v(d,f,a,m,r);if(T){a+=T.length,s=T.sample.pts,r++;continue}}break}a++}A=a<l?f.subarray(a,l):null,this.aacOverFlow=A,this.aacLastPTS=s}},t._parseMPEGPES=function(e){for(var t=e.data,r=t.length,i=0,n=0,a=e.pts;n<r;)if(_.isHeader(t,n)){var s=_.appendFrame(this._audioTrack,t,n,a,i);if(!s)break;n+=s.length,i++}else n++},t._parseID3PES=function(e){this._id3Track.samples.push(e)},e}(),R=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){var t,r,i=m.default.getID3Data(e,0);if(i&&void 0!==m.default.getTimeStamp(i))for(t=i.length,r=Math.min(e.length-1,t+100);t<r;t++)if(_.probe(e,t))return o.logger.log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,r,i){for(var n=m.default.getID3Data(e,0)||[],a=m.default.getTimeStamp(n),s=void 0!==a?90*a:9e4*t,o=n.length,l=e.length,u=0,c=0,d=this._audioTrack,h=[{pts:s,dts:s,data:n}];o<l;)if(_.isHeader(e,o)){var f=_.appendFrame(d,e,o,s,u);if(!f)break;o+=f.length,c=f.sample.pts,u++}else m.default.isHeader(e,o)?(n=m.default.getID3Data(e,o),h.push({pts:c,dts:c,data:n}),o+=n.length):o++;this.remuxer.remux(d,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),w=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}(),L=Math.pow(2,32)-1,C=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),i=8,n=r.length,a=n;n--;)i+=r[n].byteLength;for((t=new Uint8Array(i))[0]=i>>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),n=0,i=8;n<a;n++)t.set(r[n],i),i+=r[n].byteLength;return t},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(L+1)),n=Math.floor(r%(L+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(L+1)),n=Math.floor(r%(L+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(i=0;i<n.length;i++)r=n[i].flags,a[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(L+1)),o=Math.floor(i%(L+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(L+1)),s=Math.floor(r%(L+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,a,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,h=new Uint8Array(d);for(r+=8+d,h.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)a=(n=u[i]).duration,s=n.size,o=n.flags,l=n.cts,h.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,h)},e.initSegment=function(t){e.types||e.init();var r,i=e.moov(t);return(r=new Uint8Array(e.FTYP.byteLength+i.byteLength)).set(e.FTYP),r.set(i,e.FTYP.byteLength),r},e}();function O(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}function D(e,t){return void 0===t&&(t=!1),O(e,1e3,1/9e4,t)}function I(e,t){return void 0===t&&(t=1),O(e,9e4,1/t)}var P=I(10),x=I(.2),N=null;function M(e,t){var r;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}var F,U=function(){function e(e,t,r,i){if(this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===N){var n=navigator.userAgent.match(/Chrome\/(\d+)/i);N=n?parseInt(n[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},t.resetInitSegment=function(){this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,M(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&o.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,n,a,s,l){if(this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated){var u=e.samples.length,c=t.samples.length,d=a,h=a;if(u&&c){var f=this.getVideoStartPts(t.samples),g=(M(e.samples[0].pts,f)-f)/t.inputTimeScale;d+=Math.max(0,g),h+=Math.max(0,-g)}if(u){e.timescale||(o.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a));var p,v=this.remuxAudio(e,d,s,l);c&&(v&&(p=v.endPTS-v.startPTS),t.timescale||(o.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,h,s,p))}else if(c){var m=this.remuxVideo(t,h,s,0,l);m&&e.codec&&this.remuxEmptyAudio(e,d,s,m)}}r.samples.length&&this.remuxID3(r,a),n.samples.length&&this.remuxText(n,a),this.observer.trigger(i.default.FRAG_PARSED)},t.generateIS=function(e,t,r){var a,s,l=this.observer,u=e.samples,c=t.samples,d=this.typeSupported,h="audio/mp4",f={},g={tracks:f},p=void 0===this._initPTS;if(p&&(a=s=1/0),e.config&&u.length&&(e.timescale=e.samplerate,o.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(d.mpeg?(h="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),f.audio={container:h,codec:e.codec,initSegment:!e.isAAC&&d.mpeg?new Uint8Array:C.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(a=s=u[0].pts-Math.round(e.inputTimeScale*r))),t.sps&&t.pps&&c.length){var v=t.inputTimeScale;if(t.timescale=v,f.video={container:"video/mp4",codec:t.codec,initSegment:C.initSegment([t]),metadata:{width:t.width,height:t.height}},p){var m=this.getVideoStartPts(c),A=Math.round(v*r);s=Math.min(s,M(c[0].dts,m)-A),a=Math.min(a,m-A),this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:a})}}else p&&f.audio&&this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:a});Object.keys(f).length?(l.trigger(i.default.FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,p&&(this._initPTS=a,this._initDTS=s)):l.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,a){var s,l,u,c,d,h=e.timescale,f=e.samples,g=[],p=f.length,v=this._initPTS,m=8,A=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,E=0,_=!1,T=this.nextAvcDts;if(0!==p){r||(T=t*h-(f[0].pts-M(f[0].dts,f[0].pts)));for(var b=0;b<p;b++){var k=f[b];k.pts=M(k.pts-v,T),k.dts=M(k.dts-v,T),k.dts>k.pts&&(E=Math.max(Math.min(E,k.pts-k.dts),-1*x)),k.dts<f[b>0?b-1:b].dts&&(_=!0)}_&&f.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id})),c=f[0].dts,d=f[p-1].dts;var S=Math.round((d-c)/(p-1));if(E<0){if(E<-2*S){o.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+D(-S,!0)+" ms");for(var R=E,w=0;w<p;w++)f[w].dts=R=Math.max(R,f[w].pts-S),f[w].pts=Math.max(R,f[w].pts)}else{o.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+D(E,!0)+" ms to overcome this issue");for(var L=0;L<p;L++)f[L].dts=f[L].dts+E}c=f[0].dts,d=f[p-1].dts}if(r){var O=c-T,I=O>S;if(I||O<-1){I?o.logger.warn("AVC: "+D(O,!0)+" ms ("+O+"dts) hole between fragments detected, filling it"):o.logger.warn("AVC: "+D(-O,!0)+" ms ("+O+"dts) overlapping between fragments detected"),c=T;var P=f[0].pts-O;f[0].dts=c,f[0].pts=P,o.logger.log("Video: First PTS/DTS adjusted: "+D(P,!0)+"/"+D(c,!0)+", delta: "+D(O,!0)+" ms")}}N&&N<75&&(c=Math.max(0,c));for(var F=0,U=0,B=0;B<p;B++){for(var j=f[B],G=j.units,K=G.length,Y=0,V=0;V<K;V++)Y+=G[V].data.length;U+=Y,F+=K,j.length=Y,j.dts=Math.max(j.dts,c),j.pts=Math.max(j.pts,j.dts,0),A=Math.min(j.pts,A),y=Math.max(j.pts,y)}d=f[p-1].dts;var H=U+4*F+8;try{l=new Uint8Array(H)}catch(e){return void this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MUX_ERROR,details:n.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:H,reason:"fail allocating video mdat "+H})}var W=new DataView(l.buffer);W.setUint32(0,H),l.set(C.types.mdat,4);for(var z=0;z<p;z++){for(var q,X=f[z],$=X.units,Z=0,Q=0,J=$.length;Q<J;Q++){var ee=$[Q],te=ee.data,re=ee.data.byteLength;W.setUint32(m,re),m+=4,l.set(te,m),m+=re,Z+=4+re}if(z<p-1)s=f[z+1].dts-X.dts;else{var ie=this.config,ne=X.dts-f[z>0?z-1:z].dts;if(ie.stretchShortVideoTrack){var ae=ie.maxBufferHole,se=Math.floor(ae*h),oe=(a?A+a*h:this.nextAudioPts)-X.pts;oe>se?((s=oe-ne)<0&&(s=ne),o.logger.log("It is approximately "+D(oe,!1)+" ms to the next segment; using duration "+D(s,!1)+" ms for the last video frame.")):s=ne}else s=ne}q=Math.round(X.pts-X.dts),g.push({size:Z,duration:s,cts:q,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:X.key?2:1,isNonSync:X.key?0:1}})}this.nextAvcDts=d+s;var le=e.dropped;if(e.nbNalu=0,e.dropped=0,g.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ue=g[0].flags;ue.dependsOn=2,ue.isNonSync=0}e.samples=g,u=C.moof(e.sequenceNumber++,c,e),e.samples=[];var ce={data1:u,data2:l,startPTS:A/h,endPTS:(y+s)/h,startDTS:c/h,endDTS:this.nextAvcDts/h,type:"video",hasAudio:!1,hasVideo:!0,nb:g.length,dropped:le};return this.observer.trigger(i.default.FRAG_PARSING_DATA,ce),ce}},t.remuxAudio=function(e,t,r,a){var s,l,u,c,d,h,f=e.inputTimeScale,g=e.timescale,p=f/g,v=(e.isAAC?1024:1152)*p,m=this._initPTS,A=!e.isAAC&&this.typeSupported.mpeg,y=A?0:8,E=e.samples,_=[],T=this.nextAudioPts;if(r|=E.length&&T&&(a&&Math.abs(t-T/f)<.1||Math.abs(E[0].pts-T-m)<20*v),E.forEach((function(e){e.pts=e.dts=M(e.pts-m,t*f)})),0!==(E=E.filter((function(e){return e.pts>=0}))).length){if(r||(T=a?Math.max(0,t*f):E[0].pts),e.isAAC)for(var b=this.config.maxAudioFramesDrift,k=0,S=T;k<E.length;){var R=E[k],L=R.pts,O=L-S;if(O<=-b*v)r||k>0?(o.logger.warn("Dropping 1 audio frame @ "+D(S,!0)/1e3+"s due to "+D(O,!0)+" ms overlap."),E.splice(k,1)):(o.logger.warn("Audio frame @ "+D(L,!0)/1e3+"s overlaps nextAudioPts by "+D(O,!0)+" ms."),S=L+v,k++);else if(O>=b*v&&O<P&&S){var I=Math.round(O/v);o.logger.warn("Injecting "+I+" audio frames @ "+D(S,!0)/1e3+"s due to "+D(O,!0)+" ms gap.");for(var x=0;x<I;x++){var N=Math.max(S,0);(l=w.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(o.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),l=R.unit.subarray()),E.splice(k,0,{unit:l,pts:N,dts:N}),S+=v,k++}R.pts=R.dts=S,S+=v,k++}else R.pts=R.dts=S,S+=v,k++}for(var F=E.length,U=0;F--;)U+=E[F].unit.byteLength;for(var B=0,j=E.length;B<j;B++){var G=E[B],K=G.unit,Y=G.pts;if(void 0!==h&&s)s.duration=Math.round((Y-h)/p);else{var V=Y-T,H=0;if(r&&e.isAAC&&V){if(V>0&&V<P)H=Math.round((Y-T)/v),o.logger.log(D(V,!0)+" ms hole between AAC samples detected,filling it"),H>0&&((l=w.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l=K.subarray()),U+=H*l.length);else if(V<-12){o.logger.log("drop overlapping AAC sample, expected/parsed/delta: "+D(T,!0)+" ms / "+D(Y,!0)+" ms / "+D(-V,!0)+" ms"),U-=K.byteLength;continue}Y=T}if(d=Y,!(U>0))return;U+=y;try{u=new Uint8Array(U)}catch(e){return void this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MUX_ERROR,details:n.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:U,reason:"fail allocating audio mdat "+U})}A||(new DataView(u.buffer).setUint32(0,U),u.set(C.types.mdat,4));for(var W=0;W<H;W++)(l=w.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(o.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),l=K.subarray()),u.set(l,y),y+=l.byteLength,s={size:l.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(s)}u.set(K,y);var z=K.byteLength;y+=z,s={size:z,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(s),h=Y}var q=0;if((F=_.length)>=2&&(q=_[F-2].duration,s.duration=q),F){this.nextAudioPts=T=h+p*q,e.samples=_,c=A?new Uint8Array:C.moof(e.sequenceNumber++,d/p,e),e.samples=[];var X=d/f,$=T/f,Z={data1:c,data2:u,startPTS:X,endPTS:$,startDTS:X,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:F};return this.observer.trigger(i.default.FRAG_PARSING_DATA,Z),Z}return null}},t.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,l=(void 0!==s?s:i.startDTS*n)+this._initDTS,u=i.endDTS*n+this._initDTS,c=1024*a,d=Math.ceil((u-l)/c),h=w.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(o.logger.warn("remux empty Audio"),h){for(var f=[],g=0;g<d;g++){var p=l+g*c;f.push({unit:h,pts:p,dts:p})}e.samples=f,this.remuxAudio(e,t,r)}else o.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")},t.remuxID3=function(e,t){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,a=this._initPTS,s=this._initDTS,o=0;o<r;o++){var l=e.samples[o];l.pts=M(l.pts-a,t*n)/n,l.dts=M(l.dts-s,t*n)/n}this.observer.trigger(i.default.FRAG_PARSING_METADATA,{samples:e.samples}),e.samples=[]}},t.remuxText=function(e,t){var r=e.samples.length,n=e.inputTimeScale,a=this._initPTS;if(r){for(var s=0;s<r;s++){var o=e.samples[s];o.pts=M(o.pts-a,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts})),this.observer.trigger(i.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]},e}(),B=function(){function e(e){this.observer=e}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.remux=function(e,t,r,n,a,s,o,l){var u=this.observer,c="";e&&(c+="audio"),t&&(c+="video"),u.trigger(i.default.FRAG_PARSING_DATA,{data1:l,startPTS:a,startDTS:a,type:c,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(i.default.FRAG_PARSED)},e}(),j=Object(l.getSelfScope)();try{F=j.performance.now.bind(j.performance)}catch(e){o.logger.debug("Unable to use Performance API on this environment"),F=j.Date.now}var G=function(){function e(e,t,r,i){this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i}var t=e.prototype;return t.destroy=function(){var e=this.demuxer;e&&e.destroy()},t.push=function(e,t,r,n,s,o,l,u,c,d,h,f){var g=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var p=this.decrypter;null==p&&(p=this.decrypter=new a.default(this.observer,this.config));var v=F();p.decrypt(e,t.key.buffer,t.iv.buffer,(function(e){var a=F();g.observer.trigger(i.default.FRAG_DECRYPTED,{stats:{tstart:v,tdecrypt:a}}),g.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,s,o,l,u,c,d,h,f)}))}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,s,o,l,u,c,d,h,f)},t.pushDecrypted=function(e,t,r,a,s,o,l,u,c,d,h,f){var g=this.demuxer,p=this.remuxer;if(!g||l||u){for(var v,m=this.observer,E=this.typeSupported,_=this.config,T=[{demux:S,remux:U},{demux:y.default,remux:B},{demux:A,remux:U},{demux:R,remux:U}],b=0,k=T.length;b<k&&!(v=T[b]).demux.probe(e);b++);if(!v)return void m.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});p&&p instanceof v.remux||(p=new v.remux(m,_,E,this.vendor)),g&&g instanceof v.demux||(g=new v.demux(m,p,_,E),this.probe=v.demux.probe),this.demuxer=g,this.remuxer=p}(l||u)&&(g.resetInitSegment(r,a,s,d),p.resetInitSegment()),l&&(g.resetTimeStamp(f),p.resetTimeStamp(f)),"function"==typeof g.setDecryptData&&g.setDecryptData(t),g.append(e,o,c,h)},e}();t.default=G},"./src/demux/demuxer-worker.js":
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/*! exports provided: default */
|
|
41
|
-
|
|
39
|
+
!*** ./src/controller/fragment-finders.ts ***!
|
|
40
|
+
\********************************************/(e,t,r)=>{r.r(t),r.d(t,{findFragWithCC:()=>u,findFragmentByPDT:()=>a,findFragmentByPTS:()=>s,fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function a(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!(0,i.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(l(t,r,a))return a}return null}function s(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;if(e?a=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(a=t[0]),a&&0===o(r,i,a))return a;var s=n.default.search(t,o.bind(null,r,i));return s||a}function o(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function l(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function u(e,t){return n.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}},"./src/controller/fragment-tracker.ts":
|
|
41
|
+
/*!********************************************!*\
|
|
42
|
+
!*** ./src/controller/fragment-tracker.ts ***!
|
|
43
|
+
\********************************************/(e,t,r)=>{r.r(t),r.d(t,{FragmentState:()=>i,FragmentTracker:()=>s});var i,n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");!function(e){e.NOT_LOADED="NOT_LOADED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK"}(i||(i={}));var s=function(){function e(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],o=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==o&&e<=o)return n>9&&(this.activeParts=i.slice(n-9)),s}else if(r.start<=e&&void 0!==r.appendedPTS&&e<=r.appendedPTS)return r}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r){var i=this;Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a)if(a.buffered){var s=a.range[e];s&&s.time.some((function(e){var r=!i.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&i.removeFragment(a.body),r}))}else a.body.type===r&&i.removeFragment(a.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=l(i),s=this.fragments[a];s&&(Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var o=r[e],l=null!==n||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,o)}})),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},t.fragBuffered=function(e){var t=l(e),r=this.fragments[t];r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=t?t.start:e.start,s=t?t.end:e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,d=i.end(u)+this.bufferPadding;if(l>=c&&o<=d){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<d&&s>c)n.partial=!0,n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=c)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var c=l[u];c&&o(c)&&(r=c.body.start-s,i=c.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=c.body,a=t)))})),n},t.getState=function(e){var t=l(e),r=this.fragments[t];return r?r.buffered?o(r)?i.PARTIAL:i.OK:i.APPENDING:i.NOT_LOADED},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=l(r);this.fragments[n]={body:r,loaded:t,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,s=t.timeRanges;if(i.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=i,n){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(n)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(e){var t=s[e];if(r.detectEvictedFragments(e,t),!n)for(var a=0;a<t.length;a++)i.appendedPTS=Math.max(t.end(a),i.appendedPTS||0)}))},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=l(e);return!!this.fragments[t]},t.removeFragmentsInRange=function(e,t,r){var i=this;Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a&&a.buffered){var s=a.body;s.type===r&&s.start<t&&s.end>e&&i.removeFragment(s)}}))},t.removeFragment=function(e){var t=l(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},e}();function o(e){var t,r;return e.buffered&&((null===(t=e.range.video)||void 0===t?void 0:t.partial)||(null===(r=e.range.audio)||void 0===r?void 0:r.partial))}function l(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":
|
|
44
|
+
/*!******************************************!*\
|
|
45
|
+
!*** ./src/controller/gap-controller.ts ***!
|
|
46
|
+
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{MAX_START_GAP_JUMP:()=>l,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>u,SKIP_BUFFER_RANGE_START:()=>c,STALL_MINIMUM_DURATION_MS:()=>o,default:()=>d});var i=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,c=.05,d=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,n=this.media,a=this.stalled;if(null!==n){var u=n.currentTime,c=n.seeking,d=this.seeking&&!c,h=!this.seeking&&c;if(this.seeking=c,u===e){if((h||d)&&(this.stalled=null),!(n.paused&&!c||n.ended||0===n.playbackRate)&&i.BufferHelper.getBuffered(n).length){var f=i.BufferHelper.bufferInfo(n,u,0),g=f.len>0,p=f.nextStart||0;if(g||p){if(c){var v=f.len>l,m=!p||t&&t.start<=u||p-u>l&&!this.fragmentTracker.getPartialFragment(u);if(v||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,A=Math.max(p,f.start||0)-u,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=(null==E||null===(y=E.details)||void 0===y?void 0:y.live)?2*E.details.targetduration:l;if(A>0&&A<=T)return void this._trySkipBufferHole(null)}var b=self.performance.now();if(null!==a){var S=b-a;if(c||!(S>=o)||(this._reportStall(f),this.media)){var _=i.BufferHelper.bufferInfo(n,u,r.maxBufferHole);this._tryFixBufferStall(_,S)}}else this.stalled=b}}}else if(this.moved=!0,null!==a){if(this.stallReported){var k=self.performance.now()-a;s.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(k)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,o=i.getPartialFragment(a);if(o&&(this._trySkipBufferHole(o)||!this.media))return;e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(null===o)return 0;for(var l=o.currentTime,d=0,h=i.BufferHelper.getBuffered(o),f=0;f<h.length;f++){var g=h.start(f);if(l+t.maxBufferHole>=d&&l<g){var p=Math.max(g+c,o.currentTime+u);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+p),this.moved=!0,this.stalled=null,o.currentTime=p,e&&r.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+p,frag:e}),p}d=h.end(f)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var l=o+(i+1)*e.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+o+" to "+l),r.currentTime=l,t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},e}()},"./src/controller/id3-track-controller.ts":
|
|
47
|
+
/*!************************************************!*\
|
|
48
|
+
!*** ./src/controller/id3-track-controller.ts ***!
|
|
49
|
+
\************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),l=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var c=function(){var e=u();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function d(e,t){return e.getTime()/1e3-t}var h=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&((0,a.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return(0,a.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){t.frag;var a=t.samples;t.details,this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=u(),d=0;d<a.length;d++){var h=a[d].type;if((h!==l.MetadataSchema.emsg||i)&&n){var f=s.getID3Frames(a[d].data);if(f){var g=a[d].pts,p=g+a[d].duration;p>c&&(p=c),p-g<=0&&(p=g+.25);for(var v=0;v<f.length;v++){var m=f[v];if(!s.isTimeStampFrame(m)){this.updateId3CueEnds(g);var y=new o(g,p,"");y.value=m,h&&(y.type=h),this.id3Track.addCue(y)}}}}}}}},t.updateId3CueEnds=function(e){var t,r=null===(t=this.id3Track)||void 0===t?void 0:t.cues;if(r)for(var i=r.length;i--;){var n=r[i];n.startTime<e&&n.endTime===c&&(n.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,s=this.id3Track,o=this.hls;if(o){var u,c=o.config,d=c.enableEmsgMetadataCues,h=c.enableID3MetadataCues;s&&(d||h)&&(u="audio"===n?function(e){return e.type===l.MetadataSchema.audioId3&&h}:"video"===n?function(e){return e.type===l.MetadataSchema.emsg&&d}:function(e){return e.type===l.MetadataSchema.audioId3&&h||e.type===l.MetadataSchema.emsg&&d},(0,a.removeCuesInRange)(s,r,i,u))}},t.onLevelUpdated=function(e,t){var r=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,s=this.id3Track,h=n.dateRanges,f=Object.keys(h);if(s)for(var g=Object.keys(a).filter((function(e){return!f.includes(e)})),p=function(e){var t=g[e];Object.keys(a[t].cues).forEach((function(e){s.removeCue(a[t].cues[e])})),delete a[t]},v=g.length;v--;)p(v);var m=n.fragments[n.fragments.length-1];if(0!==f.length&&(0,i.isFiniteNumber)(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=m.programDateTime/1e3-m.start,A=u(),E=function(e){var t=f[e],i=h[t],n=a[t],s=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,g=d(i.startDate,y),p=c,v=i.endDate;if(v)p=d(v,y),u=!0;else if(i.endOnNext&&!u){var m=f.reduce((function(e,t){var r=h[t];return r.class===i.class&&r.id!==t&&r.startDate>i.startDate&&e.push(r),e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0];m&&(p=d(m.startDate,y),u=!0)}for(var E,T=Object.keys(i.attr),b=0;b<T.length;b++){var S=T[b];if(S!==o.DateRangeAttribute.ID&&S!==o.DateRangeAttribute.CLASS&&S!==o.DateRangeAttribute.START_DATE&&S!==o.DateRangeAttribute.DURATION&&S!==o.DateRangeAttribute.END_DATE&&S!==o.DateRangeAttribute.END_ON_NEXT){var _=s[S];if(_)u&&!n.durationKnown&&(_.endTime=p);else{var k=i.attr[S];_=new A(g,p,""),S!==o.DateRangeAttribute.SCTE35_OUT&&S!==o.DateRangeAttribute.SCTE35_IN||(E=k,k=Uint8Array.from(E.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),_.value={key:S,data:k},_.type=l.MetadataSchema.dateRange,r.id3Track.addCue(_),s[S]=_}}}a[t]={cues:s,dateRange:i,durationKnown:u}},T=0;T<f.length;T++)E(T)}}},e}();const f=h},"./src/controller/latency-controller.ts":
|
|
50
|
+
/*!**********************************************!*\
|
|
51
|
+
!*** ./src/controller/latency-controller.ts ***!
|
|
52
|
+
\**********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t,r,o,l=e.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},l.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(e,t){t.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+t.targetduration);if(t.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},l.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t=e,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])&&s(t.prototype,r),o&&s(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/controller/level-controller.ts":
|
|
53
|
+
/*!********************************************!*\
|
|
54
|
+
!*** ./src/controller/level-controller.ts ***!
|
|
55
|
+
\********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>g});var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c.apply(this,arguments)}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),g=function(e){var t,r;function l(t){var r;return(r=e.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=e,(t=l).prototype=Object.create(r.prototype),t.prototype.constructor=t,h(t,r);var g,p,v,m=l.prototype;return m._registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(n.Events.ERROR,this.onError,this)},m._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(n.Events.ERROR,this.onError,this)},m.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},m.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),e.prototype.startLoad.call(this)},m.onManifestLoaded=function(e,t){var r,l,u=[],c=[],d=[],h={},g=!1,p=!1,v=!1;if(t.levels.forEach((function(e){var t=e.attrs;g=g||!(!e.width||!e.height),p=p||!!e.videoCodec,v=v||!!e.audioCodec,f&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0);var r=e.bitrate+"-"+e.attrs.RESOLUTION+"-"+e.attrs.CODECS;(l=h[r])?l.url.push(e.url):(l=new i.Level(e),h[r]=l,u.push(l)),t&&(t.AUDIO&&(0,o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&(0,o.addGroupId)(l,"text",t.SUBTITLES))})),(g||p)&&v&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,i=e.height;return!!t||!(!r||!i)}))),u=u.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||(0,s.isCodecSupportedInMp4)(t,"audio"))&&(!r||(0,s.isCodecSupportedInMp4)(r,"video"))})),t.audioTracks&&(c=t.audioTracks.filter((function(e){return!e.audioCodec||(0,s.isCodecSupportedInMp4)(e.audioCodec,"audio")})),(0,o.assignTrackIdsByGroup)(c)),t.subtitles&&(d=t.subtitles,(0,o.assignTrackIdsByGroup)(d)),u.length>0){r=u[0].bitrate,u.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=u;for(var m=0;m<u.length;m++)if(u[m].bitrate===r){this._firstLevel=m,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=v&&!p,A={levels:u,audioTracks:c,subtitleTracks:d,firstLevel:this._firstLevel,stats:t.stats,audio:v,video:p,altAudio:!y&&c.some((function(e){return!!e.url}))};this.hls.trigger(n.Events.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},m.onError=function(t,r){var i;if(e.prototype.onError.call(this,t,r),!r.fatal){var n=r.context,s=this._levels[this.currentLevelIndex];if(n&&(n.type===u.PlaylistContextType.AUDIO_TRACK&&s.audioGroupIds&&n.groupId===s.audioGroupIds[s.urlId]||n.type===u.PlaylistContextType.SUBTITLE_TRACK&&s.textGroupIds&&n.groupId===s.textGroupIds[s.urlId]))this.redundantFailover(this.currentLevelIndex);else{var o,l=!1,c=!0;switch(r.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var d=r.frag.type===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,h=this._levels[d];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=d)):o=d}break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:n&&(n.deliveryDirectives&&(c=!1),o=n.level),l=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:o=null!=(i=r.level)?i:this.currentLevelIndex,l=!0}void 0!==o&&this.recoverLevel(r,o,l,c)}}},m.recoverLevel=function(e,t,r,i){var n=e.details,a=this._levels[t];if(a.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(i){var s=a.url.length;if(s>1&&a.loadError<s)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){for(var o=-1,l=this._levels,u=l.length;u--;){var c=(u+this.currentLevelIndex)%l.length;if(c!==this.currentLevelIndex&&0===l[c].loadError){o=c;break}}o>-1&&this.currentLevelIndex!==o&&(this.warn(n+": switch to "+o),e.levelRetry=!0,this.hls.nextAutoLevel=o)}}},m.redundantFailover=function(e){var t=this._levels[e],r=t.url.length;if(r>1){var i=(t.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach((function(e){e.urlId=i})),this.level=e}},m.onFragLoaded=function(e,t){var r=t.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var i=this._levels[r.level];void 0!==i&&(i.fragmentError=0,i.loadError=0)}},m.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!==(i=t.deliveryDirectives)&&void 0!==i&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(n,t,s.details)):null!==(r=t.deliveryDirectives)&&void 0!==r&&r.skip&&(a.deltaUpdateFailed=!0)},m.onAudioTrackSwitched=function(e,t){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[t.id].groupId,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===n){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},m.loadPlaylist=function(e){var t=this.currentLevelIndex,r=this._levels[t];if(this.canLoad&&r&&r.url.length>0){var i=r.urlId,a=r.url[i];if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+t+(e?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+i+" "+a),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:a,level:t,id:i,deliveryDirectives:e||null})}},m.removeLevel=function(e,t){var r=function(e,r){return r!==t},i=this._levels.filter((function(i,n){return n!==e||i.url.length>1&&void 0!==t&&(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0)})).map((function(e,t){var r=e.details;return null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},g=l,(p=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==e||null===(t=r[e])||void 0===t||!t.details)){if(e<0||e>=r.length){var i=e<0;if(this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,reason:"invalid level idx"}),i)return;e=Math.min(e,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,o=r[s],l=r[e];this.log("switching to level "+e+" from "+s),this.currentLevelIndex=e;var u=c({},l,{level:e,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,u);var d=l.details;if(!d||d.live){var h=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&d(g.prototype,p),v&&d(g,v),Object.defineProperty(g,"prototype",{writable:!1}),l}(l.default)},"./src/controller/level-helper.ts":
|
|
56
|
+
/*!****************************************!*\
|
|
57
|
+
!*** ./src/controller/level-helper.ts ***!
|
|
58
|
+
\****************************************/(e,t,r)=>{r.r(t),r.d(t,{addGroupId:()=>o,addSliding:()=>v,adjustSliding:()=>p,assignTrackIdsByGroup:()=>l,computeReloadInterval:()=>m,getFragmentWithSN:()=>y,getPartWith:()=>A,mapFragmentIntersection:()=>g,mapPartIntersection:()=>f,mergeDetails:()=>h,updateFragPTSDTS:()=>d,updatePTS:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},s.apply(this,arguments)}function o(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function l(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function u(e,t,r){c(e[t],e[r])}function c(e,t){var r=t.startPTS;if((0,i.isFiniteNumber)(r)){var n,a=0;t.sn>e.sn?(a=r-e.start,n=e):(a=e.start-r,n=t),n.duration!==a&&(n.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function d(e,t,r,a,s,o){a-r<=0&&(n.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,o=s+t.duration);var l=r,u=a,d=t.startPTS,h=t.endPTS;if((0,i.isFiniteNumber)(d)){var f=Math.abs(d-r);(0,i.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(f,t.deltaPTS):t.deltaPTS=f,l=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),u=Math.min(a,h),a=Math.max(a,h),o=Math.max(o,t.endDTS)}t.duration=a-r;var g=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=l,t.startDTS=s,t.endPTS=a,t.minEndPTS=u,t.endDTS=o;var p,v=t.sn;if(!e||v<e.startSN||v>e.endSN)return 0;var m=v-e.startSN,y=e.fragments;for(y[m]=t,p=m;p>0;p--)c(y[p],y[p-1]);for(p=m;p<y.length-1;p++)c(y[p],y[p+1]);return e.fragmentHint&&c(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,g}function h(e,t){for(var r=null,o=e.fragments,l=o.length-1;l>=0;l--){var u=o[l].initSegment;if(u){r=u;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var c,h,v,m,y,A=0;if(g(e,t,(function(e,n){e.relurl&&(A=e.cc-n.cc),(0,i.isFiniteNumber)(e.startPTS)&&(0,i.isFiniteNumber)(e.endPTS)&&(n.start=n.startPTS=e.startPTS,n.startDTS=e.startDTS,n.appendedPTS=e.appendedPTS,n.maxStartPTS=e.maxStartPTS,n.endPTS=e.endPTS,n.endDTS=e.endDTS,n.minEndPTS=e.minEndPTS,n.duration=e.endPTS-e.startPTS,n.duration&&(c=n),t.PTSKnown=t.alignedSliding=!0),n.elementaryStreams=e.elementaryStreams,n.loader=e.loader,n.stats=e.stats,n.urlId=e.urlId,e.initSegment&&(n.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;e.initSegment&&e.initSegment.relurl!==(null===(t=r)||void 0===t?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var E=t.skippedSegments;E--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(h=e.dateRanges,v=t.dateRanges,m=t.recentlyRemovedDateranges,y=s({},h),m&&m.forEach((function(e){delete y[e]})),Object.keys(v).forEach((function(e){var t=new a.DateRange(v[e].attr,y[e]);t.isValid?y[e]=t:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(v[e].attr)+'"')})),y));var T=t.fragments;if(A){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<T.length;b++)T[b].cc+=A}t.skippedSegments&&(t.startCC=t.fragments[0].cc),f(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),c?d(t,c,c.startPTS,c.endPTS,c.startDTS,c.endDTS):p(e,t),T.length&&(t.totalduration=t.edge-T[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var S=t.advancedDateTime;if(t.advanced&&S){var _=t.edge;t.driftStart||(t.driftStartTime=S,t.driftStart=_),t.driftEndTime=S,t.driftEnd=_}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function f(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}function g(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=n;u<=a;u++){var c=l[s+u],d=o[u];i&&!d&&u<i&&(d=t.fragments[u]=c),c&&d&&r(c,d)}}function p(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||v(t,i[r].start)}function v(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function m(e,t){var r,i=1e3*e.levelTargetDuration,n=i/2,a=e.age,s=a>0&&a<3*i,o=t.loading.end-t.loading.start,l=e.availabilityDelay;if(!1===e.updated)if(s){var u=333*e.misses;r=Math.max(Math.min(n,2*o),u),e.availabilityDelay=(e.availabilityDelay||0)+r}else r=n;else s?(l=Math.min(l||i/2,a),e.availabilityDelay=l,r=l+i-a):r=i-o;return Math.round(r)}function y(e,t,r){if(!e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}function A(e,t,r){if(!e||!e.details)return null;var i=e.details.partList;if(i)for(var n=i.length;n--;){var a=i[n];if(a.index===r&&a.fragment.sn===t)return a}return null}},"./src/controller/stream-controller.ts":
|
|
59
|
+
/*!*********************************************!*\
|
|
60
|
+
!*** ./src/controller/stream-controller.ts ***!
|
|
61
|
+
\*********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../is-supported */"./src/is-supported.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),g=r(/*! ../errors */"./src/errors.ts");function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}var m=function(e){var t,r;function m(t,r){var i;return(i=e.call(this,t,r,"[stream-controller]")||this).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i.altAudio=!1,i.audioOnly=!1,i.fragPlaying=null,i.onvplaying=null,i.onvseeked=null,i.fragLastKbps=0,i.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=e,(t=m).prototype=Object.create(r.prototype),t.prototype.constructor=t,v(t,r);var y,A,E,T=m.prototype;return T._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(s.Events.ERROR,this.onError,this),e.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(s.Events.ERROR,this.onError,this),e.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},T.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},T.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},T.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var e,t=this.levels,r=this.level,i=null==t||null===(e=t[r])||void 0===e?void 0:e.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;(!o||s>=o||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=n.State.IDLE)}this.onTickEnd()},T.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},T.doTickIdle=function(){var e,t,r=this.hls,i=this.levelLastLoaded,a=this.levels,o=this.media,d=r.config,h=r.nextLoadLevel;if(null!==i&&(o||!this.startFragRequested&&d.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&a&&a[h]){var f=a[h];this.level=r.nextLoadLevel=h;var g=f.details;if(!g||this.state===n.State.WAITING_LEVEL||g.live&&this.levelLastLoaded!==h)this.state=n.State.WAITING_LEVEL;else{var p=this.getMainFwdBufferInfo();if(null!==p&&!(p.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(p,g)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}this.backtrackFragment&&this.backtrackFragment.start>p.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:p.end,y=this.getNextFragment(m,g);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn&&this.fragmentTracker.getState(y)!==l.FragmentState.OK){var A,E=(null!=(A=this.backtrackFragment)?A:y).sn-g.startSN,T=g.fragments[E-1];T&&y.cc===T.cc&&(y=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&p.len&&(this.backtrackFragment=null);if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>m){var b=this.audioOnly&&!this.altAudio?c.ElementaryStreamTypes.AUDIO:c.ElementaryStreamTypes.VIDEO;o&&this.afterBufferFlushed(o,b,u.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,g)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(e=y.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=y.decryptdata)&&void 0!==t&&t.key?this.loadFragment(y,g,m):this.loadKey(y,g))}}}},T.loadFragment=function(t,r,i){var n,a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===l.FragmentState.NOT_LOADED?"initSegment"===t.sn?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null===(n=this.media)||void 0===n?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},T.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},T.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},T.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},T.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},T.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!t.paused&&e){var n=e[this.hls.nextLoadLevel],a=this.fragLastKbps;r=a&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*a)+1:0}else r=0;var s=this.getBufferedFrag(t.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,c=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},T.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,null!=e&&e.loader&&e.loader.abort(),this.state){case n.State.KEY_LOADING:case n.State.FRAG_LOADING:case n.State.FRAG_LOADING_WAITING_RETRY:case n.State.PARSING:case n.State.PARSED:this.state=n.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},T.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},T.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,i,this.fragmentTracker,this.hls)},T.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},T.onMediaPlaying=function(){this.tick()},T.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;(0,i.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},T.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},T.onManifestParsed=function(e,t){var r,i=!1,n=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n&&!(0,a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},T.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},T.onLevelLoaded=function(e,t){var r,i=this.levels,a=t.level,o=t.details,l=o.totalduration;if(i){this.log("Level "+a+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==n.State.FRAG_LOADING&&this.state!==n.State.FRAG_LOADING_WAITING_RETRY||u.level!==t.level&&u.loader&&(this.state=n.State.IDLE,this.backtrackFragment=null,u.loader.abort());var c=i[a],d=0;if(o.live||null!==(r=c.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,c.details)}if(c.details=o,this.levelLastLoaded=a,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:o,level:a}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=n.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}else this.warn("Levels were reset while loading level "+a)},T._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(o){var l=s.videoCodec,c=o.PTSKnown||!o.live,f=null===(t=r.initSegment)||void 0===t?void 0:t.data,g=this._getAudioCodec(s),p=this.transmuxer=this.transmuxer||new d.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),v=i?i.index:-1,m=-1!==v,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,v,m),A=this.initPTS[r.cc];p.push(n,f,g,l,r,i,o.totalduration,c,y,A)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},T.onAudioTrackSwitching=function(e,t){var r=this.altAudio,i=!!t.url,n=t.id;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;null!=a&&a.loader&&(this.log("Switching to main audio track, cancel main fragment load"),a.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})}},T.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},T.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},T.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},T.onError=function(e,t){switch(t.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=n.State.ERROR):t.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if("main"===t.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},T.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(e).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},T.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},T.onBufferFlushed=function(e,t){var r=t.type;if(r!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,u.PlaylistLevelType.MAIN)}},T.onLevelsUpdated=function(e,t){this.levels=t.levels},T.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},T.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=o.BufferHelper.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},T._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},T._loadBitrateTestFrag=function(e){var t=this;e.bitrateTest=!0,this._doFragLoad(e).then((function(r){var i=t.hls;if(r&&!i.nextLoadLevel&&!t.fragContextChanged(e)){t.fragLoadError=0,t.state=n.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(s.Events.FRAG_LOADED,r),e.bitrateTest=!1}}))},T._handleTransmuxComplete=function(e){var t,r="main",a=this.hls,o=e.remuxResult,l=e.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(l.level);var d=u.frag,h=u.part,f=u.level,g=o.video,p=o.text,v=o.id3,m=o.initSegment,y=f.details,A=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(d)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,d,l),a.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:d,id:r,tracks:m.tracks}));var E=m.initPTS,T=m.timescale;(0,i.isFiniteNumber)(E)&&(this.initPTS[d.cc]=E,a.trigger(s.Events.INIT_PTS_FOUND,{frag:d,id:r,initPTS:E,timescale:T}))}if(g&&!1!==o.independent){if(y){var b=g.startPTS,S=g.endPTS,_=g.startDTS,k=g.endDTS;if(h)h.elementaryStreams[g.type]={startPTS:b,endPTS:S,startDTS:_,endDTS:k};else if(g.firstKeyFrame&&g.independent&&(this.couldBacktrack=!0),g.dropped&&g.independent){var L=this.getMainFwdBufferInfo();if((L?L.end:this.getLoadPosition())+this.config.maxBufferHole<(g.firstKeyFramePTS?g.firstKeyFramePTS:b)-this.config.maxBufferHole)return void this.backtrack(d);d.setElementaryStreamInfo(g.type,d.start,S,d.start,k,!0)}d.setElementaryStreamInfo(g.type,b,S,_,k),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(g,d,h,l)}}else if(!1===o.independent)return void this.backtrack(d);if(A){var D=A.startPTS,R=A.endPTS,C=A.startDTS,I=A.endDTS;h&&(h.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:D,endPTS:R,startDTS:C,endDTS:I}),d.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,D,R,C,I),this.bufferFragmentData(A,d,h,l)}if(y&&null!=v&&null!==(t=v.samples)&&void 0!==t&&t.length){var O={id:r,frag:d,details:y,samples:v.samples};a.trigger(s.Events.FRAG_PARSING_METADATA,O)}if(y&&p){var w={id:r,frag:d,details:y,samples:p.samples};a.trigger(s.Events.FRAG_PARSING_USERDATA,w)}}},T._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===n.State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var c=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===d.indexOf("firefox")&&(c="mp4a.40.5")),-1!==d.indexOf("android")&&"audio/mpeg"!==o.container&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),e.audioCodec&&e.audioCodec!==c&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(e.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(s.Events.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},T.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},T.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=n.State.IDLE},T.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(o.BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):o.BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n&&t.urlId===i.urlId||(this.hls.trigger(s.Events.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:n}),this.fragPlaying=t)}}},y=m,(A=[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&(0,i.isFiniteNumber)(t)&&(0,i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+1e3*(t-r.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&p(y.prototype,A),E&&p(y,E),Object.defineProperty(y,"prototype",{writable:!1}),m}(n.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
62
|
+
/*!******************************************************!*\
|
|
63
|
+
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
64
|
+
\******************************************************/(e,t,r)=>{r.r(t),r.d(t,{SubtitleStreamController:()=>g});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),s=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../types/level */"./src/types/level.ts");function h(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}var g=function(e){var t,r;function g(t,r){var i;return(i=e.call(this,t,r,"[subtitle-stream-controller]")||this).levels=[],i.currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i._registerListeners(),i}r=e,(t=g).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r);var v,m,y,A=g.prototype;return A.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},A._registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(i.Events.ERROR,this.onError,this),e.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A._unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(i.Events.ERROR,this.onError,this),e.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A.startLoad=function(e){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},A.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},A.onLevelLoaded=function(e,t){this.mainDetails=t.details},A.onSubtitleFragProcessed=function(e,t){var r=t.frag,i=t.success;if(this.fragPrevious=r,this.state=u.State.IDLE,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}}},A.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,a=this.levels;if(!a.length||!a[n]||!a[n].details)return;var s=i-a[n].details.targetduration;if(s<=0)return;t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=s)e.shift();else{if(!(e[t].start<s))break;e[t].start=s,t++}})),this.fragmentTracker.removeFragmentsInRange(r,s,c.PlaylistLevelType.SUBTITLE)}},A.onFragBuffered=function(e,t){var r;this.loadedmetadata||t.frag.type!==c.PlaylistLevelType.MAIN||null!==(r=this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},A.onError=function(e,t){var r,i=t.frag;i&&i.type===c.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},A.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks;this.tracksBuffered=[],this.levels=i.map((function(e){return new d.Level(e)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(e){r.tracksBuffered[e.id]=[]})),this.mediaBuffer=null},A.onSubtitleTrackSwitch=function(e,t){if(this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)}else this.clearInterval()},A.onSubtitleTrackLoaded=function(e,t){var r,i=t.details,n=t.id,l=this.currentTrackId,c=this.levels;if(c.length){var d=c[l];if(!(n>=c.length||n!==l)&&d){this.mediaBuffer=this.mediaBufferTimeRanges;var h=0;if(i.live||null!==(r=d.details)&&void 0!==r&&r.live){var f=this.mainDetails;if(i.deltaUpdateFailed||!f)return;var g=f.fragments[0];d.details?0===(h=this.alignPlaylists(i,d.details))&&g&&(h=g.start,(0,o.addSliding)(i,h)):i.hasProgramDateTime&&f.hasProgramDateTime?((0,s.alignMediaPlaylistByPDT)(i,f),h=i.fragments[0].start):g&&(h=g.start,(0,o.addSliding)(i,h))}d.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(d.details,h),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&((0,a.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0))}}},A._handleFragmentLoadComplete=function(e){var t=e.frag,r=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).then((function(e){var r=performance.now();a.trigger(i.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:s,tdecrypt:r}})}))}},A.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var e=this.currentTrackId,t=this.levels;if(!t.length||!t[e]||!t[e].details)return;var r=t[e].details,i=r.targetduration,s=this.config,o=this.getLoadPosition(),d=n.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-i,s.maxBufferHole),h=d.end,f=d.len,g=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);if(f>this.getMaxBufferLength(null==g?void 0:g.len)+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var p,v=r.fragments,m=v.length,y=r.edge,A=this.fragPrevious;if(h<y){var E=s.maxFragLookUpTolerance;!(p=(0,a.findFragmentByPTS)(A,v,Math.max(v[0].start,h),E))&&A&&A.start<v[0].start&&(p=v[0])}else p=v[m-1];if(!(p=this.mapToInitFragWhenRequired(p)))return;if(this.fragmentTracker.getState(p)!==l.FragmentState.NOT_LOADED)return;p.encrypted?this.loadKey(p,r):this.loadFragment(p,r,h)}}else this.state=u.State.IDLE},A.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},A.loadFragment=function(t,r,i){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i))},v=g,(m=[{key:"mediaBufferTimeRanges",get:function(){return new p(this.tracksBuffered[this.currentTrackId]||[])}}])&&h(v.prototype,m),y&&h(v,y),Object.defineProperty(v,"prototype",{writable:!1}),g}(u.default),p=function(e){this.buffered=void 0;var t=function(t,r,i){if((r>>>=0)>i-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return e[r][t]};this.buffered={get length(){return e.length},end:function(r){return t("end",r,e.length)},start:function(r){return t("start",r,e.length)}}}},"./src/controller/subtitle-track-controller.ts":
|
|
65
|
+
/*!*****************************************************!*\
|
|
66
|
+
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
67
|
+
\*****************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,d,h,f=a.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},f.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(i.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(i.Events.ERROR,this.onError,this)},f.onMediaAttached=function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},f.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},f.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(e){(0,n.clearCurrentCues)(e)})),this.subtitleTrack=-1,this.media=null)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},f.onSubtitleTrackLoaded=function(e,t){var r=t.id,i=t.details,n=this.trackId,a=this.tracksInGroup[n];if(a){var s=a.details;a.details=t.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,s))}else this.warn("Invalid subtitle track id "+r)},f.onLevelLoading=function(e,t){this.switchLevel(t.level)},f.onLevelSwitching=function(e,t){this.switchLevel(t.level)},f.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.textGroupIds){var r=t.textGroupIds[t.urlId];if(this.groupId!==r){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=a;var s=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==s&&this.setSubtitleTrack(s,n)}}},f.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1},f.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,n=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:n,deliveryDirectives:e||null})}},f.toggleTrackModes=function(e){var t=this,r=this.media,i=this.trackId;if(r){var n=c(r.textTracks),a=n.filter((function(e){return e.groupId===t.groupId}));if(-1===e)[].slice.call(n).forEach((function(e){e.mode="disabled"}));else{var s=a[i];s&&(s.mode="disabled")}var o=a[e];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}},f.setSubtitleTrack=function(e,t){var r,n=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!==(r=n[e])&&void 0!==r&&r.details)||e<-1||e>=n.length)){this.clearTimer();var a=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var s=a.id,o=a.groupId,l=void 0===o?"":o,u=a.name,c=a.type,d=a.url;this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:s,groupId:l,name:u,type:c,url:d});var h=this.switchParams(a.url,null==t?void 0:t.details);this.loadPlaylist(h)}else this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},f.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},u=a,(d=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}])&&o(u.prototype,d),h&&o(u,h),Object.defineProperty(u,"prototype",{writable:!1}),a}(a.default);function c(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}const d=u},"./src/controller/timeline-controller.ts":
|
|
68
|
+
/*!***********************************************!*\
|
|
69
|
+
!*** ./src/controller/timeline-controller.ts ***!
|
|
70
|
+
\***********************************************/(e,t,r)=>{r.r(t),r.d(t,{TimelineController:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),s=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=r(/*! ../types/loader */"./src/types/loader.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=function(){function e(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new s.default(this,"textTrack1"),r=new s.default(this,"textTrack2"),i=new s.default(this,"textTrack3"),o=new s.default(this,"textTrack4");this.cea608Parser1=new a.default(1,t,r),this.cea608Parser2=new a.default(3,i,o)}e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(n.Events.FRAG_LOADING,this.onFragLoading,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(n.Events.FRAG_LOADING,this.onFragLoading,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,r,i,a){for(var s,o,l,u,c=!1,d=a.length;d--;){var h=a[d],f=(s=h[0],o=h[1],l=t,u=r,Math.min(o,u)-Math.max(s,l));if(f>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),c=!0,f/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var g=this.captionsTracks[e];this.Cues.newCue(g,t,r,i)}else{var p=this.Cues.newCue(null,t,r,i);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:p,track:e})}},t.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,s=t.initPTS,o=t.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[i.cc]=s,this.timescale[i.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(e){r.onFragLoaded(n.Events.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,n=t[e],a=n.label,s=n.languageCode,o=this.getExistingTrack(e);if(o)r[e]=o,(0,l.clearCurrentCues)(r[e]),(0,l.sendAddTrackEvent)(r[e],i);else{var u=this.createTextTrack("captions",a,s);u&&(u[e]=!0,r[e]=u)}}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},t.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){(0,l.clearCurrentCues)(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)(0,l.clearCurrentCues)(t[r])}},t.onSubtitleTracksUpdated=function(e,t){var r=this;this.textTracks=[];var i=t.subtitleTracks||[],a=i.some((function(e){return e.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var s=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,t){var i;if(t<o.length){for(var n=null,a=0;a<o.length;a++)if(g(o[a],e)){n=o[a];break}n&&(i=n)}if(i)(0,l.clearCurrentCues)(i);else{var s=r._captionsOrSubtitlesFromCharacteristics(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&(i.groupId=e.groupId,r.textTracks.push(i))}))}else if(!s&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},t._captionsOrSubtitlesFromCharacteristics=function(e){var t;if(null!==(t=e.attrs)&&void 0!==t&&t.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(r&&i)return"captions"}return"subtitles"},t.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i="textTrack"+t[1],n=r.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}}))},t.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]},t.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,n=this.lastSn,a=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===d.PlaylistLevelType.MAIN){var s,o,l=t.frag.sn,u=null!=(s=null==t||null===(o=t.part)||void 0===o?void 0:o.index)?s:-1;l===n+1||l===n&&u===a+1||(r.reset(),i.reset()),this.lastSn=l,this.lastPartIndex=u}},t.onFragLoaded=function(e,t){var r=t.frag,a=t.payload,s=this.initPTS,o=this.unparsedVttFrags;if(r.type===d.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!(0,i.isFiniteNumber)(s[r.cc]))return o.push(t),void(s.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,c="stats"in t;if(null==l||null==l.key||"AES-128"!==l.method||c){var h=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),h&&h.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,a):this._parseVTTs(r,a,f)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var r=this,i=this.hls;(0,u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){h.logger.log("Failed to parse IMSC1: "+t),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e,t,r){var i,a=this,s=this.hls,l=null!==(i=e.initSegment)&&void 0!==i&&i.data?(0,c.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t;(0,o.parseWebVTT)(l,this.initPTS[e.cc],this.timescale[e.cc],r,e.cc,e.start,(function(t){a._appendCues(t,e.level),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(r){a._fallbackToIMSC1(e,t),h.logger.log("Failed to parse VTT cue: "+r),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})}))},t._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||(0,u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(){i.textCodec=u.IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))},t._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach((function(e){return(0,l.addCueToTrack)(i,e)}))}else{var a=this.tracks[t];if(!a)return;var s=a.default?"default":"subtitles"+t;r.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:e,track:s})}},t.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===d.PlaylistLevelType.SUBTITLE){if(!(0,i.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(n.Events.FRAG_LOADED,t)}},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var n=t.frag,a=t.samples;if(n.type!==d.PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(n))for(var s=0;s<a.length;s++){var o=a[s].bytes;if(o){var l=this.extractCea608Data(o);r.addData(a[s].pts,l[0]),i.addData(a[s].pts,l[1])}}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return(0,l.removeCuesInRange)(o[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u=this.textTracks;Object.keys(u).forEach((function(e){return(0,l.removeCuesInRange)(u[e],r,n)}))}}},t.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if((0!==s||0!==o)&&0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t},e}();function g(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}},"./src/crypt/aes-crypto.ts":
|
|
71
|
+
/*!*********************************!*\
|
|
72
|
+
!*** ./src/crypt/aes-crypto.ts ***!
|
|
73
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}()},"./src/crypt/aes-decryptor.ts":
|
|
74
|
+
/*!************************************!*\
|
|
75
|
+
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
76
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a,removePadding:()=>n});var i=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?(0,i.sliceUint8)(e,0,t-r):e}var a=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],h=new Uint32Array(256),f=0,g=0,p=0;for(p=0;p<256;p++)h[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var v=g^g<<1^g<<2^g<<3^g<<4;v=v>>>8^255&v^99,e[f]=v,t[v]=f;var m=h[f],y=h[m],A=h[y],E=257*h[v]^16843008*v;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*A^65537*y^257*m^16843008*f,l[v]=E<<24|E>>>8,u[v]=E<<16|E>>>16,c[v]=E<<8|E>>>24,d[v]=E,f?(f=m^h[h[h[A^m]]],g^=h[h[g]]):f=g=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),d=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,g=this.invSubMix,p=g[0],v=g[1],m=g[2],y=g[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],d[s]=s<4||a<=4?l:p[h[l>>>24]]^v[h[l>>>16&255]]^m[h[l>>>8&255]]^y[h[255&l]],d[s]=d[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,l,u,c,d,h,f,g,p,v,m=this.keySize+6,y=this.invKeySchedule,A=this.invSBox,E=this.invSubMix,T=E[0],b=E[1],S=E[2],_=E[3],k=this.uint8ArrayToUint32Array_(r),L=k[0],D=k[1],R=k[2],C=k[3],I=new Int32Array(e),O=new Int32Array(I.length),w=this.networkToHostOrderSwap;t<I.length;){for(d=w(I[t]),h=w(I[t+1]),f=w(I[t+2]),g=w(I[t+3]),o=d^y[0],l=g^y[1],u=f^y[2],c=h^y[3],p=4,v=1;v<m;v++)i=T[o>>>24]^b[l>>16&255]^S[u>>8&255]^_[255&c]^y[p],n=T[l>>>24]^b[u>>16&255]^S[c>>8&255]^_[255&o]^y[p+1],a=T[u>>>24]^b[c>>16&255]^S[o>>8&255]^_[255&l]^y[p+2],s=T[c>>>24]^b[o>>16&255]^S[l>>8&255]^_[255&u]^y[p+3],o=i,l=n,u=a,c=s,p+=4;i=A[o>>>24]<<24^A[l>>16&255]<<16^A[u>>8&255]<<8^A[255&c]^y[p],n=A[l>>>24]<<24^A[u>>16&255]<<16^A[c>>8&255]<<8^A[255&o]^y[p+1],a=A[u>>>24]<<24^A[c>>16&255]<<16^A[o>>8&255]<<8^A[255&l]^y[p+2],s=A[c>>>24]<<24^A[o>>16&255]<<16^A[l>>8&255]<<8^A[255&u]^y[p+3],O[t]=w(i^L),O[t+1]=w(s^D),O[t+2]=w(a^R),O[t+3]=w(n^C),L=d,D=h,R=f,C=g,t+=4}return O.buffer},e}()},"./src/crypt/decrypter.ts":
|
|
77
|
+
/*!********************************!*\
|
|
78
|
+
!*** ./src/crypt/decrypter.ts ***!
|
|
79
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),a=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(e,t,r){var i=(void 0===r?{}:r).removePKCS7Padding,n=void 0===i||i;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=e,this.config=t,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var t=e.prototype;return t.destroy=function(){this.observer=null},t.isSync=function(){return this.config.enableSoftwareAES},t.flush=function(){var e=this.currentResult;if(e){var t=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(0,a.removePadding)(t):t}this.reset()},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(e),t,r);var n=this.flush();n&&i(n.buffer)}else this.webCryptoDecrypt(new Uint8Array(e),t,r).then(i)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=(0,o.appendUint8Array)(s,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;i&&(r=i);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new a.default),c.expandKey(t);var d=n;return this.currentResult=c.decrypt(u.buffer,0,r),this.currentIV=(0,l.sliceUint8)(u,-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,r){var a=this,s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new n.default(s,t)),this.fastAesKey.expandKey().then((function(t){return s?new i.default(s,r).decrypt(e.buffer,t):Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){return a.onWebCryptoError(i,e,t,r)}))},t.onWebCryptoError=function(e,t,r,i){return s.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",e),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,i)},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=(0,l.sliceUint8)(e,0,r),this.remainderData=(0,l.sliceUint8)(e,r)),t},t.logOnce=function(e){this.logEnabled&&(s.logger.log("[decrypter.ts]: "+e),this.logEnabled=!1)},e}()},"./src/crypt/fast-aes-key.ts":
|
|
80
|
+
/*!***********************************!*\
|
|
81
|
+
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
82
|
+
\***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}()},"./src/demux/aacdemuxer.ts":
|
|
83
|
+
/*!*********************************!*\
|
|
84
|
+
!*** ./src/demux/aacdemuxer.ts ***!
|
|
85
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ./adts */"./src/demux/adts.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}const l=function(e){var t,r;function i(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(n.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(e,t){return n.canParse(e,t)},l.appendFrame=function(e,t,r){n.initTrackConfig(e,this.observer,t,r,e.manifestCodec);var i=n.appendFrame(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},i}(i.default)},"./src/demux/adts.ts":
|
|
86
|
+
/*!***************************!*\
|
|
87
|
+
!*** ./src/demux/adts.ts ***!
|
|
88
|
+
\***************************/(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>m,canGetFrameLength:()=>c,canParse:()=>h,getAudioConfig:()=>s,getFrameDuration:()=>p,getFullFrameLength:()=>u,getHeaderLength:()=>l,initTrackConfig:()=>g,isHeader:()=>d,isHeaderPattern:()=>o,parseFrameHeader:()=>v,probe:()=>f});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts");function s(e,t,r,s){var o,l,u,c,d=navigator.userAgent.toLowerCase(),h=s,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&t[r+2])>>>6);var g=(60&t[r+2])>>>2;if(!(g>f.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,i.logger.log("manifest codec:"+s+", ADTS type:"+o+", samplingIndex:"+g),/firefox/i.test(d)?g>=6?(o=5,c=new Array(4),l=g-3):(o=2,c=new Array(2),l=g):-1!==d.indexOf("android")?(o=2,c=new Array(2),l=g):(o=5,c=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&g>=6?l=g-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(g>=6&&1===u||/vivaldi/i.test(d))||!s&&1===u)&&(o=2,c=new Array(2)),l=g)),c[0]=o<<3,c[0]|=(14&g)>>1,c[1]|=(1&g)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&l)>>1,c[2]=(1&l)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:f[g],channelCount:u,codec:"mp4a.40."+o,manifestCodec:h};e.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+g})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function c(e,t){return t+5<e.length}function d(e,t){return t+1<e.length&&o(e,t)}function h(e,t){return c(e,t)&&o(e,t)&&u(e,t)<=e.length-t}function f(e,t){if(d(e,t)){var r=l(e,t);if(t+r>=e.length)return!1;var i=u(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||d(e,n)}return!1}function g(e,t,r,n,a){if(!e.samplerate){var o=s(t,r,n,a);if(!o)return;e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+e.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(e){return 9216e4/e}function v(e,t){var r=l(e,t);if(t+r<=e.length){var i=u(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}function m(e,t,r,i,n){var a,s=i+n*p(e.samplerate),o=v(t,r);if(o){var l=o.frameLength,u=o.headerLength,c=u+l,d=Math.max(0,r+c-t.length);d?(a=new Uint8Array(c-u)).set(t.subarray(r+u,t.length),0):a=t.subarray(r+u,r+c);var h={unit:a,pts:s};return d||e.samples.push(h),{sample:h,length:c,missing:d}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}},"./src/demux/base-audio-demuxer.ts":
|
|
89
|
+
/*!*****************************************!*\
|
|
90
|
+
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
91
|
+
\*****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d,initPTSFn:()=>c});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=(0,o.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,u=n.getID3Data(e,0),d=u?u.length:0,h=this._audioTrack,f=this._id3Track,g=u?n.getTimeStamp(u):void 0,p=e.length;for((null===this.basePTS||0===this.frameIndex&&(0,i.isFiniteNumber)(g))&&(this.basePTS=c(g,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),u&&u.length>0&&f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});d<p;){if(this.canParse(e,d)){var v=this.appendFrame(h,e,d);v?(this.frameIndex++,this.lastPTS=v.sample.pts,r=d+=v.length):d=p}else n.canParse(e,d)?(u=n.getID3Data(e,d),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=d+=u.length):d++;if(d===p&&r!==p){var m=(0,l.sliceUint8)(e,r);this.cachedData?this.cachedData=(0,o.appendUint8Array)(this.cachedData,m):this.cachedData=m}}return{audioTrack:h,videoTrack:(0,s.dummyTrack)(),id3Track:f,textTrack:(0,s.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:(0,s.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,s.dummyTrack)()}},t.destroy=function(){},e}(),c=function(e,t,r){return(0,i.isFiniteNumber)(e)?90*e:9e4*t+(r||0)};const d=u},"./src/demux/chunk-cache.ts":
|
|
92
|
+
/*!**********************************!*\
|
|
93
|
+
!*** ./src/demux/chunk-cache.ts ***!
|
|
94
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}()},"./src/demux/dummy-demuxed-track.ts":
|
|
95
|
+
/*!******************************************!*\
|
|
96
|
+
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
97
|
+
\******************************************/(e,t,r)=>{function i(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}r.r(t),r.d(t,{dummyTrack:()=>i})},"./src/demux/exp-golomb.ts":
|
|
98
|
+
/*!*********************************!*\
|
|
99
|
+
!*** ./src/demux/exp-golomb.ts ***!
|
|
100
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/logger */"./src/utils/logger.ts");const n=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),d=this.skipBits.bind(this),h=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();var p=o();if(l(5),d(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var v=u();if(3===v&&d(1),f(),f(),d(1),c())for(t=3!==v?8:12,r=0;r<t;r++)c()&&g(r<6?16:64)}f();var m=u();if(0===m)u();else if(1===m)for(d(1),h(),h(),e=u(),r=0;r<e;r++)h();f(),d(1);var y=u(),A=u(),E=l(1);0===E&&d(1),d(1),c()&&(i=u(),n=u(),a=u(),s=u());var T=[1,1];if(c()&&c())switch(o()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-E)*(A+1)*16-(E?2:4)*(a+s),pixelRatio:T}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}()},"./src/demux/id3.ts":
|
|
42
101
|
/*!**************************!*\
|
|
43
|
-
!*** ./src/demux/id3.
|
|
44
|
-
\**************************/
|
|
45
|
-
|
|
102
|
+
!*** ./src/demux/id3.ts ***!
|
|
103
|
+
\**************************/(e,t,r)=>{r.r(t),r.d(t,{canParse:()=>l,decodeFrame:()=>f,getID3Data:()=>s,getID3Frames:()=>h,getTimeStamp:()=>u,isFooter:()=>a,isHeader:()=>n,isTimeStampFrame:()=>c,testables:()=>A,utf8ArrayToStr:()=>y});var i,n=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},a=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s=function(e,t){for(var r=t,i=0;n(e,t);)i+=10,i+=o(e,t+6),a(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},o=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},l=function(e,t){return n(e,t)&&o(e,t+6)+10<=e.length-t},u=function(e){for(var t=h(e),r=0;r<t.length;r++){var i=t[r];if(c(i))return m(i)}},c=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},d=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},h=function(e){for(var t=0,r=[];n(e,t);){for(var i=o(e,t+6),s=(t+=10)+i;t+8<s;){var l=d(e.subarray(t)),u=f(l);u&&r.push(u),t+=l.size+10}a(e,t)&&(t+=10)}return r},f=function(e){return"PRIV"===e.type?g(e):"W"===e.type[0]?v(e):p(e)},g=function(e){if(!(e.size<2)){var t=y(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},p=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data.subarray(1));return{key:e.type,data:n}}},v=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data);return{key:e.type,data:n}},m=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(e,t){void 0===t&&(t=!1);var r=E();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",c=0;c<l;){if(0===(a=e[c++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[c++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[c++],o=e[c++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u},A={decodeTextFrame:p};function E(){return i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":
|
|
104
|
+
/*!*********************************!*\
|
|
105
|
+
!*** ./src/demux/mp3demuxer.ts ***!
|
|
106
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}var l=function(e){var t,r;function i(){return e.apply(this,arguments)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(s.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(e,t){return s.canParse(e,t)},l.appendFrame=function(e,t,r){if(null!==this.basePTS)return s.appendFrame(e,t,r,this.basePTS,this.frameIndex)},i}(i.default);const u=l},"./src/demux/mp4demuxer.ts":
|
|
46
107
|
/*!*********************************!*\
|
|
47
|
-
!*** ./src/demux/mp4demuxer.
|
|
48
|
-
\*********************************/
|
|
49
|
-
|
|
108
|
+
!*** ./src/demux/mp4demuxer.ts ***!
|
|
109
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;const l=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=(0,a.parseInitSegment)(e),o=this.videoTrack=(0,s.dummyTrack)("video",1),l=this.audioTrack=(0,s.dummyTrack)("audio",1),u=this.txtTrack=(0,s.dummyTrack)("text",1);if(this.id3Track=(0,s.dummyTrack)("id3",1),this.timeOffset=0,n.video){var c=n.video,d=c.id,h=c.timescale,f=c.codec;o.id=d,o.timescale=u.timescale=h,o.codec=f}if(n.audio){var g=n.audio,p=g.id,v=g.timescale,m=g.codec;l.id=p,l.timescale=v,l.codec=m}u.id=a.RemuxerTrackIdConfig.text,o.sampleDuration=0,o.duration=l.duration=i},t.resetContiguity=function(){},e.probe=function(e){return e=e.length>16384?e.subarray(0,16384):e,(0,a.findBox)(e,["moof"]).length>0},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=(0,a.appendUint8Array)(this.remainderData,e));var s=(0,a.segmentValidRange)(r);this.remainderData=s.remainder,i.samples=s.valid||new Uint8Array}else i.samples=r;var o=this.extractID3Track(i,t);return n.samples=(0,a.parseSamples)(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=(0,a.parseSamples)(e,t),{videoTrack:t,audioTrack:(0,s.dummyTrack)(),id3Track:i,textTrack:(0,s.dummyTrack)()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=(0,a.findBox)(e.samples,["emsg"]);s&&s.forEach((function(e){var s=(0,a.parseEmsg)(e);if(o.test(s.schemeIdUri)){var l=(0,i.isFiniteNumber)(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale,u=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var c=s.payload;r.samples.push({data:c,len:c.byteLength,dts:l,pts:l,type:n.MetadataSchema.emsg,duration:u})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}()},"./src/demux/mpegaudio.ts":
|
|
110
|
+
/*!********************************!*\
|
|
111
|
+
!*** ./src/demux/mpegaudio.ts ***!
|
|
112
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>l,canParse:()=>h,isHeader:()=>d,isHeaderPattern:()=>c,parseHeader:()=>u,probe:()=>f});var i=null,n=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t,r,i,n){if(!(r+24>t.length)){var a=u(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function u(e,t){var r=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,c=e[t+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==c){var d=e[t+2]>>1&1,h=e[t+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+u-1],g=a[3*(3===r?0:2===r?1:2)+c],p=3===h?1:2,v=s[r][l],m=o[l],y=8*v*m,A=Math.floor(v*f/g+d)*m;if(null===i){var E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=E?parseInt(E[1]):0}return!!i&&i<=87&&2===l&&f>=224e3&&0===h&&(e[t+3]=128|e[t+3]),{sampleRate:g,channelCount:p,frameLength:A,samplesPerFrame:y}}}function c(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function d(e,t){return t+1<e.length&&c(e,t)}function h(e,t){return c(e,t)&&4<=e.length-t}function f(e,t){if(t+1<e.length&&c(e,t)){var r=u(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||d(e,n)}return!1}},"./src/demux/sample-aes.ts":
|
|
113
|
+
/*!*********************************!*\
|
|
114
|
+
!*** ./src/demux/sample-aes.ts ***!
|
|
115
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");const a=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,t)},t.decryptAacSample=function(e,t,r,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(s,(function(a){var s=new Uint8Array(a);n.set(s,16),i||o.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,a,s){var o=(0,n.discardEPB)(a.data),l=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(l.buffer,(function(n){a.data=u.getAvcDecryptedUnit(o,n),s||u.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,a,s),!s)return}}}},e}()},"./src/demux/transmuxer-interface.ts":
|
|
116
|
+
/*!*******************************************!*\
|
|
117
|
+
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
118
|
+
\*******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ./webworkify-webpack */"./src/demux/webworkify-webpack.js"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=(0,l.getMediaSource)()||{isTypeSupported:function(){return!1}},d=function(){function e(e,t,r,l){var d=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var h=e.config;this.hls=e,this.id=t,this.useWorker=!!h.enableWorker,this.onTransmuxComplete=r,this.onFlush=l;var f=function(e,t){(t=t||{}).frag=d.frag,t.id=d.id,d.hls.trigger(e,t)};this.observer=new u.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var g={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){var v;s.logger.log("demuxing in webworker");try{v=this.worker=(0,i.default)(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(e){d.useWorker=!1,s.logger.warn("Exception in webworker, fallback to inline"),d.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},v.postMessage({cmd:"init",typeSupported:g,vendor:p,id:t,config:JSON.stringify(h)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new a.default(this.observer,g,h,p,t),this.worker=null}}else this.transmuxer=new a.default(this.observer,g,h,p,t)}var t=e.prototype;return t.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},t.push=function(e,t,r,i,n,o,l,u,c,d){var h,f,g=this;c.transmuxing.start=self.performance.now();var p=this.transmuxer,v=this.worker,m=o?o.start:n.start,y=n.decryptdata,A=this.frag,E=!(A&&n.cc===A.cc),T=!(A&&c.level===A.level),b=A?c.sn-A.sn:-1,S=this.part?c.part-this.part.index:-1,_=0===b&&c.id>1&&c.id===(null==A?void 0:A.stats.chunkCount),k=!T&&(1===b||0===b&&(1===S||_&&S<=0)),L=self.performance.now();(T||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=L),!o||!S&&k||(o.stats.parsing.start=L);var D=!(A&&(null===(h=n.initSegment)||void 0===h?void 0:h.url)===(null===(f=A.initSegment)||void 0===f?void 0:f.url)),R=new a.TransmuxState(E,k,u,T,m,D);if(!k||E||D){s.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+E+"\n trackSwitch: "+T+"\n contiguous: "+k+"\n accurateTimeOffset: "+u+"\n timeOffset: "+m+"\n initSegmentChange: "+D);var C=new a.TransmuxConfig(r,i,t,l,d);this.configureTransmuxer(C)}if(this.frag=n,this.part=o,v)v.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:c,state:R},e instanceof ArrayBuffer?[e]:[]);else if(p){var I=p.push(e,y,c,R);(0,a.isPromise)(I)?I.then((function(e){g.handleTransmuxComplete(e)})):this.handleTransmuxComplete(I)}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:e});else if(r){var n=r.flush(e);(0,a.isPromise)(n)?n.then((function(r){t.handleFlushResult(r,e)})):this.handleFlushResult(n,e)}},t.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":s.logger[t.data.logType]&&s.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}()},"./src/demux/transmuxer-worker.ts":
|
|
119
|
+
/*!****************************************!*\
|
|
120
|
+
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
121
|
+
\****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(e){var t=new s.EventEmitter,r=function(t,r){e.postMessage({event:t,data:r})};t.on(n.Events.FRAG_DECRYPTED,r),t.on(n.Events.ERROR,r),e.addEventListener("message",(function(n){var s=n.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.transmuxer=new i.default(t,s.typeSupported,o,s.vendor,s.id),(0,a.enableLogs)(o.debug,s.id),function(){var e=function(e){a.logger[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in a.logger)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(s.config);break;case"demux":var u=e.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);(0,i.isPromise)(u)?u.then((function(t){l(e,t)})):l(e,u);break;case"flush":var d=s.chunkMeta,h=e.transmuxer.flush(d);(0,i.isPromise)(h)?h.then((function(t){c(e,t,d)})):c(e,h,d)}}))}function l(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&u(i,a),s&&u(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function u(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(e,t,r){t.reduce((function(t,r){return l(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
|
|
122
|
+
/*!*********************************!*\
|
|
123
|
+
!*** ./src/demux/transmuxer.ts ***!
|
|
124
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{TransmuxConfig:()=>y,TransmuxState:()=>A,default:()=>p,isPromise:()=>m});var i,n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),d=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=r(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(e){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var g=[{demux:u.default,remux:d.default},{demux:l.default,remux:h.default},{demux:o.default,remux:d.default},{demux:c.default,remux:d.default}],p=function(){function e(e,t,r,i,n){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,n){var a=this,s=r.transmuxing;s.executeStart=i();var o=new Uint8Array(e),l=this.config,u=this.currentTransmuxState,c=this.transmuxConfig;n&&(this.currentTransmuxState=n);var d=n||u,h=d.contiguous,f=d.discontinuity,g=d.trackSwitch,p=d.accurateTimeOffset,m=d.timeOffset,y=d.initSegmentChange,A=c.audioCodec,E=c.videoCodec,T=c.defaultInitPts,b=c.duration,S=c.initSegmentData;(f||g||y)&&this.resetInitSegment(S,A,E,b),(f||y)&&this.resetInitialTimestamp(T),h||this.resetContiguity();var _=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(_&&"AES-128"===_.method){var k=this.getDecrypter();if(!l.enableSoftwareAES)return this.decryptionPromise=k.webCryptoDecrypt(o,_.key.buffer,_.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var L=k.softwareDecrypt(o,_.key.buffer,_.iv.buffer);if(!L)return s.executeEnd=i(),v(r);o=new Uint8Array(L)}this.needsProbing(o,f,g)&&this.configureTransmuxer(o,c);var D=this.transmux(o,_,m,p,r),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,s.executeEnd=i(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=i();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then((function(){return t.flush(e)}));var u=[],c=o.timeOffset;if(s){var d=s.flush();d&&u.push(this.push(d,null,e))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[v(e)];var g=h.flush(c);return m(g)?g.then((function(r){return t.flushRemux(u,r,e),u})):(this.flushRemux(u,g,e),u)},t.flushRemux=function(e,t,r){var n=t.audioTrack,a=t.videoTrack,s=t.id3Track,o=t.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,c=l.timeOffset;f.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(n,a,s,o,c,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=i()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i){var n=this.demuxer,a=this.remuxer;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e,t){for(var r,i=this.config,n=this.observer,a=this.typeSupported,s=this.vendor,o=t.audioCodec,u=t.defaultInitPts,c=t.duration,d=t.initSegmentData,p=t.videoCodec,v=0,m=g.length;v<m;v++)if(g[v].demux.probe(e)){r=g[v];break}r||(f.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:h.default});var y=this.demuxer,A=this.remuxer,E=r.remux,T=r.demux;A&&A instanceof E||(this.remuxer=new E(n,i,a,s)),y&&y instanceof T||(this.demuxer=new T(n,i,a),this.probe=T.probe),this.resetInitSegment(d,o,p,c),this.resetInitialTimestamp(u)},t.needsProbing=function(e,t,r){return!this.demuxer||!this.remuxer||t||r},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new s.default(this.observer,this.config)),e},e}(),v=function(e){return{remuxResult:{},chunkMeta:e}};function m(e){return"then"in e&&e.then instanceof Function}var y=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},A=function(e,t,r,i,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts":
|
|
125
|
+
/*!********************************!*\
|
|
126
|
+
!*** ./src/demux/tsdemuxer.ts ***!
|
|
127
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>A});var i=r(/*! ./adts */"./src/demux/adts.ts"),n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),a=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),s=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../errors */"./src/errors.ts"),d=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},h.apply(this,arguments)}var f=188;function g(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function p(e,t){return(31&e[t+10])<<8|e[t+11]}function v(e,t,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var s=(31&e[t+1])<<8|e[t+2];switch(e[t]){case 207:if(!i){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=s,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return n}function m(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var c=t[7];192&c&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&c?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(u.logger.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var d=(i=t[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),f=0,g=o.length;f<g;f++){var p=(t=o[f]).byteLength;if(d){if(d>p){d-=p;continue}t=t.subarray(d),p-=d,d=0}h.set(t,s),s+=p}return r&&(r-=i+3),{data:h,pts:n,dts:a,len:r}}return null}function y(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}const A=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return r>0&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=Math.min(940,e.length-376)+1,r=0;r<t;){if(71===e[r]&&71===e[r+f])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:l.RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._avcTrack,d=this._audioTrack,h=this._id3Track,g=this._txtTrack,y=s.pid,A=s.pesData,E=d.pid,T=h.pid,b=d.pesData,S=h.pesData,_=null,k=this.pmtParsed,L=this._pmtId,D=t.length;if(this.remainderData&&(D=(t=(0,l.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),D<f&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:s,id3Track:h,textTrack:g};var R=Math.max(0,e.syncOffset(t));(D-=(D-R)%f)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,D,t.buffer.byteLength-D));for(var C=0,I=R;I<D;I+=f)if(71===t[I]){var O=!!(64&t[I+1]),w=((31&t[I+1])<<8)+t[I+2],P=void 0;if((48&t[I+3])>>4>1){if((P=I+5+t[I+4])===I+f)continue}else P=I+4;switch(w){case y:O&&(A&&(a=m(A))&&this.parseAVCPES(s,g,a,!1),A={data:[],size:0}),A&&(A.data.push(t.subarray(P,I+f)),A.size+=I+f-P);break;case E:if(O){if(b&&(a=m(b)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,a);break;case"mp3":this.parseMPEGPES(d,a)}b={data:[],size:0}}b&&(b.data.push(t.subarray(P,I+f)),b.size+=I+f-P);break;case T:O&&(S&&(a=m(S))&&this.parseID3PES(h,a),S={data:[],size:0}),S&&(S.data.push(t.subarray(P,I+f)),S.size+=I+f-P);break;case 0:O&&(P+=t[P]+1),L=this._pmtId=p(t,P);break;case L:O&&(P+=t[P]+1);var x=v(t,P,this.typeSupported,i);(y=x.avc)>0&&(s.pid=y),(E=x.audio)>0&&(d.pid=E,d.segmentCodec=x.segmentCodec),(T=x.id3)>0&&(h.pid=T),null===_||k||(u.logger.log("unknown PID '"+_+"' in TS found"),_=null,I=R-188),k=this.pmtParsed=!0;break;case 17:case 8191:break;default:_=w}}else C++;C>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+C+" TS packet/s that do not start with 0x47"}),s.pesData=A,d.pesData=b,h.pesData=S;var N={audioTrack:d,videoTrack:s,id3Track:h,textTrack:g};return n&&this.extractRemainingSamples(N),N},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=m(s))?(this.parseAVCPES(i,a,t,!0),i.pesData=null):i.pesData=s,o&&(t=m(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=m(l))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new s.default(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAVCPES=function(e,t,r,i){var n,s=this,o=this.parseAVCNALu(e,r.data),u=this.avcSample,c=!1;r.data=null,u&&o.length&&!e.audFound&&(y(u,e),u=this.avcSample=g(!1,r.pts,r.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,u||(u=s.avcSample=g(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(c&&o.length>4){var d=new a.default(o).readSliceType();2!==d&&4!==d&&7!==d&&9!==d||(u.key=!0)}break;case 5:n=!0,u||(u=s.avcSample=g(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,(0,l.parseSEIMessageFromNALu)(i.data,1,r.pts,t.samples);break;case 7:if(n=!0,c=!0,!e.sps){var h=new a.default(i.data).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[i.data],e.duration=s._duration;for(var f=i.data.subarray(1,4),p="avc1.",v=0;v<3;v++){var m=f[v].toString(16);m.length<2&&(m="0"+m),p+=m}e.codec=p}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,u&&y(u,e),u=s.avcSample=g(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&n&&u.units.push(i)})),i&&u&&(y(u,e),this.avcSample=null)},t.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!==(t=i)&&void 0!==t&&t.units){var n=i.units;r=n[n.length-1]}return r},t.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],l=0,u=-1,c=0;for(-1===a&&(u=0,c=31&t[0],a=0,l=1);l<n;)if(r=t[l++],a)if(1!==a)if(r)if(1===r){if(u>=0){var d={data:t.subarray(u,l-a-1),type:c};o.push(d)}else{var h=this.getLastNalUnit(e.samples);if(h&&(s&&l<=4-s&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-s)),(i=l-a-1)>0)){var f=new Uint8Array(h.data.byteLength+i);f.set(h.data,0),f.set(t.subarray(0,i),h.data.byteLength),h.data=f,h.state=0}}l<n?(u=l,c=31&t[l],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(u>=0&&a>=0){var g={data:t.subarray(u,n),type:c,state:a};o.push(g)}if(0===o.length){var p=this.getLastNalUnit(e.samples);if(p){var v=new Uint8Array(p.data.byteLength+t.byteLength);v.set(p.data,0),v.set(t,p.data.byteLength),p.data=v}}return e.naluState=a,o},t.parseAACPES=function(e,t){var r,n,a,s,l,d=0,h=this.aacOverFlow,f=t.data;if(h){this.aacOverFlow=null;var g=h.missing,p=h.sample.unit.byteLength;if(-1===g){var v=new Uint8Array(p+f.byteLength);v.set(h.sample.unit,0),v.set(f,p),f=v}else{var m=p-g;h.sample.unit.set(f.subarray(0,g),m),e.samples.push(h.sample),d=h.missing}}for(r=d,n=f.length;r<n-1&&!i.isHeader(f,r);r++);if(r===d||(r<n-1?(a="AAC PES did not start with ADTS header,offset:"+r,s=!1):(a="no ADTS header found in AAC PES",s=!0),u.logger.warn("parsing error:"+a),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:a}),!s)){if(i.initTrackConfig(e,this.observer,f,r,this.audioCodec),void 0!==t.pts)l=t.pts;else{if(!h)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var y=i.getFrameDuration(e.samplerate);l=h.sample.pts+y}for(var A,E=0;r<n;){if(r+=(A=i.appendFrame(e,f,r,l,E)).length,A.missing){this.aacOverFlow=A;break}for(E++;r<n-1&&!i.isHeader(f,r);r++);}}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,s=0,o=t.pts;if(void 0!==o)for(;s<i;)if(n.isHeader(r,s)){var l=n.appendFrame(e,r,s,o,a);if(!l)break;s+=l.length,a++}else s++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=h({},t,{type:this._avcTrack?d.MetadataSchema.emsg:d.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}()},"./src/demux/webworkify-webpack.js":
|
|
128
|
+
/*!*****************************************!*\
|
|
129
|
+
!*** ./src/demux/webworkify-webpack.js ***!
|
|
130
|
+
\*****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=function(){var e=ENTRY_MODULE,t={},r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports};r.m=e,r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r(ENTRY_MODULE);return i.default||i}.toString().split("ENTRY_MODULE"),n="[\\.|\\-|\\+|\\w|/|@]+",a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,i){var o={};o[i]=[];var l=t.toString().replace(/^"[^"]+"/,"function"),u=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||l.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!u)return o;for(var c,d=u[1],h=new RegExp("(\\\\n|\\W)"+s(d)+a,"g");c=h.exec(l);)"dll-reference"!==c[3]&&o[i].push(c[3]);for(h=new RegExp("\\("+s(d)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+a,"g");c=h.exec(l);)e[c[2]]||(o[i].push(c[1]),e[c[2]]=r(c[1]).m),o[c[2]]=o[c[2]]||[],o[c[2]].push(c[4]);for(var f,g=Object.keys(o),p=0;p<g.length;p++)for(var v=0;v<o[g[p]].length;v++)f=o[g[p]][v],isNaN(1*f)||(o[g[p]][v]=1*o[g[p]][v]);return o}function l(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}function u(e,t,r,n){var a=e[n].map((function(e){return'"'+e+'": '+t[n][e].toString().replace(/^"[^"]+"/,"function")})).join(",");return i[0]+"{"+a+"}"+i[1]+'"'+r+'"'+i[2]}function c(e,t){t=t||{};var i={main:r.m},n=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},i={main:[]},n={main:{}};l(r);)for(var a=Object.keys(r),s=0;s<a.length;s++){var u=a[s],c=r[u].pop();if(n[u]=n[u]||{},!n[u][c]&&e[u][c]){n[u][c]=!0,i[u]=i[u]||[],i[u].push(c);for(var d=o(e,e[u][c],u),h=Object.keys(d),f=0;f<h.length;f++)r[h[f]]=r[h[f]]||[],r[h[f]]=r[h[f]].concat(d[h[f]])}}return i}(i,e),a="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;n[e][t];)t++;n[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+u(n,i,t,modules)+")();\n"})),a=a+"new (("+u(n,i,e,"main")+")())(self);";var s=new window.Blob([a],{type:"text/javascript"}),c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(s),d=new window.Worker(c);return d.objectURL=c,d}},"./src/errors.ts":
|
|
50
131
|
/*!***********************!*\
|
|
51
132
|
!*** ./src/errors.ts ***!
|
|
52
|
-
\***********************/
|
|
53
|
-
/*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){var i,n;r.r(t),r.d(t,"ErrorTypes",(function(){return i})),r.d(t,"ErrorDetails",(function(){return n})),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(i||(i={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException"}(n||(n={}))},"./src/events.js":
|
|
133
|
+
\***********************/(e,t,r)=>{var i,n;r.r(t),r.d(t,{ErrorDetails:()=>n,ErrorTypes:()=>i}),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(i||(i={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"}(n||(n={}))},"./src/events.ts":
|
|
54
134
|
/*!***********************!*\
|
|
55
|
-
!*** ./src/events.
|
|
56
|
-
\***********************/
|
|
57
|
-
|
|
135
|
+
!*** ./src/events.ts ***!
|
|
136
|
+
\***********************/(e,t,r)=>{var i;r.r(t),r.d(t,{Events:()=>i}),function(e){e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached"}(i||(i={}))},"./src/hls.ts":
|
|
137
|
+
/*!********************!*\
|
|
138
|
+
!*** ./src/hls.ts ***!
|
|
139
|
+
\********************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>y});var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),a=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),d=r(/*! ./is-supported */"./src/is-supported.ts"),h=r(/*! ./utils/logger */"./src/utils/logger.ts"),f=r(/*! ./config */"./src/config.ts"),g=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),p=r(/*! ./events */"./src/events.ts"),v=r(/*! ./errors */"./src/errors.ts");function m(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var y=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new g.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,f.mergeConfig)(e.DefaultConfig,t);this.userConfig=t,(0,h.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,f.enableStreamingMode)(r);var i=r.abrController,d=r.bufferController,p=r.capLevelController,v=r.fpsController,m=this.abrController=new i(this),y=this.bufferController=new d(this),A=this.capLevelController=new p(this),E=new v(this),T=new n.default(this),b=new a.default(this),S=new s.default(this),_=this.levelController=new l.default(this),k=new u.FragmentTracker(this),L=this.streamController=new c.default(this,k);A.setStreamController(L),E.setStreamController(L);var D=[T,b,_,L];this.networkControllers=D;var R=[m,y,A,E,S,k];this.audioTrackController=this.createController(r.audioTrackController,null,D),this.createController(r.audioStreamController,k,D),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,D),this.createController(r.subtitleStreamController,k,D),this.createController(r.timelineController,null,R),this.emeController=this.createController(r.emeController,null,R),this.cmcdController=this.createController(r.cmcdController,null,R),this.latencyController=this.createController(o.default,null,R),this.coreComponents=R}e.isSupported=function(){return(0,d.isSupported)()};var t,r,y,A=e.prototype;return A.createController=function(e,t,r){if(e){var i=t?new e(this,t):new e(this);return r&&r.push(i),i}return null},A.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},A.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},A.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},A.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},A.listeners=function(e){return this._emitter.listeners(e)},A.emit=function(e,t,r){return this._emitter.emit(e,t,r)},A.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){h.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(p.Events.ERROR,{type:v.ErrorTypes.OTHER_ERROR,details:v.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},A.listenerCount=function(e){return this._emitter.listenerCount(e)},A.destroy=function(){h.logger.log("destroy"),this.trigger(p.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0},A.attachMedia=function(e){h.logger.log("attachMedia"),this._media=e,this.trigger(p.Events.MEDIA_ATTACHING,{media:e})},A.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(p.Events.MEDIA_DETACHING,void 0),this._media=null},A.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});h.logger.log("loadSource:"+n),t&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.Events.MANIFEST_LOADING,{url:e})},A.startLoad=function(e){void 0===e&&(e=-1),h.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},A.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},A.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},A.recoverMediaError=function(){h.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},A.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},t=e,y=[{key:"version",get:function(){return"1.2.9"}},{key:"Events",get:function(){return p.Events}},{key:"ErrorTypes",get:function(){return v.ErrorTypes}},{key:"ErrorDetails",get:function(){return v.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:f.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}],(r=[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){h.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){h.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){h.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){h.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){h.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(h.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&m(t.prototype,r),y&&m(t,y),Object.defineProperty(t,"prototype",{writable:!1}),e}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
140
|
+
/*!*****************************!*\
|
|
141
|
+
!*** ./src/is-supported.ts ***!
|
|
142
|
+
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{changeTypeSupported:()=>s,isSupported:()=>a});var i=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e=(0,i.getMediaSource)();if(!e)return!1;var t=n(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}function s(){var e,t=n();return"function"==typeof(null==t||null===(e=t.prototype)||void 0===e?void 0:e.changeType)}},"./src/loader/date-range.ts":
|
|
143
|
+
/*!**********************************!*\
|
|
144
|
+
!*** ./src/loader/date-range.ts ***!
|
|
145
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{DateRange:()=>u,DateRangeAttribute:()=>i});var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function l(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}!function(e){e.ID="ID",e.CLASS="CLASS",e.START_DATE="START-DATE",e.DURATION="DURATION",e.END_DATE="END-DATE",e.END_ON_NEXT="END-ON-NEXT",e.PLANNED_DURATION="PLANNED-DURATION",e.SCTE35_OUT="SCTE35-OUT",e.SCTE35_IN="SCTE35-IN"}(i||(i={}));var u=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var l in r)if(Object.prototype.hasOwnProperty.call(e,l)&&e[l]!==r[l]){s.logger.warn('DATERANGE tag attribute: "'+l+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=l;break}e=o(new a.AttrList({}),r,e)}if(this.attr=e,this._startDate=new Date(e[i.START_DATE]),i.END_DATE in this.attr){var u=new Date(this.attr[i.END_DATE]);(0,n.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}var t,r,u;return t=e,(r=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if(i.DURATION in this.attr){var e=this.attr.decimalFloatingPoint(i.DURATION);if((0,n.isFiniteNumber)(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return i.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(i.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(i.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,n.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&l(t.prototype,r),u&&l(t,u),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/fragment-loader.ts":
|
|
146
|
+
/*!***************************************!*\
|
|
147
|
+
!*** ./src/loader/fragment-loader.ts ***!
|
|
148
|
+
\***************************************/(e,t,r)=>{r.r(t),r.d(t,{LoadError:()=>f,default:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../errors */"./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return s(e,arguments,u(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,e)},a(e)}function s(e,t,r){return s=o()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&l(n,r.prototype),n},s.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var c=Math.pow(2,17),d=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(i,l){r.loader&&r.loader.destroy();var u=r.loader=e.loader=s?new s(a):new o(a),d=h(e),g={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===e.sn?1/0:c};e.stats=u.stats,u.load(d,g,{onSuccess:function(t,n,a,s){r.resetLoader(e,u),i({frag:e,part:null,payload:t.data,networkDetails:s})},onError:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){i.loader&&i.loader.destroy();var d=i.loader=e.loader=s?new s(a):new o(a),g=h(e,t),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=d.stats,d.load(g,p,{onSuccess:function(n,a,s,o){i.resetLoader(e,d),i.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:n.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s){i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r,networkDetails:s}))},onAbort:function(r,a,s){e.stats.aborted=t.stats.aborted,i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:s}))},onTimeout:function(r,a,s){i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:s}))}})}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function h(e,t){void 0===t&&(t=null);var r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return(0,i.isFiniteNumber)(a)&&(0,i.isFiniteNumber)(s)&&(n.rangeStart=a,n.rangeEnd=s),n}var f=function(e){var t,r;function i(t){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];return(r=e.call.apply(e,[this].concat(n))||this).data=void 0,r.data=t,r}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r),i}(a(Error))},"./src/loader/fragment.ts":
|
|
149
|
+
/*!********************************!*\
|
|
150
|
+
!*** ./src/loader/fragment.ts ***!
|
|
151
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{BaseSegment:()=>f,ElementaryStreamTypes:()=>i,Fragment:()=>g,Part:()=>p});var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}!function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"}(i||(i={}));var f=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},h(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),g=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkey=void 0,i.type=void 0,i.loader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new l.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.type=t,i}u(t,e);var r=t.prototype;return r.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null},h(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&s.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!(0,n.isFiniteNumber)(this.programDateTime))return null;var e=(0,n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null===(e=this.decryptdata)||void 0===e||!e.keyFormat||!this.decryptdata.uri)}}]),t}(f),p=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new l.LoadStats,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),h(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(f)},"./src/loader/key-loader.ts":
|
|
152
|
+
/*!**********************************!*\
|
|
153
|
+
!*** ./src/loader/key-loader.ts ***!
|
|
154
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function e(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){this.hls.on(i.Events.KEY_LOADING,this.onKeyLoading,this)},t.unregisterListeners=function(){this.hls.off(i.Events.KEY_LOADING,this.onKeyLoading)},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onKeyLoading=function(e,t){var r=t.frag,n=r.type,s=this.loaders[n];if(r.decryptdata){var o=r.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(s&&(a.logger.warn("abort previous key loader for type:"+n),s.abort()),!o)return void a.logger.warn("key uri is falsy");var u=l.loader,c=r.loader=this.loaders[n]=new u(l);this.decrypturl=o,this.decryptkey=null;var d={url:o,frag:r,responseType:"arraybuffer"},h={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(d,h,f)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(i.Events.KEY_LOADED,{frag:r}))}else a.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){var n=r.frag;n.decryptdata?(this.decryptkey=n.decryptdata.key=new Uint8Array(e.data),n.loader=null,delete this.loaders[n.type],this.hls.trigger(i.Events.KEY_LOADED,{frag:n})):a.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},t.loadtimeout=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}()},"./src/loader/level-details.ts":
|
|
155
|
+
/*!*************************************!*\
|
|
156
|
+
!*** ./src/loader/level-details.ts ***!
|
|
157
|
+
\*************************************/(e,t,r)=>{r.r(t),r.d(t,{LevelDetails:()=>a});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=e}var t,r,a;return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},t=e,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,i.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!==(e=this.fragments)&&void 0!==e&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/level-key.ts":
|
|
58
158
|
/*!*********************************!*\
|
|
59
|
-
!*** ./src/
|
|
60
|
-
\*********************************/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/*!
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/*!
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/url-toolkit/src/url-toolkit.js (<- Module is not an ECMAScript module) */function(e,t,r){r.r(t),r.d(t,"default",(function(){return or}));var i={};r.r(i),r.d(i,"newCue",(function(){return ft}));var n,a,s=r("./node_modules/url-toolkit/src/url-toolkit.js"),o=r("./src/errors.ts"),l=r("./src/polyfills/number.js"),u=r("./src/events.js"),c=r("./src/utils/logger.js"),d={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},h=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.handledEvents=r,this.useGenericHandler=!0,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){},t.onHandlerDestroyed=function(){},t.isEventHandler=function(){return"object"==typeof this.handledEvents&&this.handledEvents.length&&"function"==typeof this.onEvent},t.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){if(d[e])throw new Error("Forbidden event-name: "+e);this.hls.on(e,this.onEvent)}),this)},t.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){this.hls.off(e,this.onEvent)}),this)},t.onEvent=function(e,t){this.onEventGeneric(e,t)},t.onEventGeneric=function(e,t){try{(function(e,t){var r="on"+e.replace("hls","");if("function"!=typeof this[r])throw new Error("Event "+e+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,t)}).call(this,e,t).call()}catch(t){c.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,err:t})}},e}();!function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(n||(n={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(a||(a={}));var f=r("./src/demux/mp4demuxer.js");function g(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var p,v=function(){function e(e,t){this._uri=null,this.baseuri=void 0,this.reluri=void 0,this.method=null,this.key=null,this.iv=null,this.baseuri=e,this.reluri=t}var t,r,i;return t=e,(r=[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=Object(s.buildAbsoluteURL)(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}])&&g(t.prototype,r),i&&g(t,i),e}();function m(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}!function(e){e.AUDIO="audio",e.VIDEO="video"}(p||(p={}));var A=function(){function e(){var e;this._url=null,this._byteRange=null,this._decryptdata=null,this._elementaryStreams=((e={})[p.AUDIO]=!1,e[p.VIDEO]=!1,e),this.deltaPTS=0,this.rawProgramDateTime=null,this.programDateTime=null,this.title=null,this.tagList=[],this.cc=void 0,this.type=void 0,this.relurl=void 0,this.baseurl=void 0,this.duration=void 0,this.start=void 0,this.sn=0,this.urlId=0,this.level=0,this.levelkey=void 0,this.loader=void 0}var t,r,i,n=e.prototype;return n.setByteRange=function(e,t){var r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},n.addElementaryStream=function(e){this._elementaryStreams[e]=!0},n.hasElementaryStream=function(e){return!0===this._elementaryStreams[e]},n.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},n.setDecryptDataFromLevelKey=function(e,t){var r=e;return(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=new v(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},t=e,(r=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&c.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(l.isFiniteNumber)(this.programDateTime))return null;var e=Object(l.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&m(t.prototype,r),i&&m(t,i),e}();function y(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var E=function(){function e(e){this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=e,this.version=null}var t,r,i;return t=e,(r=[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Object(l.isFiniteNumber)(this.fragments[0].programDateTime))}}])&&y(t.prototype,r),i&&y(t,i),e}(),_=/^(\d+)x(\d+)$/,T=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,b=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.enumeratedString=function(e){return this[e]},t.decimalResolution=function(e){var t=_.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(T.lastIndex=0;null!==(t=T.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}(),k={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function S(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var R=/(?:#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)|#EXT-X-SESSION-DATA:([^\n\r]*)[\r\n]+)/g,w=/#EXT-X-MEDIA:(.*)/g,L=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),C=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,O=/\.(mp4|m4s|m4v|m4a)$/i,D=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return s.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,n=[],a={},s=!1;function o(e,t){["video","audio"].forEach((function(r){var i=e.filter((function(e){return function(e,t){var r=k[t];return!!r&&!0===r[e.slice(0,4)]}(e,r)}));if(i.length){var n=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}for(R.lastIndex=0;null!=(i=R.exec(t));)if(i[1]){var l={},u=l.attrs=new b(i[1]);l.url=e.resolve(i[2],r);var c=u.decimalResolution("RESOLUTION");c&&(l.width=c.width,l.height=c.height),l.bitrate=u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),l.name=u.NAME,o([].concat((u.CODECS||"").split(/[ ,]+/)),l),l.videoCodec&&-1!==l.videoCodec.indexOf("avc1")&&(l.videoCodec=e.convertAVC1ToAVCOTI(l.videoCodec)),n.push(l)}else if(i[3]){var d=new b(i[3]);d["DATA-ID"]&&(s=!0,a[d["DATA-ID"]]=d)}return{levels:n,sessionData:s?a:null}},e.parseMasterPlaylistMedia=function(t,r,i,n){var a;void 0===n&&(n=[]);var s=[],o=0;for(w.lastIndex=0;null!==(a=w.exec(t));){var l=new b(a[1]);if(l.TYPE===i){var u={attrs:l,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE,type:i,default:"YES"===l.DEFAULT,autoselect:"YES"===l.AUTOSELECT,forced:"YES"===l.FORCED,lang:l.LANGUAGE};if(l.URI&&(u.url=e.resolve(l.URI,r)),n.length){var c=e.findGroup(n,u.groupId);u.audioCodec=c?c.codec:n[0].codec}s.push(u)}}return s},e.parseLevelPlaylist=function(e,t,r,i,n){var a,s,o,u=0,d=0,h=new E(t),f=0,g=null,p=new A,m=null;for(L.lastIndex=0;null!==(a=L.exec(e));){var y=a[1];if(y){p.duration=parseFloat(y);var _=(" "+a[2]).slice(1);p.title=_||null,p.tagList.push(_?["INF",y,_]:["INF",y])}else if(a[3]){if(Object(l.isFiniteNumber)(p.duration)){var T=u++;p.type=i,p.start=d,o&&(p.levelkey=o),p.sn=T,p.level=r,p.cc=f,p.urlId=n,p.baseurl=t,p.relurl=(" "+a[3]).slice(1),I(p,g),h.fragments.push(p),g=p,d+=p.duration,p=new A}}else if(a[4]){var k=(" "+a[4]).slice(1);g?p.setByteRange(k,g):p.setByteRange(k)}else if(a[5])p.rawProgramDateTime=(" "+a[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),null===m&&(m=h.fragments.length);else{if(!(a=a[0].match(C))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(s=1;s<a.length&&void 0===a[s];s++);var S=(" "+a[s+1]).slice(1),R=(" "+a[s+2]).slice(1);switch(a[s]){case"#":p.tagList.push(R?[S,R]:[S]);break;case"PLAYLIST-TYPE":h.type=S.toUpperCase();break;case"MEDIA-SEQUENCE":u=h.startSN=parseInt(S);break;case"TARGETDURATION":h.targetduration=parseFloat(S);break;case"VERSION":h.version=parseInt(S);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"DIS":f++,p.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":f=parseInt(S);break;case"KEY":var w=new b(S),D=w.enumeratedString("METHOD"),P=w.URI,x=w.hexadecimalInteger("IV");if("com.apple.streamingkeydelivery"===(w.KEYFORMAT||"identity")){c.logger.warn("Keyformat com.apple.streamingkeydelivery is not supported");continue}D&&(o=new v(t,P),P&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(D)>=0&&(o.method=D,o.key=null,o.iv=x));break;case"START":var N=new b(S).decimalFloatingPoint("TIME-OFFSET");Object(l.isFiniteNumber)(N)&&(h.startTimeOffset=N);break;case"MAP":var M=new b(S);p.relurl=M.URI,M.BYTERANGE&&p.setByteRange(M.BYTERANGE),p.baseurl=t,p.level=r,p.type=i,p.sn="initSegment",h.initSegment=p,(p=new A).rawProgramDateTime=h.initSegment.rawProgramDateTime;break;default:c.logger.warn("line parsed but not handled: "+a)}}}return(p=g)&&!p.relurl&&(h.fragments.pop(),d-=p.duration),h.totalduration=d,h.averagetargetduration=d/h.fragments.length,h.endSN=u-1,h.startCC=h.fragments[0]?h.fragments[0].cc:0,h.endCC=f,!h.initSegment&&h.fragments.length&&h.fragments.every((function(e){return O.test(e.relurl)}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(p=new A).relurl=h.fragments[0].relurl,p.baseurl=t,p.level=r,p.type=i,p.sn="initSegment",h.initSegment=p,h.needSidxRanges=!0),m&&function(e,t){for(var r=e[t],i=t-1;i>=0;i--){var n=e[i];n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h.fragments,m),h},e}();function I(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):(null==t?void 0:t.programDateTime)&&(e.programDateTime=t.endProgramDateTime),Object(l.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var P=window.performance,x=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MANIFEST_LOADING,u.default.LEVEL_LOADING,u.default.AUDIO_TRACK_LOADING,u.default.SUBTITLE_TRACK_LOADING)||this).loaders={},r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i.canHaveQualityLevels=function(e){return e!==n.AUDIO_TRACK&&e!==n.SUBTITLE_TRACK},i.mapContextToLevelType=function(e){switch(e.type){case n.AUDIO_TRACK:return a.AUDIO;case n.SUBTITLE_TRACK:return a.SUBTITLE;default:return a.MAIN}},i.getResponseUrl=function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r};var s=i.prototype;return s.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return e.loader=n,this.loaders[e.type]=n,n},s.getInternalLoader=function(e){return this.loaders[e.type]},s.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},s.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},s.destroy=function(){this.destroyInternalLoaders(),e.prototype.destroy.call(this)},s.onManifestLoading=function(e){this.load({url:e.url,type:n.MANIFEST,level:0,id:null,responseType:"text"})},s.onLevelLoading=function(e){this.load({url:e.url,type:n.LEVEL,level:e.level,id:e.id,responseType:"text"})},s.onAudioTrackLoading=function(e){this.load({url:e.url,type:n.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},s.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:n.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},s.load=function(e){var t=this.hls.config;c.logger.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id);var r,i,a,s,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url)return c.logger.trace("playlist request ongoing"),!1;c.logger.warn("aborting previous loader for type: "+e.type),o.abort()}switch(e.type){case n.MANIFEST:r=t.manifestLoadingMaxRetry,i=t.manifestLoadingTimeOut,a=t.manifestLoadingRetryDelay,s=t.manifestLoadingMaxRetryTimeout;break;case n.LEVEL:r=0,s=0,a=0,i=t.levelLoadingTimeOut;break;default:r=t.levelLoadingMaxRetry,i=t.levelLoadingTimeOut,a=t.levelLoadingRetryDelay,s=t.levelLoadingMaxRetryTimeout}o=this.createInternalLoader(e);var u={timeout:i,maxRetry:r,retryDelay:a,maxRetryDelay:s},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return c.logger.debug("Calling internal loader delegate for URL: "+e.url),o.load(e,u,d),!0},s.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);if(this.resetInternalLoader(r.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var n=e.data;t.tload=P.now(),0===n.indexOf("#EXTM3U")?n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},s.loaderror=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!1,e)},s.loadtimeout=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!0)},s._handleMasterPlaylist=function(e,t,r,n){var a=this.hls,s=e.data,o=i.getResponseUrl(e,r),l=D.parseMasterPlaylist(s,o),d=l.levels,h=l.sessionData;if(d.length){var f=d.map((function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}})),g=D.parseMasterPlaylistMedia(s,o,"AUDIO",f),p=D.parseMasterPlaylistMedia(s,o,"SUBTITLES"),v=D.parseMasterPlaylistMedia(s,o,"CLOSED-CAPTIONS");if(g.length){var m=!1;g.forEach((function(e){e.url||(m=!0)})),!1===m&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(c.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:{},url:""}))}a.trigger(u.default.MANIFEST_LOADED,{levels:d,audioTracks:g,subtitles:p,captions:v,url:o,stats:t,networkDetails:n,sessionData:h})}else this._handleManifestParsingError(e,r,"no level found in manifest",n)},s._handleTrackOrLevelPlaylist=function(e,t,r,a){var s=this.hls,c=r.id,d=r.level,h=r.type,f=i.getResponseUrl(e,r),g=Object(l.isFiniteNumber)(c)?c:0,p=Object(l.isFiniteNumber)(d)?d:g,v=i.mapContextToLevelType(r),m=D.parseLevelPlaylist(e.data,f,p,v,g);if(m.tload=t.tload,m.fragments.length){if(h===n.MANIFEST){var A={url:f,details:m};s.trigger(u.default.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:f,stats:t,networkDetails:a,sessionData:null})}if(t.tparsed=P.now(),m.needSidxRanges){var y=m.initSegment.url;this.load({url:y,isSidxRequest:!0,type:h,level:d,levelDetails:m,id:c,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else r.levelDetails=m,this._handlePlaylistLoaded(e,t,r,a)}else s.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},s._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r=f.default.parseSegmentIndex(new Uint8Array(e.data));if(r){var i=r.references,n=t.levelDetails;i.forEach((function(e,t){var r=e.info;if(n){var i=n.fragments[t];0===i.byteRange.length&&i.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}})),n&&n.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},s._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})},s._handleNetworkError=function(e,t,r,i){var a,s;void 0===r&&(r=!1),void 0===i&&(i=null),c.logger.info("A network error occured while loading a "+e.type+"-type playlist");var l=this.getInternalLoader(e);switch(e.type){case n.MANIFEST:a=r?o.ErrorDetails.MANIFEST_LOAD_TIMEOUT:o.ErrorDetails.MANIFEST_LOAD_ERROR,s=!0;break;case n.LEVEL:a=r?o.ErrorDetails.LEVEL_LOAD_TIMEOUT:o.ErrorDetails.LEVEL_LOAD_ERROR,s=!1;break;case n.AUDIO_TRACK:a=r?o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,s=!1;break;default:s=!1}l&&(l.abort(),this.resetInternalLoader(e.type));var d={type:o.ErrorTypes.NETWORK_ERROR,details:a,fatal:s,url:e.url,loader:l,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(u.default.ERROR,d)},s._handlePlaylistLoaded=function(e,t,r,a){var s=r.type,o=r.level,l=r.id,c=r.levelDetails;if(c&&c.targetduration)if(i.canHaveQualityLevels(r.type))this.hls.trigger(u.default.LEVEL_LOADED,{details:c,level:o||0,id:l||0,stats:t,networkDetails:a});else switch(s){case n.AUDIO_TRACK:this.hls.trigger(u.default.AUDIO_TRACK_LOADED,{details:c,id:l,stats:t,networkDetails:a});break;case n.SUBTITLE_TRACK:this.hls.trigger(u.default.SUBTITLE_TRACK_LOADED,{details:c,id:l,stats:t,networkDetails:a})}else this._handleManifestParsingError(e,r,"invalid target duration",a)},i}(h),N=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.FRAG_LOADING)||this).loaders={},r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){var t=this.loaders;for(var r in t){var i=t[r];i&&i.destroy()}this.loaders={},e.prototype.destroy.call(this)},n.onFragLoading=function(e){var t=e.frag,r=t.type,i=this.loaders,n=this.hls.config,a=n.fLoader,s=n.loader;t.loaded=0;var o,u,d,h=i[r];h&&(c.logger.warn("abort previous fragment loader for type: "+r),h.abort()),h=i[r]=t.loader=n.fLoader?new a(n):new s(n),o={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var f=t.byteRangeStartOffset,g=t.byteRangeEndOffset;Object(l.isFiniteNumber)(f)&&Object(l.isFiniteNumber)(g)&&(o.rangeStart=f,o.rangeEnd=g),u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:n.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},h.load(o,u,d)},n.loadsuccess=function(e,t,r,i){void 0===i&&(i=null);var n=e.data,a=r.frag;a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(u.default.FRAG_LOADED,{payload:n,frag:a,stats:t,networkDetails:i})},n.loaderror=function(e,t,r){void 0===r&&(r=null);var i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},n.loadtimeout=function(e,t,r){void 0===r&&(r=null);var i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},n.loadprogress=function(e,t,r,i){void 0===i&&(i=null);var n=t.frag;n.loaded=e.loaded,this.hls.trigger(u.default.FRAG_LOAD_PROGRESS,{frag:n,stats:e,networkDetails:i})},i}(h),M=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.KEY_LOADING)||this).loaders={},r.decryptkey=null,r.decrypturl=null,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy()}this.loaders={},e.prototype.destroy.call(this)},n.onKeyLoading=function(e){var t=e.frag,r=t.type,i=this.loaders[r];if(t.decryptdata){var n=t.decryptdata.uri;if(n!==this.decrypturl||null===this.decryptkey){var a=this.hls.config;if(i&&(c.logger.warn("abort previous key loader for type:"+r),i.abort()),!n)return void c.logger.warn("key uri is falsy");t.loader=this.loaders[r]=new a.loader(a),this.decrypturl=n,this.decryptkey=null;var s={url:n,frag:t,responseType:"arraybuffer"},o={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};t.loader.load(s,o,l)}else this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(u.default.KEY_LOADED,{frag:t}))}else c.logger.warn("Missing decryption data on fragment in onKeyLoading")},n.loadsuccess=function(e,t,r){var i=r.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,delete this.loaders[i.type],this.hls.trigger(u.default.KEY_LOADED,{frag:i})):c.logger.error("after key load, decryptdata unset")},n.loaderror=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},n.loadtimeout=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},i}(h),F="NOT_LOADED",U="APPENDING",B="PARTIAL",j="OK",G=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.BUFFER_APPENDED,u.default.FRAG_BUFFERED,u.default.FRAG_LOADED)||this).bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=t.config,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,h.prototype.destroy.call(this),e.prototype.destroy.call(this)},n.getBufferedFrag=function(e,t){var r=this.fragments,i=Object.keys(r).filter((function(i){var n=r[i];if(n.body.type!==t)return!1;if(!n.buffered)return!1;var a=n.body;return a.startPTS<=e&&e<=a.endPTS}));if(0===i.length)return null;var n=i.pop();return r[n].body},n.detectEvictedFragments=function(e,t){var r=this;Object.keys(this.fragments).forEach((function(i){var n=r.fragments[i];if(n&&n.buffered){var a=n.range[e];if(a)for(var s=a.time,o=0;o<s.length;o++){var l=s[o];if(!r.isTimeBuffered(l.startPTS,l.endPTS,t)){r.removeFragment(n.body);break}}}}))},n.detectPartialFragments=function(e){var t=this,r=this.getFragmentKey(e),i=this.fragments[r];i&&(i.buffered=!0,Object.keys(this.timeRanges).forEach((function(r){if(e.hasElementaryStream(r)){var n=t.timeRanges[r];i.range[r]=t.getBufferedTimes(e.startPTS,e.endPTS,n)}})))},n.getBufferedTimes=function(e,t,r){for(var i,n,a=[],s=!1,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,n=r.end(o)+this.bufferPadding,e>=i&&t<=n){a.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))});break}if(e<n&&t>i)a.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))}),s=!0;else if(t<=i)break}return{time:a,partial:s}},n.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},n.getPartialFragment=function(e){var t,r,i,n=this,a=null,s=0;return Object.keys(this.fragments).forEach((function(o){var l=n.fragments[o];n.isPartial(l)&&(r=l.body.startPTS-n.bufferPadding,i=l.body.endPTS+n.bufferPadding,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(a=l.body,s=t)))})),a},n.getState=function(e){var t=this.getFragmentKey(e),r=this.fragments[t],i=F;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?B:j:U),i},n.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},n.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e){var t=e.frag;Object(l.isFiniteNumber)(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},n.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach((function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)}))},n.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},n.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},n.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},n.removeAllFragments=function(){this.fragments=Object.create(null)},i}(h),K={search:function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null}},Y=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,i=0;i<r.length;i++)if(t>=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){var i,n=e.buffered,a=[];for(i=0;i<n.length;i++)a.push({start:n.start(i),end:n.end(i)});return this.bufferedInfo(a,t,r)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}},e.bufferedInfo=function(e,t,r){e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,d=0;d<i.length;d++){var h=i[d].start,f=i[d].end;if(t+r>=h&&t<f)u=h,l=(c=f)-t;else if(t+r<h){o=h;break}}return{len:l,start:u,end:c,nextStart:o}},e}(),V=r("./node_modules/eventemitter3/index.js"),H=r("./node_modules/webworkify-webpack/index.js"),W=r("./src/demux/demuxer-inline.js");function z(){return window.MediaSource||window.WebKitMediaSource}var q=r("./src/utils/get-self-scope.js"),X=function(e){var t,r;function i(){return e.apply(this,arguments)||this}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i.prototype.trigger=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e,e].concat(r))},i}(V.EventEmitter),$=Object(q.getSelfScope)(),Z=z()||{isTypeSupported:function(){return!1}},Q=function(){function e(e,t){var r=this;this.hls=e,this.id=t;var i=this.observer=new X,n=e.config,a=function(t,i){(i=i||{}).frag=r.frag,i.id=r.id,e.trigger(t,i)};i.on(u.default.FRAG_DECRYPTED,a),i.on(u.default.FRAG_PARSING_INIT_SEGMENT,a),i.on(u.default.FRAG_PARSING_DATA,a),i.on(u.default.FRAG_PARSED,a),i.on(u.default.ERROR,a),i.on(u.default.FRAG_PARSING_METADATA,a),i.on(u.default.FRAG_PARSING_USERDATA,a),i.on(u.default.INIT_PTS_FOUND,a);var s={mp4:Z.isTypeSupported("video/mp4"),mpeg:Z.isTypeSupported("audio/mpeg"),mp3:Z.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(n.enableWorker&&"undefined"!=typeof Worker){var d;c.logger.log("demuxing in webworker");try{d=this.w=H(/*! ../demux/demuxer-worker.js */"./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),d.addEventListener("message",this.onwmsg),d.onerror=function(t){e.trigger(u.default.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:t.message+" ("+t.filename+":"+t.lineno+")"}})},d.postMessage({cmd:"init",typeSupported:s,vendor:l,id:t,config:JSON.stringify(n)})}catch(e){c.logger.warn("Error in worker:",e),c.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),d&&$.URL.revokeObjectURL(d.objectURL),this.demuxer=new W.default(i,s,n,l),this.w=void 0}}else this.demuxer=new W.default(i,s,n,l)}var t=e.prototype;return t.destroy=function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var t=this.demuxer;t&&(t.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)},t.push=function(e,t,r,i,n,a,s,o){var u=this.w,d=Object(l.isFiniteNumber)(n.startPTS)?n.startPTS:n.start,h=n.decryptdata,f=this.frag,g=!(f&&n.cc===f.cc),p=!(f&&n.level===f.level),v=f&&n.sn===f.sn+1,m=!p&&v;if(g&&c.logger.log(this.id+":discontinuity detected"),p&&c.logger.log(this.id+":switch detected"),this.frag=n,u)u.postMessage({cmd:"demux",data:e,decryptdata:h,initSegment:t,audioCodec:r,videoCodec:i,timeOffset:d,discontinuity:g,trackSwitch:p,contiguous:m,duration:a,accurateTimeOffset:s,defaultInitPTS:o},e instanceof ArrayBuffer?[e]:[]);else{var A=this.demuxer;A&&A.push(e,h,t,r,i,d,g,p,m,a,s,o)}},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":$.URL.revokeObjectURL(this.w.objectURL);break;case u.default.FRAG_PARSING_DATA:t.data.data1=new Uint8Array(t.data1),t.data2&&(t.data.data2=new Uint8Array(t.data2));default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},e}();function J(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function ee(e,t,r){var i=e[t],n=e[r],a=n.startPTS;if(Object(l.isFiniteNumber)(a))r>t?(i.duration=a-i.start,i.duration<0&&c.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-a,n.duration<0&&c.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"));else if(r>t){var s=i.cc===n.cc;n.start=i.start+(s&&i.minEndPTS?i.minEndPTS-i.start:i.duration)}else n.start=Math.max(i.start-n.duration,0)}function te(e,t,r,i,n,a){var s=r,o=i;if(Object(l.isFiniteNumber)(t.startPTS)){var u=Math.abs(t.startPTS-r);Object(l.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),o=Math.min(i,t.endPTS),i=Math.max(i,t.endPTS),n=Math.min(n,t.startDTS),a=Math.max(a,t.endDTS)}var c=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=i,t.minEndPTS=o,t.startDTS=n,t.endDTS=a,t.duration=i-r;var d,h,f,g=t.sn;if(!e||g<e.startSN||g>e.endSN)return 0;for(d=g-e.startSN,(h=e.fragments)[d]=t,f=d;f>0;f--)ee(h,f,f-1);for(f=d;f<h.length-1;f++)ee(h,f,f+1);return e.PTSKnown=!0,c}function re(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment);var r,i=0;if(ie(e,t,(function(e,n){i=e.cc-n.cc,Object(l.isFiniteNumber)(e.startPTS)&&(n.start=n.startPTS=e.startPTS,n.endPTS=e.endPTS,n.duration=e.duration,n.backtracked=e.backtracked,n.dropped=e.dropped,r=n),t.PTSKnown=!0})),t.PTSKnown){if(i){c.logger.log("discontinuity sliding from playlist, take drift into account");for(var n=t.fragments,a=0;a<n.length;a++)n[a].cc+=i}r?te(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):function(e,t){var r=t.startSN-e.startSN,i=e.fragments,n=t.fragments;if(!(r<0||r>i.length))for(var a=0;a<n.length;a++)n[a].start+=i[r].start}(e,t),t.PTSKnown=e.PTSKnown}}function ie(e,t,r){if(e&&t)for(var i=Math.max(e.startSN,t.startSN)-t.startSN,n=Math.min(e.endSN,t.endSN)-t.startSN,a=t.startSN-e.startSN,s=i;s<=n;s++){var o=e.fragments[a+s],l=t.fragments[s];if(!o||!l)break;r(o,l,s)}}function ne(e,t,r){var i=1e3*(t.averagetargetduration?t.averagetargetduration:t.targetduration),n=i/2;return e&&t.endSN===e.endSN&&(i=n),r&&(i=Math.max(n,i-(window.performance.now()-r))),Math.round(i)}var ae={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}};function se(e,t){t.fragments.forEach((function(t){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}})),t.PTSKnown=!0}function oe(e,t,r){!function(e,t,r){if(function(e,t,r){var i=!1;return t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)&&(i=!0),i}(e,r,t)){var i=function(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var n=function(e,t){for(var r=null,i=0;i<e.length;i+=1){var n=e[i];if(n&&n.cc===t){r=n;break}}return r}(r,i[0].cc);if(n&&(!n||n.startPTS))return n;c.logger.log("No frag in previous level to align on")}else c.logger.log("No fragments to align")}(r.details,t);i&&(c.logger.log("Adjusting PTS using last level due to CC increase within current level"),se(i.start,t))}}(e,r,t),!r.PTSKnown&&t&&function(e,t){if(t&&t.fragments.length){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;var r=t.fragments[0].programDateTime,i=(e.fragments[0].programDateTime-r)/1e3+t.fragments[0].start;Object(l.isFiniteNumber)(i)&&(c.logger.log("adjusting PTS using programDateTime delta, sliding:"+i.toFixed(3)),se(i,e))}}(r,t.details)}function le(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(l.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var n=e[i];if(de(t,r,n))return n}return null}function ue(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var n=null;if(e?n=t[e.sn-t[0].sn+1]:0===r&&0===t[0].start&&(n=t[0]),n&&0===ce(r,i,n))return n;var a=K.search(t,ce.bind(null,r,i));return a||n}function ce(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function de(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var he=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,n=r.currentTime,a=r.seeking,s=this.seeking&&!a,o=!this.seeking&&a;if(this.seeking=a,n===e){if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){var l=Y.bufferInfo(r,n,0),u=l.len>0,d=l.nextStart||0;if(u||d){if(a){var h=l.len>2,f=!d||d-n>2&&!this.fragmentTracker.getPartialFragment(n);if(h||f)return;this.moved=!1}if(!this.moved&&this.stalled){var g=Math.max(d,l.start||0)-n;if(g>0&&g<=2)return void this._trySkipBufferHole(null)}var p=self.performance.now();if(null!==i){var v=p-i;!a&&v>=250&&this._reportStall(l.len);var m=Y.bufferInfo(r,n,t.maxBufferHole);this._tryFixBufferStall(m,v)}else this.stalled=p}}}else if(this.moved=!0,null!==i){if(this.stallReported){var A=self.performance.now()-i;c.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(A)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media.currentTime,a=i.getPartialFragment(n);a&&this._trySkipBufferHole(a)||e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(c.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,c.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,n=i.currentTime,a=0,s=0;s<i.buffered.length;s++){var l=i.buffered.start(s);if(n+t.maxBufferHole>=a&&n<l){var d=Math.max(l+.05,i.currentTime+.1);return c.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+d),this.moved=!0,this.stalled=null,i.currentTime=d,e&&r.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+n+" to "+d,frag:e}),d}a=i.buffered.end(s)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=r.currentTime,n=(this.nudgeRetry||0)+1;if(this.nudgeRetry=n,n<e.nudgeMaxRetry){var a=i+n*e.nudgeOffset;c.logger.warn("Nudging 'currentTime' from "+i+" to "+a),r.currentTime=a,t.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else c.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},e}();function fe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var ge=function(e){var t,r;function i(t){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];return(r=e.call.apply(e,[this,t].concat(n))||this)._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(fe(r)),r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},n.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},n.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},n.doTick=function(){},i}(h),pe="STOPPED",ve="STARTING",me="IDLE",Ae="PAUSED",ye="KEY_LOADING",Ee="FRAG_LOADING",_e="FRAG_LOADING_WAITING_RETRY",Te="WAITING_TRACK",be="PARSING",ke="PARSED",Se="BUFFER_FLUSHING",Re="ENDED",we="ERROR",Le="WAITING_INIT_PTS",Ce="WAITING_LEVEL",Oe=function(e){var t,r;function i(){return e.apply(this,arguments)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.doTick=function(){},n.startLoad=function(){},n.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=pe},n._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var n=i.getState(r);return n===B||n===j}return!1},n.onMediaSeeking=function(){var e=this.config,t=this.media,r=this.mediaBuffer,i=this.state,n=t?t.currentTime:null,a=Y.bufferInfo(r||t,n,this.config.maxBufferHole);if(c.logger.log("media seeking to "+(Object(l.isFiniteNumber)(n)?n.toFixed(3):n)),i===Ee){var s=this.fragCurrent;if(0===a.len&&s){var o=e.maxFragLookUpTolerance,u=s.start-o,d=s.start+s.duration+o;n<u||n>d?(s.loader&&(c.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=me):c.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else i===Re&&(0===a.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=me);t&&(this.lastCurrentTime=n),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=n),this.tick()},n.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},n.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},n.onHandlerDestroyed=function(){this.state=pe,this.fragmentTracker=null},n.computeLivePosition=function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)},i}(ge);function De(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Ie,Pe=function(e){var t,r;function i(t,r){var i;return(i=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.MANIFEST_LOADING,u.default.MANIFEST_PARSED,u.default.LEVEL_LOADED,u.default.LEVELS_UPDATED,u.default.KEY_LOADED,u.default.FRAG_LOADED,u.default.FRAG_LOAD_EMERGENCY_ABORTED,u.default.FRAG_PARSING_INIT_SEGMENT,u.default.FRAG_PARSING_DATA,u.default.FRAG_PARSED,u.default.ERROR,u.default.AUDIO_TRACK_SWITCHING,u.default.AUDIO_TRACK_SWITCHED,u.default.BUFFER_CREATED,u.default.BUFFER_APPENDED,u.default.BUFFER_FLUSHED)||this).fragmentTracker=r,i.config=t.config,i.audioCodecSwap=!1,i._state=pe,i.stallReported=!1,i.gapController=null,i.altAudio=!1,i.audioOnly=!1,i.bitrateTest=!1,i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,s,d,h=i.prototype;return h.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(c.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=me,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=pe},h.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case Se:this.fragLoadError=0;break;case me:this._doTickIdle();break;case Ce:var e=this.levels[this.level];e&&e.details&&(this.state=me);break;case _e:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(c.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=me)}this._checkBuffer(),this._checkFragmentChanged()},h._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch))if(this.altAudio&&this.audioOnly)this.demuxer.frag=null;else{var i;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var n=e.nextLoadLevel,a=this.levels[n];if(a){var s,o=a.bitrate;s=o?Math.max(8*t.maxBufferSize/o,t.maxBufferLength):t.maxBufferLength,s=Math.min(s,t.maxMaxBufferLength);var l=i<t.maxBufferHole?Math.max(2,t.maxBufferHole):t.maxBufferHole,d=Y.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,l),h=d.len;if(!(h>=s)){c.logger.trace("buffer length of "+h.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=n;var f=a.details;if(!f||f.live&&this.levelLastLoaded!==n)this.state=Ce;else{if(this._streamEnded(d,f)){var g={};return this.altAudio&&(g.type="video"),this.hls.trigger(u.default.BUFFER_EOS,g),void(this.state=Re)}this._fetchPayloadOrEos(i,d,f)}}}}},h._fetchPayloadOrEos=function(e,t,r){var i=this.fragPrevious;this.level;var n=r.fragments,a=n.length;if(0!==a){var s,o=n[0].start,l=n[a-1].start+n[a-1].duration,u=t.end;if(r.initSegment&&!r.initSegment.data)s=r.initSegment;else if(r.live){var d=this.config.initialLiveManifestSize;if(a<d)return void c.logger.warn("Can not start playback of a level, reason: not enough fragments "+a+" < "+d);if(null===(s=this._ensureFragmentAtLivePoint(r,u,o,l,i,n)))return}else u<o&&(s=n[0]);s||(s=this._findFragment(o,i,a,n,u,l,r)),s&&(s.encrypted?this._loadKey(s,r):this._loadFragment(s,r,e,u))}},h._ensureFragmentAtLivePoint=function(e,t,r,i,n,a){var s,o=this.hls.config,u=this.media,d=1/0;if(void 0!==o.liveMaxLatencyDuration?d=o.liveMaxLatencyDuration:Object(l.isFiniteNumber)(o.liveMaxLatencyDurationCount)&&(d=o.liveMaxLatencyDurationCount*e.targetduration),t<Math.max(r-o.maxFragLookUpTolerance,i-d)){var h=this.liveSyncPosition=this.computeLivePosition(r,e);t=h,u&&!u.paused&&u.readyState&&u.duration>h&&h>u.currentTime&&(c.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+h.toFixed(3)),u.currentTime=h),this.nextLoadPosition=h}if(e.PTSKnown&&t>i&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown&&n)if(e.hasProgramDateTime)c.logger.log("live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),s=le(a,n.endProgramDateTime,o.maxFragLookUpTolerance);else{var f=n.sn+1;if(f>=e.startSN&&f<=e.endSN){var g=a[f-e.startSN];n.cc===g.cc&&(s=g,c.logger.log("live playlist, switching playlist, load frag with next SN: "+s.sn))}s||(s=K.search(a,(function(e){return n.cc-e.cc})))&&c.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn)}return s},h._findFragment=function(e,t,r,i,n,a,s){var o,l=this.hls.config;if(o=n<a?ue(t,i,n,n>a-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[r-1]){var u=o.sn-s.startSN,d=t&&o.level===t.level,h=i[u-1],f=i[u+1];if(t&&o.sn===t.sn)if(d&&!o.backtracked)if(o.sn<s.endSN){var g=t.deltaPTS;g&&g>l.maxBufferHole&&t.dropped&&u?(o=h,c.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):(o=f,this.fragmentTracker.getState(o)!==j&&c.logger.log("Re-loading fragment with SN: "+o.sn))}else o=null;else o.backtracked&&(f&&f.backtracked?(c.logger.warn("Already backtracked from fragment "+f.sn+", will not backtrack to fragment "+o.sn+". Loading fragment "+f.sn),o=f):(c.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),o.dropped=0,h?(o=h).backtracked=!0:u&&(o=null)))}return o},h._loadKey=function(e,t){c.logger.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], level "+this.level),this.state=ye,this.hls.trigger(u.default.KEY_LOADING,{frag:e})},h._loadFragment=function(e,t,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,"initSegment"!==e.sn&&(this.startFragRequested=!0),Object(l.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||n===F||n===B?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,c.logger.log("Loading "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], level "+this.level+", "+(this.loadedmetadata?"currentTime":"nextLoadPosition")+": "+parseFloat(r.toFixed(3))+", bufferEnd: "+parseFloat(i.toFixed(3))),this.hls.trigger(u.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new Q(this.hls,"main")),this.state=Ee):n===U&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},h.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,a.MAIN)},h.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},h._checkFragmentChanged=function(){var e,t,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),Y.isBuffered(r,t)?e=this.getBufferedFrag(t):Y.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(u.default.FRAG_CHANGED,{frag:i});var n=i.level;this.fragPlaying&&this.fragPlaying.level===n||this.hls.trigger(u.default.LEVEL_SWITCHED,{level:n}),this.fragPlaying=i}}},h.immediateLevelSwitch=function(){if(c.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e,t=this.media;t?(e=t.paused)||t.pause():e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,e.currentTime>0&&Y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},h.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,r=this.getBufferedFrag(e.currentTime);if(r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],a=this.fragLastKbps;t=a&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*a)+1:0}var s=this.getBufferedFrag(e.currentTime+t);if(s){var o=this.followingBufferedFrag(s);if(o){var l=this.fragCurrent;l&&l.loader&&l.loader.abort(),this.fragCurrent=null;var u=Math.max(s.endPTS,o.maxStartPTS+Math.min(this.config.maxFragLookUpTolerance,o.duration));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}},h.flushMainBuffer=function(e,t){this.state=Se;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(u.default.BUFFER_FLUSHING,r)},h.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new he(r,t,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(c.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach((function(e){e.details&&e.details.fragments.forEach((function(e){e.backtracked=void 0}))})),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.fragmentTracker.removeAllFragments(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},h.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(l.isFiniteNumber)(t)&&c.logger.log("media seeked to "+t.toFixed(3)),this.tick()},h.onManifestLoading=function(){c.logger.log("trigger BUFFER_RESET"),this.hls.trigger(u.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},h.onManifestParsed=function(e){var t,r=!1,i=!1;e.levels.forEach((function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&c.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.altAudio=e.altAudio,this.levels=e.levels,this.startFragRequested=!1;var n=this.config;(n.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(n.startPosition)},h.onLevelLoaded=function(e){var t=e.details,r=e.level,i=this.levels[this.levelLastLoaded],n=this.levels[r],a=t.totalduration,s=0;if(c.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.live||n.details&&n.details.live){var o=n.details;o&&t.fragments.length>0?(re(o,t),s=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,o),t.PTSKnown&&Object(l.isFiniteNumber)(s)?c.logger.log("live playlist sliding:"+s.toFixed(3)):(c.logger.log("live playlist - outdated PTS, unknown sliding"),oe(this.fragPrevious,i,t))):(c.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,oe(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(n.details=t,this.levelLastLoaded=r,this.hls.trigger(u.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var d=t.startTimeOffset;Object(l.isFiniteNumber)(d)?(d<0&&(c.logger.log("negative start time offset "+d+", count from end of last fragment"),d=s+a+d),c.logger.log("start time offset found in playlist, adjust startPosition to "+d),this.startPosition=d):t.live?(this.startPosition=this.computeLivePosition(s,t),c.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===Ce&&(this.state=me),this.tick()},h.onKeyLoaded=function(){this.state===ye&&(this.state=me,this.tick())},h.onFragLoaded=function(e){var t=this.fragCurrent,r=this.hls,i=this.levels,n=this.media,a=e.frag;if(this.state===Ee&&t&&"main"===a.type&&a.level===t.level&&a.sn===t.sn){var s=e.stats,o=i[t.level],l=o.details;if(this.bitrateTest=!1,this.stats=s,c.logger.log("Loaded "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level),a.bitrateTest&&r.nextLoadLevel)this.state=me,this.startFragRequested=!1,s.tparsed=s.tbuffered=window.performance.now(),r.trigger(u.default.FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else if("initSegment"===a.sn)this.state=me,s.tparsed=s.tbuffered=window.performance.now(),l.initSegment.data=e.payload,r.trigger(u.default.FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else{c.logger.log("Parsing "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level+", cc "+t.cc),this.state=be,this.pendingBuffering=!0,this.appended=!1,a.bitrateTest&&(a.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:a}));var d=!(n&&n.seeking)&&(l.PTSKnown||!l.live),h=l.initSegment?l.initSegment.data:[],f=this._getAudioCodec(o);(this.demuxer=this.demuxer||new Q(this.hls,"main")).push(e.payload,h,f,o.videoCodec,t,l.totalduration,d)}}this.fragLoadError=0},h.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===be){var i,n,a=e.tracks;if(this.audioOnly=a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio,n=a.audio){var s=this.levels[this.level].audioCodec,o=navigator.userAgent.toLowerCase();s&&this.audioCodecSwap&&(c.logger.log("swapping playlist audio codec"),s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==n.metadata.channelCount&&-1===o.indexOf("firefox")&&(s="mp4a.40.5"),-1!==o.indexOf("android")&&"audio/mpeg"!==n.container&&(s="mp4a.40.2",c.logger.log("Android: force audio codec to "+s)),n.levelCodec=s,n.id=e.id}for(i in(n=a.video)&&(n.levelCodec=this.levels[this.level].videoCodec,n.id=e.id),this.hls.trigger(u.default.BUFFER_CODECS,a),a){n=a[i],c.logger.log("main track:"+i+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var l=n.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},h.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"main"===e.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===be){var n=this.levels[this.level],a=r;if(Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&a.addElementaryStream(p.AUDIO),!0===e.hasVideo&&a.addElementaryStream(p.VIDEO),c.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(a.dropped=e.dropped,a.dropped)if(a.backtracked)c.logger.warn("Already backtracked on this fragment, appending with the gap",a.sn);else{var s=n.details;if(!s||a.sn!==s.startSN)return c.logger.warn("missing video frame(s), backtracking fragment",a.sn),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=me,this.fragPrevious=a,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),void this.tick();c.logger.warn("missing video frame(s) on first frag, appending with gap",a.sn)}else a.backtracked=!1;var o=te(n.details,a,e.startPTS,e.endPTS,e.startDTS,e.endDTS),d=this.hls;d.trigger(u.default.LEVEL_PTS_UPDATED,{details:n.details,level:this.level,drift:o,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach((function(r){r&&r.length&&t.state===be&&(t.appended=!0,t.pendingBuffering=!0,d.trigger(u.default.BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))})),this.tick()}},h.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===be&&(this.stats.tparsed=window.performance.now(),this.state=ke,this._checkAppendedParsed())},h.onAudioTrackSwitching=function(e){var t=this.altAudio,r=!!e.url,i=e.id;if(!r){if(this.mediaBuffer!==this.media){c.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n.loader&&(c.logger.log("switching to main audio track, cancel main fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=me}var a=this.hls;t&&a.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:i})}},h.onAudioTrackSwitched=function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(c.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},h.onBufferCreated=function(e){var t,r,i=e.tracks,n=!1;for(var a in i){var s=i[a];"main"===s.id?(r=a,t=s,"video"===a&&(this.videoBuffer=i[a].buffer)):n=!0}n&&t?(c.logger.log("alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},h.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==be&&t!==ke||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},h._checkAppendedParsed=function(){if(!(this.state!==ke||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;c.logger.log("main buffered : "+ae.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(u.default.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=me}(this.loadedmetadata||this.startPosition<=0)&&this.tick()}},h.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&Y.isBuffered(this.media,this.media.currentTime)&&Y.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);c.logger.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=_e}else c.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=we;break;case o.ErrorDetails.LEVEL_LOAD_ERROR:case o.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==we&&(e.fatal?(this.state=we,c.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==Ce||(this.state=me));break;case o.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==be&&this.state!==ke||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=me):(c.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},h._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,c.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},h._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}},h.onFragLoadEmergencyAborted=function(){this.state=me,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},h.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;if(e){var t=this.audioOnly?p.AUDIO:p.VIDEO;this.fragmentTracker.detectEvictedFragments(t,e.buffered)}this.state=me,this.fragPrevious=null},h.onLevelsUpdated=function(e){this.levels=e.levels},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=this.startPosition;if(t!==r&&r>=0){if(e.seeking)return void c.logger.log("could not seek to "+r+", already seeking at "+t);var i=(e.buffered.length?e.buffered.start(0):0)-r;i>0&&i<this.config.maxBufferHole&&(c.logger.log("adjusting start position by "+i+" to match buffer start"),r+=i,this.startPosition=r),c.logger.log("seek to target start position "+r+" from current time "+t+". ready state "+e.readyState),e.currentTime=r}},h._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(c.logger.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},n=i,(s=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,c.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(u.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&De(n.prototype,s),d&&De(n,d),i}(Oe);function xe(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Ne=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MANIFEST_LOADED,u.default.LEVEL_LOADED,u.default.AUDIO_TRACK_SWITCHED,u.default.FRAG_LOADED,u.default.ERROR)||this).canload=!1,r.currentLevelIndex=null,r.manualLevelIndex=-1,r.timer=null,Ie=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,l=i.prototype;return l.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},l.clearTimer=function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},l.startLoad=function(){var e=this._levels;this.canload=!0,this.levelRetryCount=0,e&&e.forEach((function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)})),null!==this.timer&&this.loadLevel()},l.stopLoad=function(){this.canload=!1},l.onManifestLoaded=function(e){var t,r=[],i=[],n={},a=null,s=!1,l=!1;if(e.levels.forEach((function(e){var t=e.attrs;e.loadError=0,e.fragmentError=!1,s=s||!!e.videoCodec,l=l||!!e.audioCodec,Ie&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(a=n[e.bitrate])?a.url.push(e.url):(e.url=[e.url],e.urlId=0,n[e.bitrate]=e,r.push(e)),t&&(t.AUDIO&&J(a||e,"audio",t.AUDIO),t.SUBTITLES&&J(a||e,"text",t.SUBTITLES))})),s&&l&&(r=r.filter((function(e){return!!e.videoCodec}))),r=r.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||S(t,"audio"))&&(!r||S(r,"video"))})),e.audioTracks&&(i=e.audioTracks.filter((function(e){return!e.audioCodec||S(e.audioCodec,"audio")}))).forEach((function(e,t){e.id=t})),r.length>0){t=r[0].bitrate,r.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=r;for(var d=0;d<r.length;d++)if(r[d].bitrate===t){this._firstLevel=d,c.logger.log("manifest loaded,"+r.length+" level(s) found, first bitrate:"+t);break}var h=l&&!s;this.hls.trigger(u.default.MANIFEST_PARSED,{levels:r,audioTracks:i,firstLevel:this._firstLevel,stats:e.stats,audio:l,video:s,altAudio:!h&&i.some((function(e){return!!e.url}))})}else this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},l.setLevelInternal=function(e){var t=this._levels,r=this.hls;if(e>=0&&e<t.length){if(this.clearTimer(),this.currentLevelIndex!==e){c.logger.log("switching to level "+e),this.currentLevelIndex=e;var i=t[e];i.level=e,r.trigger(u.default.LEVEL_SWITCHING,i)}var n=t[e],a=n.details;if(!a||a.live){var s=n.urlId;r.trigger(u.default.LEVEL_LOADING,{url:n.url[s],level:e,id:s})}}else r.trigger(u.default.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})},l.onError=function(e){if(e.fatal)e.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer();else{var t,r=!1,i=!1;switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:t=e.frag.level,i=!0;break;case o.ErrorDetails.LEVEL_LOAD_ERROR:case o.ErrorDetails.LEVEL_LOAD_TIMEOUT:t=e.context.level,r=!0;break;case o.ErrorDetails.REMUX_ALLOC_ERROR:t=e.level,r=!0}void 0!==t&&this.recoverLevel(e,t,r,i)}},l.recoverLevel=function(e,t,r,i){var n,a,s,o=this,l=this.hls.config,u=e.details,d=this._levels[t];if(d.loadError++,d.fragmentError=i,r){if(!(this.levelRetryCount+1<=l.levelLoadingMaxRetry))return c.logger.error("level controller, cannot recover from "+u+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);a=Math.min(Math.pow(2,this.levelRetryCount)*l.levelLoadingRetryDelay,l.levelLoadingMaxRetryTimeout),this.timer=setTimeout((function(){return o.loadLevel()}),a),e.levelRetry=!0,this.levelRetryCount++,c.logger.warn("level controller, "+u+", retry in "+a+" ms, current retry count is "+this.levelRetryCount)}(r||i)&&((n=d.url.length)>1&&d.loadError<n?(d.urlId=(d.urlId+1)%n,d.details=void 0,c.logger.warn("level controller, "+u+" for level "+t+": switching to redundant URL-id "+d.urlId)):-1===this.manualLevelIndex?(s=0===t?this._levels.length-1:t-1,c.logger.warn("level controller, "+u+": switch to "+s),this.hls.nextAutoLevel=this.currentLevelIndex=s):i&&(c.logger.warn("level controller, "+u+": reload a fragment"),this.currentLevelIndex=null))},l.onFragLoaded=function(e){var t=e.frag;if(void 0!==t&&"main"===t.type){var r=this._levels[t.level];void 0!==r&&(r.fragmentError=!1,r.loadError=0,this.levelRetryCount=0)}},l.onLevelLoaded=function(e){var t=this,r=e.level,i=e.details;if(r===this.currentLevelIndex){var n=this._levels[r];if(n.fragmentError||(n.loadError=0,this.levelRetryCount=0),i.live){var a=ne(n.details,i,e.stats.trequest);c.logger.log("live playlist, reload in "+Math.round(a)+" ms"),this.timer=setTimeout((function(){return t.loadLevel()}),a)}else this.clearTimer()}},l.onAudioTrackSwitched=function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=0;n<r.audioGroupIds.length;n++)if(r.audioGroupIds[n]===t){i=n;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},l.loadLevel=function(){if(c.logger.debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload){var e=this._levels[this.currentLevelIndex];if("object"==typeof e&&e.url.length>0){var t=this.currentLevelIndex,r=e.urlId,i=e.url[r];c.logger.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(u.default.LEVEL_LOADING,{url:i,level:t,id:r})}}},l.removeLevel=function(e,t){var r=this.levels.filter((function(r,i){return i!==e||r.url.length>1&&void 0!==t&&(r.url=r.url.filter((function(e,r){return r!==t})),r.urlId=0,!0)})).map((function(e,t){var r=e.details;return r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=r,this.hls.trigger(u.default.LEVELS_UPDATED,{levels:r})},n=i,(a=[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&xe(n.prototype,a),s&&xe(n,s),i}(h),Me=r("./src/demux/id3.js");function Fe(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Ue(e){if(null==e?void 0:e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}var Be=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_METADATA,u.default.LIVE_BACK_BUFFER_REACHED)||this).id3Track=void 0,r.media=void 0,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){h.prototype.destroy.call(this)},n.onMediaAttached=function(e){this.media=e.media,this.media},n.onMediaDetaching=function(){Ue(this.id3Track),this.id3Track=void 0,this.media=void 0},n.getID3Track=function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Fe(r,this.media),r}return this.media.addTextTrack("metadata","id3")},n.onFragParsingMetadata=function(e){var t=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,n=0;n<r.length;n++){var a=Me.default.getID3Frames(r[n].data);if(a){var s=Math.max(r[n].pts,0),o=n<r.length-1?r[n+1].pts:t.endPTS;o||(o=t.start+t.duration),o-s<=0&&(o=s+.25);for(var l=0;l<a.length;l++){var u=a[l];if(!Me.default.isTimeStampFrame(u)){var c=new i(s,o,"");c.value=u,this.id3Track.addCue(c)}}}}},n.onLiveBackBufferReached=function(e){var t=e.bufferEnd,r=this.id3Track;if(r&&r.cues&&r.cues.length){var i=function(e,t){if(t<e[0].endTime)return e[0];if(t>e[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var n=Math.floor((i+r)/2);if(t<e[n].endTime)i=n-1;else{if(!(t>e[n].endTime))return e[n];r=n+1}}return e[r].endTime-t<t-e[i].endTime?e[r]:e[i]}(r.cues,t);if(i)for(;r.cues[0]!==i;)r.removeCue(r.cues[0])}},i}(h),je=function(){function e(e){this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=0,this.totalWeight_=0}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/e}return this.estimate_},e}(),Ge=function(){function e(e,t,r,i){this.hls=void 0,this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.hls=e,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new je(t),this.fast_=new je(r)}var t=e.prototype;return t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function Ke(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Ye=window.performance,Ve=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.FRAG_LOADING,u.default.FRAG_LOADED,u.default.FRAG_BUFFERED,u.default.ERROR)||this).lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=t,r.timer=null,r._bwEstimator=null,r.onCheck=r._abandonRulesCheck.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,d=i.prototype;return d.destroy=function(){this.clearTimer(),h.prototype.destroy.call(this)},d.onFragLoading=function(e){var t=e.frag;if("main"===t.type&&(this.timer||(this.fragCurrent=t,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var r,i,n=this.hls,a=n.config,s=t.level;n.levels[s].details.live?(r=a.abrEwmaFastLive,i=a.abrEwmaSlowLive):(r=a.abrEwmaFastVoD,i=a.abrEwmaSlowVoD),this._bwEstimator=new Ge(n,i,r,a.abrEwmaDefaultEstimate)}},d._abandonRulesCheck=function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var i=r.loader;if(!i||i.stats&&i.stats.aborted)return c.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var n=i.stats;if(t&&n&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var a=Ye.now()-n.trequest,s=Math.abs(t.playbackRate);if(a>500*r.duration/s){var o=e.levels,l=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/a),d=o[r.level];if(!d)return;var h=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,f=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*h/8)),g=t.currentTime,p=(f-n.loaded)/l,v=(Y.bufferInfo(t,g,e.config.maxBufferHole).end-g)/s;if(v<2*r.duration/s&&p>v){var m,A,y=e.minAutoLevel;for(A=r.level-1;A>y;A--){var E=o[A].realBitrate?Math.max(o[A].realBitrate,o[A].bitrate):o[A].bitrate;if(r.duration*E/(6.4*l)<v)break}m<p&&(c.logger.warn("loading too slow, abort fragment loading and switch to level "+A+":fragLoadedDelay["+A+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+m.toFixed(1)+"<"+p.toFixed(1)+":"+v.toFixed(1)),e.nextLoadLevel=A,this._bwEstimator.sample(a,n.loaded),i.abort(),this.clearTimer(),e.trigger(u.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:n}))}}}}},d.onFragLoaded=function(e){var t=e.frag;if("main"===t.type&&Object(l.isFiniteNumber)(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],i=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,n=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:i,duration:n},r.realBitrate=Math.round(8*i/n)}if(e.frag.bitrateTest){var a=e.stats;a.tparsed=a.tbuffered=a.tload,this.onFragBuffered(e)}}},d.onFragBuffered=function(e){var t=e.stats,r=e.frag;if(!0!==t.aborted&&"main"===r.type&&Object(l.isFiniteNumber)(r.sn)&&(!r.bitrateTest||t.tload===t.tbuffered)){var i=t.tparsed-t.trequest;c.logger.log("latency/loading/parsing/append/kbps:"+Math.round(t.tfirst-t.trequest)+"/"+Math.round(t.tload-t.tfirst)+"/"+Math.round(t.tparsed-t.tload)+"/"+Math.round(t.tbuffered-t.tparsed)+"/"+Math.round(8*t.loaded/(t.tbuffered-t.trequest))),this._bwEstimator.sample(i,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},d.onError=function(e){switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){clearInterval(this.timer),this.timer=null},d._findBestLevel=function(e,t,r,i,n,a,s,o,l){for(var u=n;u>=i;u--){var d=l[u];if(d){var h=d.details,f=h?h.totalduration/h.fragments.length:t,g=!!h&&h.live,p=void 0;p=u<=e?s*r:o*r;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,m=v*f/p;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+v+"/"+f+"/"+a+"/"+m),p>v&&(!m||g&&!this.bitrateTestDelay||m<a))return u}}return-1},n=i,(a=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this._nextABRAutoLevel;return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.levels,i=e.config,n=e.minAutoLevel,a=e.media,s=this.lastLoadedFragLevel,o=this.fragCurrent?this.fragCurrent.duration:0,l=a?a.currentTime:0,u=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,d=this._bwEstimator?this._bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,h=(Y.bufferInfo(a,l,i.maxBufferHole).end-l)/u,f=this._findBestLevel(s,o,d,n,t,h,i.abrBandWidthFactor,i.abrBandWidthUpFactor,r);if(f>=0)return f;c.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var g=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,v=i.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;m&&(g=(o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay)-m,c.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),p=v=1)}return f=this._findBestLevel(s,o,d,n,t,h+g,p,v,r),Math.max(f,0)}}])&&Ke(n.prototype,a),s&&Ke(n,s),i}(h),He=z(),We=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_RESET,u.default.BUFFER_APPENDING,u.default.BUFFER_CODECS,u.default.BUFFER_EOS,u.default.BUFFER_FLUSHING,u.default.LEVEL_PTS_UPDATED,u.default.LEVEL_UPDATED)||this)._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r._needsFlush=!1,r._needsEos=!1,r.config=void 0,r.audioTimestampOffset=void 0,r.bufferCodecEventsExpected=0,r._bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.segments=[],r.parent=void 0,r.appending=!1,r.appended=0,r.appendError=0,r.flushBufferCounter=0,r.tracks={},r.pendingTracks={},r.sourceBuffer={},r.flushRange=[],r._onMediaSourceOpen=function(){c.logger.log("media source opened"),r.hls.trigger(u.default.MEDIA_ATTACHED,{media:r.media});var e=r.mediaSource;e&&e.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},r._onMediaSourceClose=function(){c.logger.log("media source closed")},r._onMediaSourceEnded=function(){c.logger.log("media source ended")},r._onSBUpdateEnd=function(){if(r.audioTimestampOffset&&r.sourceBuffer.audio){var e=r.sourceBuffer.audio;c.logger.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+r.audioTimestampOffset),e.timestampOffset=r.audioTimestampOffset,delete r.audioTimestampOffset}r._needsFlush&&r.doFlush(),r._needsEos&&r.checkEos(),r.appending=!1;var t=r.parent,i=r.segments.reduce((function(e,r){return r.parent===t?e+1:e}),0),n={},a=r.sourceBuffer;for(var s in a){var o=a[s];if(!o)throw Error("handling source buffer update end error: source buffer for "+s+" uninitilized and unable to update buffered TimeRanges.");n[s]=o.buffered}r.hls.trigger(u.default.BUFFER_APPENDED,{parent:t,pending:i,timeRanges:n}),r._needsFlush||r.doAppending(),r.updateMediaElementDuration(),0===i&&r.flushLiveBackBuffer()},r._onSBUpdateError=function(e){c.logger.error("sourceBuffer error:",e),r.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},r.config=t.config,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){h.prototype.destroy.call(this)},n.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(!i)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(Math.abs(i.timestampOffset-e.start)>.1){var n=i.updating;try{i.abort()}catch(e){c.logger.warn("can not abort audio buffer: "+e)}n?this.audioTimestampOffset=e.start:(c.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}},n.onManifestParsed=function(e){var t=2;(e.audio&&!e.video||!e.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,c.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e){var t=this.media=e.media;if(t&&He){var r=this.mediaSource=new He;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}},n.onMediaDetaching=function(){c.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){c.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.media&&(this._objectUrl&&window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):c.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.hls.trigger(u.default.MEDIA_DETACHED)},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},n.onBufferReset=function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];try{r&&(this.mediaSource&&this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this._onSBUpdateEnd),r.removeEventListener("error",this._onSBUpdateError))}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},n.onBufferCodecs=function(e){var t=this;Object.keys(this.sourceBuffer).length||(Object.keys(e).forEach((function(r){t.pendingTracks[r]=e[r]})),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},n.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var n=e[i];if(!n)throw Error("source buffer exists for track "+i+", however track does not");var a=n.levelCodec||n.codec,s=n.container+";codecs="+a;c.logger.log("creating sourceBuffer("+s+")");try{var l=t[i]=r.addSourceBuffer(s);l.addEventListener("updateend",this._onSBUpdateEnd),l.addEventListener("error",this._onSBUpdateError),this.tracks[i]={buffer:l,codec:a,id:n.id,container:n.container,levelCodec:n.levelCodec}}catch(e){c.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:s})}}this.hls.trigger(u.default.BUFFER_CREATED,{tracks:this.tracks})},n.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},n.onBufferEos=function(e){for(var t in this.sourceBuffer)if(!e.type||e.type===t){var r=this.sourceBuffer[t];r&&!r.ended&&(r.ended=!0,c.logger.log(t+" sourceBuffer now EOS"))}this.checkEos()},n.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var i=e[r];if(i){if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}}c.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){c.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},n.onBufferFlushing=function(e){e.type?this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}):(this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"video"}),this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"audio"})),this.flushBufferCounter=0,this.doFlush()},n.flushLiveBackBuffer=function(){if(this._live){var e=this.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))if(this.media)for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),n=t-Math.max(e,this._levelTargetDuration),a=i.length-1;a>=0;a--){var s=i[a],o=r[s];if(o){var l=o.buffered;l.length>0&&n>l.start(0)&&this.removeBufferRange(s,o,0,n)&&this.hls.trigger(u.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n})}}else c.logger.error("flushLiveBackBuffer called without attaching media")}},n.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},n.updateMediaElementDuration=function(){var e,t=this.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer){var i=this.sourceBuffer[r];if(i&&!0===i.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(c.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(l.isFiniteNumber)(e))&&(c.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},n.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var n=r[i];n&&(t+=n.buffered.length)}}catch(e){c.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(u.default.BUFFER_FLUSHED)}},n.doAppending=function(){var e=this.config,t=this.hls,r=this.segments,i=this.sourceBuffer;if(Object.keys(i).length){if(!this.media||this.media.error)return this.segments=[],void c.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var n=r.shift();if(n)try{var a=i[n.type];if(!a)return void this._onSBUpdateEnd();if(a.updating)return void r.unshift(n);a.ended=!1,this.parent=n.parent,a.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0}catch(i){c.logger.error("error while trying to append buffer:"+i.message),r.unshift(n);var s={type:o.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===i.code?(this.segments=[],s.details=o.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,s.details=o.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.appendErrorMaxRetry&&(c.logger.log("fail "+e.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],s.fatal=!0)),t.trigger(u.default.ERROR,s)}}}},n.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var n="null";if(this.media&&(n=this.media.currentTime.toFixed(3)),c.logger.log("flushBuffer,pos/start/end: "+n+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return c.logger.warn("abort flushing too many retries"),!0;var a=i[r];if(a){if(a.ended=!1,a.updating)return c.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,a,e,t))return this.flushBufferCounter++,!1}return c.logger.log("buffer flushed"),!0},n.removeBufferRange=function(e,t,r,i){try{for(var n=0;n<t.buffered.length;n++){var a=t.buffered.start(n),s=t.buffered.end(n),o=Math.max(a,r),l=Math.min(s,i);if(Math.min(l,s)-o>.5){var u="null";return this.media&&(u=this.media.currentTime.toString()),c.logger.log("sb remove "+e+" ["+o+","+l+"], of ["+a+","+s+"], pos:"+u),t.remove(o,l),!0}}}catch(e){c.logger.warn("removeBufferRange failed",e)}return!1},i}(h);function ze(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var qe=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.FPS_DROP_LEVEL_CAPPING,u.default.MEDIA_ATTACHING,u.default.MANIFEST_PARSED,u.default.LEVELS_UPDATED,u.default.BUFFER_CODECS,u.default.MEDIA_DETACHING)||this).autoLevelCapping=Number.POSITIVE_INFINITY,r.firstLevel=null,r.levels=[],r.media=null,r.restrictedLevels=[],r.timer=null,r.clientRect=null,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,o=i.prototype;return o.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this.clientRect=null,this.stopCapping())},o.onFpsDropLevelCapping=function(e){i.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)},o.onMediaAttaching=function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null},o.onManifestParsed=function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onBufferCodecs=function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},o.onLevelsUpdated=function(e){this.levels=e.levels},o.onMediaDetaching=function(){this.stopCapping()},o.detectPlayerSize=function(){if(this.media){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},o.getMaxLevel=function(e){var t=this;if(!this.levels)return-1;var r=this.levels.filter((function(r,n){return i.isLevelAllowed(n,t.restrictedLevels)&&n<=e}));return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},o.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},o.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},o.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},i.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},i.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var i,n,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(i=o,!(n=e[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},n=i,s=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(a=[{key:"mediaWidth",get:function(){return this.getDimensions().width*i.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*i.contentScaleFactor}}])&&ze(n.prototype,a),s&&ze(n,s),i}(h),Xe=window.performance,$e=function(e){var t,r;function i(t){return e.call(this,t,u.default.MEDIA_ATTACHING)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},n.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},n.checkFPS=function(e,t,r){var i=Xe.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(u.default.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var d=l.currentLevel;c.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=d)&&(d-=1,l.trigger(u.default.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},i}(h),Ze=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:window.performance.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e,t=this.context;e=this.loader=new window.XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(r){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},t.readystatechange=function(e){var t=e.currentTarget,r=t.readyState,i=this.stats,n=this.context,a=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(window.performance.now(),i.trequest)),4===r){var s=t.status;if(s>=200&&s<300){var o,l;i.tload=Math.max(i.tfirst,window.performance.now()),l="arraybuffer"===n.responseType?(o=t.response).byteLength:(o=t.responseText).length,i.loaded=i.total=l;var u={url:t.responseURL,data:o};this.callbacks.onSuccess(u,i,n,t)}else i.retry>=a.maxRetry||s>=400&&s<499?(c.logger.error(s+" while loading "+n.url),this.callbacks.onError({code:s,text:t.statusText},n,t)):(c.logger.warn(s+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),a.timeout)},t.loadtimeout=function(){c.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)},e}();function Qe(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var Je=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MANIFEST_LOADING,u.default.MANIFEST_PARSED,u.default.AUDIO_TRACK_LOADED,u.default.AUDIO_TRACK_SWITCHED,u.default.LEVEL_LOADED,u.default.ERROR)||this)._trackId=-1,r._selectDefaultTrack=!0,r.tracks=[],r.trackIdBlacklist=Object.create(null),r.audioGroupId=null,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,l=i.prototype;return l.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},l.onManifestParsed=function(e){var t=this.tracks=e.audioTracks||[];this.hls.trigger(u.default.AUDIO_TRACKS_UPDATED,{audioTracks:t}),this._selectAudioGroup(this.hls.nextLoadLevel)},l.onAudioTrackLoaded=function(e){if(e.id>=this.tracks.length)c.logger.warn("Invalid audio track id:",e.id);else{if(c.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}},l.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},l.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},l.onError=function(e){e.type===o.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(c.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},l._setAudioTrack=function(e){if(this._trackId===e&&this.tracks[this._trackId].details)c.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)c.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];c.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,i=t.type,n=t.id;this.hls.trigger(u.default.AUDIO_TRACK_SWITCHING,{id:n,type:i,url:r}),this._loadTrackDetailsIfNeeded(t)}},l.doTick=function(){this._updateTrack(this._trackId)},l._selectAudioGroup=function(e){var t=this.hls.levels[e];if(t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}},l._selectInitialAudioTrack=function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var n=t.filter((function(e){return e.default}));n.length?t=n:c.logger.warn("No default audio tracks defined")}var a=!1,s=function(){t.forEach((function(t){a||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),a=!0)}))};s(),a||(i=null,s()),a||(c.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},l._needsTrackLoading=function(e){var t=e.details,r=e.url;return!(t&&!t.live||!r)},l._loadTrackDetailsIfNeeded=function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;c.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(u.default.AUDIO_TRACK_LOADING,{url:t,id:r})}},l._updateTrack=function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,c.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}},l._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,n=t.groupId;c.logger.warn("Loading failed on audio track id: "+e+", group-id: "+n+', name/language: "'+r+'" / "'+i+'"');for(var a=e,s=0;s<this.tracks.length;s++)if(!this.trackIdBlacklist[s]&&this.tracks[s].name===r){a=s;break}a!==e?(c.logger.log("Attempting audio-track fallback id:",a,"group-id:",this.tracks[a].groupId),this._setAudioTrack(a)):c.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"')},n=i,(a=[{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}])&&Qe(n.prototype,a),s&&Qe(n,s),i}(ge);function et(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var tt=window.performance,rt=function(e){var t,r;function i(t,r){var i;return(i=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.AUDIO_TRACKS_UPDATED,u.default.AUDIO_TRACK_SWITCHING,u.default.AUDIO_TRACK_LOADED,u.default.KEY_LOADED,u.default.FRAG_LOADED,u.default.FRAG_PARSING_INIT_SEGMENT,u.default.FRAG_PARSING_DATA,u.default.FRAG_PARSED,u.default.ERROR,u.default.BUFFER_RESET,u.default.BUFFER_CREATED,u.default.BUFFER_APPENDED,u.default.BUFFER_FLUSHED,u.default.INIT_PTS_FOUND)||this).fragmentTracker=r,i.config=t.config,i.audioCodecSwap=!1,i._state=pe,i.initPTS=[],i.waitingFragment=null,i.videoTrackCC=null,i.waitingVideoCC=null,i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,d=i.prototype;return d.onInitPtsFound=function(e){var t=e.id,r=e.frag.cc,i=e.initPTS;"main"===t&&(this.initPTS[r]=i,this.videoTrackCC=r,c.logger.log("InitPTS for cc: "+r+" found from main: "+i),this.state===Le&&this.tick())},d.startLoad=function(e){if(this.tracks){var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(c.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=me):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=ve),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=pe},d.doTick=function(){var e,t,r,i=this.hls,n=i.config;switch(this.state){case we:case Ae:case Se:break;case ve:this.state=Te,this.loadedmetadata=!1;break;case me:var a=this.tracks;if(!a)break;if(!this.media&&(this.startFragRequested||!n.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var s=this.mediaBuffer?this.mediaBuffer:this.media,o=this.videoBuffer?this.videoBuffer:this.media,d=e<n.maxBufferHole?Math.max(2,n.maxBufferHole):n.maxBufferHole,h=Y.bufferInfo(s,e,d),f=Y.bufferInfo(o,e,d),g=h.len,p=h.end,v=this.fragPrevious,m=Math.min(n.maxBufferLength,n.maxMaxBufferLength),A=Math.max(m,f.len),y=this.audioSwitch,E=this.trackId;if((g<A||y)&&E<a.length){if(void 0===(r=a[E].details)){this.state=Te;break}if(!y&&this._streamEnded(h,r))return this.hls.trigger(u.default.BUFFER_EOS,{type:"audio"}),void(this.state=Re);var _,T=r.fragments,b=T.length,k=T[0].start,S=T[b-1].start+T[b-1].duration;if(y)if(r.live&&!r.PTSKnown)c.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),p=0;else if(p=e,r.PTSKnown&&e<k){if(!(h.end>k||h.nextStart))return;c.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=k+.05}if(r.initSegment&&!r.initSegment.data)_=r.initSegment;else if(p<=k){if(_=T[0],null!==this.videoTrackCC&&_.cc!==this.videoTrackCC&&(_=function(e,t){return K.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}(T,this.videoTrackCC)),r.live&&_.loadIdx&&_.loadIdx===this.fragLoadIdx){var R=h.nextStart?h.nextStart:k;return c.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(R+.05)),void(this.media.currentTime=R+.05)}}else{var w,L=n.maxFragLookUpTolerance,C=v?T[v.sn-T[0].sn+1]:void 0;p<S?(p>S-L&&(L=0),w=C&&!ce(p,L,C)?C:K.search(T,(function(e){return ce(p,L,e)}))):w=T[b-1],w&&(_=w,k=w.start,v&&_.level===v.level&&_.sn===v.sn&&(_.sn<r.endSN?(_=T[_.sn+1-r.startSN],this.fragmentTracker.getState(_)!==j&&c.logger.log("SN just loaded, load next one: "+_.sn)):_=null))}_&&(_.encrypted?(c.logger.log("Loading key for "+_.sn+" of ["+r.startSN+" ,"+r.endSN+"],track "+E),this.state=ye,i.trigger(u.default.KEY_LOADING,{frag:_})):(this.fragCurrent=_,(y||this.fragmentTracker.getState(_)===F)&&(c.logger.log("Loading "+_.sn+", cc: "+_.cc+" of ["+r.startSN+" ,"+r.endSN+"],track "+E+", "+(this.loadedmetadata?"currentTime":"nextLoadPosition")+": "+e+", bufferEnd: "+p.toFixed(3)),"initSegment"!==_.sn&&(this.startFragRequested=!0),Object(l.isFiniteNumber)(_.sn)&&(this.nextLoadPosition=_.start+_.duration),i.trigger(u.default.FRAG_LOADING,{frag:_}),this.state=Ee)))}break;case Te:(t=this.tracks[this.trackId])&&t.details&&(this.state=me);break;case _e:var O=tt.now(),D=this.retryDate,I=(s=this.media)&&s.seeking;(!D||O>=D||I)&&(c.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=me);break;case Le:var P=this.waitingFragment;if(P){var x=P.frag.cc;if(void 0!==this.initPTS[x])this.waitingFragment=null,this.state=Ee,this.onFragLoaded(P);else if(this.videoTrackCC!==this.waitingVideoCC)c.logger.log("Waiting fragment cc ("+x+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var N=Y.bufferInfo(this.mediaBuffer,this.media.currentTime,n.maxBufferHole);ce(N.end,n.maxFragLookUpTolerance,P.frag)<0&&(c.logger.log("Waiting fragment cc ("+x+") @ "+P.frag.start+" cancelled because another fragment at "+N.end+" is needed"),this.clearWaitingFragment())}}else this.state=me}},d.clearWaitingFragment=function(){var e=this.waitingFragment;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingFragment=null,this.waitingVideoCC=null,this.state=me)},d.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},d.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(c.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},d.onAudioTracksUpdated=function(e){c.logger.log("audio tracks updated"),this.tracks=e.audioTracks},d.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.clearWaitingFragment(),this.state=Ae,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=me),this.tick()},d.onAudioTrackLoaded=function(e){var t=e.details,r=e.id,i=this.tracks[r],n=i.details,a=t.totalduration,s=0;if(c.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.live||n&&n.live?n&&t.fragments.length>0?(re(n,t),s=t.fragments[0].start,t.PTSKnown?c.logger.log("live audio playlist sliding:"+s.toFixed(3)):c.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,c.logger.log("live audio playlist - first load, unknown sliding")):t.PTSKnown=!1,i.details=t,!this.startFragRequested){if(-1===this.startPosition){var o=t.startTimeOffset;Object(l.isFiniteNumber)(o)?(c.logger.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o):t.live?(this.startPosition=this.computeLivePosition(s,t),c.logger.log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===Te&&(this.state=me),this.tick()},d.onKeyLoaded=function(){this.state===ye&&(this.state=me,this.tick())},d.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag;if(this.state===Ee&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var i=this.tracks[this.trackId],n=i.details,a=n.totalduration,s=t.level,o=t.sn,l=t.cc,d=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",h=this.stats=e.stats;if("initSegment"===o)this.state=me,h.tparsed=h.tbuffered=tt.now(),n.initSegment.data=e.payload,this.hls.trigger(u.default.FRAG_BUFFERED,{stats:h,frag:t,id:"audio"}),this.tick();else{this.state=be,this.appended=!1,this.demuxer||(this.demuxer=new Q(this.hls,"audio"));var f=this.initPTS[l],g=n.initSegment?n.initSegment.data:[];void 0!==f?(this.pendingBuffering=!0,c.logger.log("Demuxing "+o+" of ["+n.startSN+" ,"+n.endSN+"],track "+s),this.demuxer.push(e.payload,g,d,null,t,a,!1,f)):(c.logger.log("Unknown video PTS for cc "+l+", waiting for video PTS before demuxing audio frag "+o+" of ["+n.startSN+" ,"+n.endSN+"],track "+s),this.waitingFragment=e,this.waitingVideoCC=this.videoTrackCC,this.state=Le)}}this.fragLoadError=0},d.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===be){var i,n=e.tracks;if(n.video&&delete n.video,i=n.audio){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(u.default.BUFFER_CODECS,n),c.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var a=i.initSegment;if(a){var s={type:"audio",data:a,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[s]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,s))}this.tick()}}},d.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&i.sn===r.sn&&i.level===r.level&&this.state===be){var n=this.trackId,a=this.tracks[n],s=this.hls;Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),r.addElementaryStream(p.AUDIO),c.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),te(a.details,r,e.startPTS,e.endPTS);var d=this.media,h=!1;if(this.audioSwitch)if(d&&d.readyState){var f=d.currentTime;c.logger.log("switching audio track : currentTime:"+f),f>=e.startPTS&&(c.logger.log("switching audio track : flushing all audio"),this.state=Se,s.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),h=!0,this.audioSwitch=!1,s.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:n}))}else this.audioSwitch=!1,s.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:n});var g=this.pendingData;if(!g)return c.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void s.trigger(u.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach((function(t){t&&t.length&&g.push({type:e.type,data:t,parent:"audio",content:"data"})})),!h&&g.length&&(g.forEach((function(e){t.state===be&&(t.pendingBuffering=!0,t.hls.trigger(u.default.BUFFER_APPENDING,e))})),this.pendingData=[],this.appended=!0)),this.tick()}},d.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===be&&(this.stats.tparsed=tt.now(),this.state=ke,this._checkAppendedParsed())},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},d.onBufferAppended=function(e){if("audio"===e.parent){var t=this.state;t!==be&&t!==ke||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},d._checkAppendedParsed=function(){if(!(this.state!==ke||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=tt.now(),r.trigger(u.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;i&&c.logger.log("audio buffered : "+ae.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=me}this.tick()}},d.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var n=this.config;if(i<=n.fragLoadingMaxRetry){this.fragLoadError=i;var a=Math.min(Math.pow(2,i-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);c.logger.warn("AudioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=tt.now()+a,this.state=_e}else c.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=we}break;case o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case o.ErrorDetails.KEY_LOAD_ERROR:case o.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==we&&(this.state=e.fatal?we:me,c.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case o.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===be||this.state===ke)){var s=this.mediaBuffer,l=this.media.currentTime;if(s&&Y.isBuffered(s,l)&&Y.isBuffered(s,l+.5)){var d=this.config;d.maxMaxBufferLength>=d.maxBufferLength&&(d.maxMaxBufferLength/=2,c.logger.warn("AudioStreamController: reduce max buffer length to "+d.maxMaxBufferLength+"s")),this.state=me}else c.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Se,this.hls.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},d.onBufferFlushed=function(){var e=this,t=this.pendingData;t&&t.length?(c.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach((function(t){e.hls.trigger(u.default.BUFFER_APPENDING,t)})),this.appended=!0,this.pendingData=[],this.state=ke):(this.state=me,this.fragPrevious=null,this.tick())},n=i,(a=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,c.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}])&&et(n.prototype,a),s&&et(n,s),i}(Oe),it=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function r(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}function i(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]=r[i]}return e}function n(t,n,a){var s=this,o={enumerable:!0};s.hasBeenReset=!1;var l="",u=!1,c=t,d=n,h=a,f=null,g="",p=!0,v="auto",m="start",A=50,y="middle",E=50,_="middle";Object.defineProperty(s,"id",i({},o,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",i({},o,{get:function(){return u},set:function(e){u=!!e}})),Object.defineProperty(s,"startTime",i({},o,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",i({},o,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",i({},o,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",i({},o,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",i({},o,{get:function(){return g},set:function(t){var r=function(t){return"string"==typeof t&&!!e[t.toLowerCase()]&&t.toLowerCase()}(t);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");g=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",i({},o,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",i({},o,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",i({},o,{get:function(){return m},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",i({},o,{get:function(){return A},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",i({},o,{get:function(){return y},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",i({},o,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",i({},o,{get:function(){return _},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),s.displayState=void 0}return n.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},n}(),nt=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function at(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new nt,this.regionList=[]}function st(){this.values=Object.create(null)}function ot(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);2===s.length&&t(s[0],s[1])}}st.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(t=parseFloat(t))>=0&&t<=100)&&(this.set(e,t),!0)}};var lt=new it(0,0,0),ut="middle"===lt.align?"middle":"center";function ct(e,t,r){var i=e;function n(){var t=function(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),a(),t.endTime=n(),a(),function(e,t){var i=new st;ot(e,(function(e,t){switch(e){case"region":for(var n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var a=t.split(","),s=a[0];i.integer(e,s),i.percent(e,s)&&i.set("snapToLines",!1),i.alt(e,s,["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",ut,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",ut,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",ut,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===lt.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",ut);var a=i.get("position","auto");"auto"===a&&50===lt.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function dt(e){return e.replace(/<br(?: \/)?>/gi,"\n")}at.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=dt(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var n=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!n||!n[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var a=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=r(),t.state){case"HEADER":/:/.test(i)?ot(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new it(0,0,""),t.state="CUE",-1===i.indexOf("--\x3e")){t.cue.id=i;continue}case"CUE":try{ct(i,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==i.indexOf("--\x3e");if(!i||s&&(a=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID");continue}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),(e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state)throw new Error("Malformed WebVTT signature.")}catch(e){throw e}return e.onflush&&e.onflush(),this}};var ht=at;function ft(e,t,r,i){for(var n,a,s,o,l,u=[],c=window.VTTCue||TextTrackCue,d=0;d<i.rows.length;d++)if(s=!0,o=0,l="",!(n=i.rows[d]).isEmpty()){for(var h=0;h<n.chars.length;h++)n.chars[h].uchar.match(/\s/)&&s?o++:(l+=n.chars[h].uchar,s=!1);n.cueStartTime=t,t===r&&(r+=1e-4),a=new c(t,r,dt(l.trim())),o>=16?o--:o++,navigator.userAgent.match(/Firefox\//)?a.line=d+1:a.line=d>7?d-2:d+1,a.align="left",a.position=Math.max(0,Math.min(100,o/32*100)),u.push(a),e&&e.addCue(a)}return u}var gt,pt={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},vt=function(e){var t=e;return pt.hasOwnProperty(e)&&(t=pt[e]),String.fromCharCode(t)},mt=15,At=100,yt={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Et={17:2,18:4,21:6,22:8,23:10,19:13,20:15},_t={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Tt={25:2,26:4,29:6,30:8,31:10,27:13,28:15},bt=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(e){e[e.ERROR=0]="ERROR",e[e.TEXT=1]="TEXT",e[e.WARNING=2]="WARNING",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.DATA=3]="DATA"}(gt||(gt={}));var kt=function(){function e(){this.time=null,this.verboseLevel=gt.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&c.logger.log(this.time+" ["+e+"] "+t)},e}(),St=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Rt=function(){function e(e,t,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),wt=function(){function e(e,t,r,i,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Rt(t,r,i,n,a)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),Lt=function(){function e(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<At;t++)this.chars.push(new wt);this.logger=e,this.pos=0,this.currPenState=new Rt}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<At;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<At;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<At;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(gt.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>At&&(this.logger.log(gt.DEBUG,"Too large cursor position "+this.pos),this.pos=At)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=vt(e);this.pos>=At?this.logger.log(gt.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<At;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<At;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),Ct=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<mt;t++)this.rows.push(new Lt(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<mt;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<mt;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<mt;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<mt;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(gt.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(gt.INFO,"pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<mt;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){var a=n.rows[i].cueStartTime,s=this.logger.time;if(a&&null!==s&&a<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(n.rows[i+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,c=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[c].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)},t.setBkgData=function(e){this.logger.log(gt.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(gt.TEXT,this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(gt.INFO,"Rolling up")}else this.logger.log(gt.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,n=0;n<mt;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),Ot=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ct(r),this.nonDisplayedMemory=new Ct(r),this.lastOutputScreen=new Ct(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(gt.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(gt.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(gt.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(gt.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(gt.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(gt.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(gt.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(gt.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(gt.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(gt.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(gt.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(gt.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(gt.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(gt.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(this.logger.log(gt.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(gt.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(gt.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(gt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}();function Dt(e,t,r){r.a=e,r.b=t}function It(e,t,r){return r.a===e&&r.b===t}var Pt=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new kt;this.channels=[null,new Ot(e,t,i),new Ot(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i,n,a=!1;this.logger.time=e;for(var s=0;s<t.length;s+=2)if(i=127&t[s],n=127&t[s+1],0!==i||0!==n){if(this.logger.log(gt.DATA,"["+St([t[s],t[s+1]])+"] -> ("+St([i,n])+")"),(r=this.parseCmd(i,n))||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(a=this.parseChars(i,n))){var o=this.currentChannel;o&&o>0?this.channels[o].insertChars(a):this.logger.log(gt.WARNING,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(gt.WARNING,"Couldn't parse cleaned data "+St([i,n])+" orig: "+St([t[s],t[s+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(It(e,t,r))return Dt(null,null,r),this.logger.log(gt.DEBUG,"Repeated command ("+St([e,t])+") is dropped"),!0;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),Dt(e,t,r),this.currentChannel=i,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(gt.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(gt.DEBUG,"MIDROW ("+St([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(It(e,t,i))return Dt(null,null,i),!0;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?yt[e]:_t[e]:1===n?Et[e]:Tt[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),Dt(e,t,i),this.currentChannel=n,!0)},t.interpretPAC=function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.parseChars=function(e,t){var r,i=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){var a=t;a=17===n?t+80:18===n?t+112:t+144,this.logger.log(gt.INFO,"Special char '"+vt(a)+"' in channel "+r),i=[a]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var s=St(i);this.logger.log(gt.DEBUG,"Char codes = "+s.join(",")),Dt(e,t,this.cmdHistory)}return i},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=bt[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),Dt(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}(),xt=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[]},e}(),Nt=function(e,t,r){return e.substr(r||0,t.length)===t},Mt=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},Ft={parse:function(e,t,r,i,n,a){var s,o=Object(Me.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),u="00:00.000",c=0,d=0,h=0,f=[],g=!0,p=!1,v=new ht;v.oncue=function(e){var t=r[i],n=r.ccOffset;t&&t.new&&(void 0!==d?n=r.ccOffset=t.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;n&&n.new;)e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC];e.presentationOffset=r}(r,i,h)),h&&(n=h-r.presentationOffset),p&&(e.startTime+=n-d,e.endTime+=n-d),e.id=Mt(e.startTime.toString())+Mt(e.endTime.toString())+Mt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&f.push(e)},v.onparsingerror=function(e){s=e},v.onflush=function(){s&&a?a(s):n(f)},o.forEach((function(e){if(g){if(Nt(e,"X-TIMESTAMP-MAP=")){g=!1,p=!0,e.substr(16).split(",").forEach((function(e){Nt(e,"LOCAL:")?u=e.substr(6):Nt(e,"MPEGTS:")&&(c=parseInt(e.substr(7)))}));try{t+(9e4*r[i].start||0)<0&&(t+=8589934592),c-=t,d=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),n=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(l.isFiniteNumber)(t)&&Object(l.isFiniteNumber)(r)&&Object(l.isFiniteNumber)(i)&&Object(l.isFiniteNumber)(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,(t+=6e4*i)+36e5*n}(u)/1e3,h=c/9e4}catch(e){p=!1,s=e}return}""===e&&(g=!1)}v.parse(e+"\n")})),v.flush()}};function Ut(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Bt(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}var jt=function(e){var t,r;function i(t){var r;if((r=e.call(this,t,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_USERDATA,u.default.FRAG_DECRYPTED,u.default.MANIFEST_LOADING,u.default.MANIFEST_LOADED,u.default.FRAG_LOADED,u.default.INIT_PTS_FOUND)||this).media=null,r.config=void 0,r.enabled=!0,r.Cues=void 0,r.textTracks=[],r.tracks=[],r.initPTS=[],r.unparsedVttFrags=[],r.captionsTracks={},r.nonNativeCaptionsTracks={},r.captionsProperties=void 0,r.cea608Parser1=void 0,r.cea608Parser2=void 0,r.lastSn=-1,r.prevCC=-1,r.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},r.hls=t,r.config=t.config,r.Cues=t.config.cueHandler,r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode},textTrack3:{label:r.config.captionsTextTrack3Label,languageCode:r.config.captionsTextTrack3LanguageCode},textTrack4:{label:r.config.captionsTextTrack4Label,languageCode:r.config.captionsTextTrack4LanguageCode}},r.config.enableCEA708Captions){var i=new xt(Ut(r),"textTrack1"),n=new xt(Ut(r),"textTrack2"),a=new xt(Ut(r),"textTrack3"),s=new xt(Ut(r),"textTrack4");r.cea608Parser1=new Pt(1,i,n),r.cea608Parser2=new Pt(3,a,s)}return r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.addCues=function(e,t,r,i,n){for(var a,s,o,l,c=!1,d=n.length;d--;){var h=n[d],f=(a=h[0],s=h[1],o=t,l=r,Math.min(s,l)-Math.max(a,o));if(f>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),c=!0,f/(r-t)>.5))return}if(c||n.push([t,r]),this.config.renderTextTracksNatively)this.Cues.newCue(this.captionsTracks[e],t,r,i);else{var g=this.Cues.newCue(null,t,r,i);this.hls.trigger(u.default.CUES_PARSED,{type:"captions",cues:g,track:e})}},n.onInitPtsFound=function(e){var t=this,r=e.frag,i=e.id,n=e.initPTS,a=this.unparsedVttFrags;"main"===i&&(this.initPTS[r.cc]=n),a.length&&(this.unparsedVttFrags=[],a.forEach((function(e){t.onFragLoaded(e)})))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},n.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},n.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,n=t[e],a=n.label,s=n.languageCode,o=this.getExistingTrack(e);if(o)r[e]=o,Ue(r[e]),Fe(r[e],i);else{var l=this.createTextTrack("captions",a,s);l&&(l[e]=!0,r[e]=l)}}},n.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(u.default.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},n.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},n.destroy=function(){e.prototype.destroy.call(this)},n.onMediaAttaching=function(e){this.media=e.media,this._cleanTracks()},n.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){Ue(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},n.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={}},n._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)Ue(t[r])}},n.onManifestLoaded=function(e){var t=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset()),this.config.enableWebVTT){var r=e.subtitles||[],i=this.tracks&&r&&this.tracks.length===r.length;if(this.tracks=e.subtitles||[],this.config.renderTextTracksNatively){var n=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,r){var i;if(r<n.length){for(var a=null,s=0;s<n.length;s++)if(Bt(n[s],e)){a=n[s];break}a&&(i=a)}i||(i=t.createTextTrack("subtitles",e.name,e.lang)),e.default?i.mode=t.hls.subtitleDisplay?"showing":"hidden":i.mode="disabled",t.textTracks.push(i)}))}else if(!i&&this.tracks&&this.tracks.length){var a=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(u.default.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((function(e){var r=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(r){var i="textTrack"+r[1],n=t.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}}))},n.onFragLoaded=function(e){var t=e.frag,r=e.payload,i=this.cea608Parser1,n=this.cea608Parser2,a=this.initPTS,s=this.lastSn,o=this.unparsedVttFrags;if("main"===t.type){var c=t.sn;t.sn!==s+1&&i&&n&&(i.reset(),n.reset()),this.lastSn=c}else if("subtitle"===t.type)if(r.byteLength){if(!Object(l.isFiniteNumber)(a[t.cc]))return o.push(e),void(a.length&&this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t}));var d=t.decryptdata;null!=d&&null!=d.key&&"AES-128"===d.method||this._parseVTTs(t,r)}else this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})},n._parseVTTs=function(e,t){var r=this,i=this.hls,n=this.prevCC,a=this.textTracks,s=this.vttCCs;s[e.cc]||(s[e.cc]={start:e.start,prevCC:n,new:!0},this.prevCC=e.cc),Ft.parse(t,this.initPTS[e.cc],s,e.cc,(function(t){if(r.config.renderTextTracksNatively){var n=a[e.level];if("disabled"===n.mode)return void i.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e});t.forEach((function(e){if(!n.cues.getCueById(e.id))try{if(n.addCue(e),!n.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){c.logger.debug("Failed occurred on adding cues: "+r);var t=new window.TextTrackCue(e.startTime,e.endTime,e.text);t.id=e.id,n.addCue(t)}}))}else{var s=r.tracks[e.level].default?"default":"subtitles"+e.level;i.trigger(u.default.CUES_PARSED,{type:"subtitles",cues:t,track:s})}i.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){c.logger.log("Failed to parse VTT cue: "+t),i.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})}))},n.onFragDecrypted=function(e){var t=e.frag,r=e.payload;if("subtitle"===t.type){if(!Object(l.isFiniteNumber)(this.initPTS[t.cc]))return void this.unparsedVttFrags.push(e);this._parseVTTs(t,r)}},n.onFragParsingUserdata=function(e){var t=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&t&&r)for(var i=0;i<e.samples.length;i++){var n=e.samples[i].bytes;if(n){var a=this.extractCea608Data(n);t.addData(e.samples[i].pts,a[0]),r.addData(e.samples[i].pts,a[1])}}},n.extractCea608Data=function(e){for(var t=31&e[0],r=2,i=[[],[]],n=0;n<t;n++){var a=e[r++],s=127&e[r++],o=127&e[r++],l=3&a;0===s&&0===o||0!=(4&a)&&(0!==l&&1!==l||(i[l].push(s),i[l].push(o)))}return i},i}(h);function Gt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Kt(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}var Yt,Vt=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.MANIFEST_LOADED,u.default.SUBTITLE_TRACK_LOADED)||this).tracks=[],r.trackId=-1,r.media=null,r.stopped=!0,r.subtitleDisplay=!0,r.queuedDefaultTrack=null,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,o=i.prototype;return o.destroy=function(){h.prototype.destroy.call(this)},o.onMediaAttached=function(e){var t=this;this.media=e.media,this.media&&(Object(l.isFiniteNumber)(this.queuedDefaultTrack)&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=null),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval((function(){t.trackChangeListener()}),500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},o.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),Object(l.isFiniteNumber)(this.subtitleTrack)&&(this.queuedDefaultTrack=this.subtitleTrack),Kt(this.media.textTracks).forEach((function(e){Ue(e)})),this.subtitleTrack=-1,this.media=null)},o.onManifestLoaded=function(e){var t=this,r=e.subtitles||[];this.tracks=r,this.hls.trigger(u.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:r}),r.forEach((function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)}))},o.onSubtitleTrackLoaded=function(e){var t=this,r=e.id,i=e.details,n=this.trackId,a=this.tracks,s=a[n];if(r>=a.length||r!==n||!s||this.stopped)this._clearReloadTimer();else if(c.logger.log("subtitle track "+r+" loaded"),i.live){var o=ne(s.details,i,e.stats.trequest);c.logger.log("Reloading live subtitle playlist in "+o+"ms"),this.timer=setTimeout((function(){t._loadCurrentTrack()}),o)}else this._clearReloadTimer()},o.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},o.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},o._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},o._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(c.logger.log("Loading subtitle track "+e),r.trigger(u.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},o._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;if(t){var n=Kt(t.textTracks);if(-1===e)[].slice.call(n).forEach((function(e){e.mode="disabled"}));else{var a=n[i];a&&(a.mode="disabled")}var s=n[e];s&&(s.mode=r?"showing":"hidden")}},o._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(l.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,c.logger.log("Switching to subtitle track "+e),t.trigger(u.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},o._onTextTracksChanged=function(){if(this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=Kt(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}},n=i,(a=[{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.trackId!==e&&(this._toggleTrackModes(e),this._setSubtitleTrackInternal(e))}}])&&Gt(n.prototype,a),s&&Gt(n,s),i}(h),Ht=r("./src/crypt/decrypter.js"),Wt=window.performance,zt=function(e){var t,r;function i(t,r){var i;return(i=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.ERROR,u.default.KEY_LOADED,u.default.FRAG_LOADED,u.default.SUBTITLE_TRACKS_UPDATED,u.default.SUBTITLE_TRACK_SWITCH,u.default.SUBTITLE_TRACK_LOADED,u.default.SUBTITLE_FRAG_PROCESSED,u.default.LEVEL_UPDATED)||this).fragmentTracker=r,i.config=t.config,i.state=pe,i.tracks=[],i.tracksBuffered=[],i.currentTrackId=-1,i.decrypter=new Ht.default(t,t.config),i.lastAVStart=0,i._onMediaSeeking=i.onMediaSeeking.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i)),i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.startLoad=function(){this.stopLoad(),this.state=me;var e=this.tracks[this.currentTrackId];e&&e.details&&(this.setInterval(500),this.tick())},n.onSubtitleFragProcessed=function(e){var t=e.frag,r=e.success;if(this.fragPrevious=t,this.state=me,r){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var n,a=t.start,s=0;s<i.length;s++)if(a>=i[s].start&&a<=i[s].end){n=i[s];break}var o=t.start+t.duration;n?n.end=o:(n={start:a,end:o},i.push(n))}}},n.onMediaAttached=function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=me},n.onMediaDetaching=function(){var e=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach((function(t){e.tracksBuffered[t.id]=[]})),this.media=null,this.state=pe)},n.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.fragCurrent&&this.fragCurrent.loader&&this.fragCurrent.loader.abort(),this.state=me)},n.onSubtitleTracksUpdated=function(e){var t=this;c.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach((function(e){t.tracksBuffered[e.id]=[]}))},n.onSubtitleTrackSwitch=function(e){if(this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()},n.onSubtitleTrackLoaded=function(e){var t=e.id,r=e.details,i=this.currentTrackId,n=this.tracks,a=n[i];t>=n.length||t!==i||!a||(r.live&&function(e,t,r){void 0===r&&(r=0);var i=-1;ie(e,t,(function(e,t,r){t.start=e.start,i=r}));var n=t.fragments;if(i<0)n.forEach((function(e){e.start+=r}));else for(var a=i+1;a<n.length;a++)n[a].start=n[a-1].start+n[a-1].duration}(a.details,r,this.lastAVStart),a.details=r,this.setInterval(500))},n.onKeyLoaded=function(){this.state===ye&&(this.state=me)},n.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag.decryptdata,i=e.frag,n=this.hls;if(this.state===Ee&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&e.payload.byteLength>0&&r&&r.key&&"AES-128"===r.method){var a=Wt.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,(function(e){var t=Wt.now();n.trigger(u.default.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:a,tdecrypt:t}})}))}},n.onLevelUpdated=function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0},n.doTick=function(){if(this.media)switch(this.state){case me:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,n=this.tracks;if(!n||!n[t]||!n[t].details)break;var a,s=e.maxBufferHole,o=e.maxFragLookUpTolerance,l=Math.min(e.maxBufferLength,e.maxMaxBufferLength),d=Y.bufferedInfo(this._getBuffered(),i.currentTime,s),h=d.end,f=d.len,g=n[t].details,p=g.fragments,v=p.length,m=p[v-1].start+p[v-1].duration;if(f>l)return;var A=this.fragPrevious;h<m?(A&&g.hasProgramDateTime&&(a=le(p,A.endProgramDateTime,o)),a||(a=ue(A,p,h,o))):a=p[v-1],a&&a.encrypted?(c.logger.log("Loading key for "+a.sn),this.state=ye,this.hls.trigger(u.default.KEY_LOADING,{frag:a})):a&&r.getState(a)===F&&(this.fragCurrent=a,this.state=Ee,this.hls.trigger(u.default.FRAG_LOADING,{frag:a}))}else this.state=me},n.stopLoad=function(){this.lastAVStart=0,this.fragPrevious=null,e.prototype.stopLoad.call(this)},n._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},n.onMediaSeeking=function(){if(this.fragCurrent){var e=this.media?this.media.currentTime:0,t=this.config.maxFragLookUpTolerance,r=this.fragCurrent.start-t,i=this.fragCurrent.start+this.fragCurrent.duration+t;(e<r||e>i)&&(this.fragCurrent.loader&&this.fragCurrent.loader.abort(),this.fragmentTracker.removeFragment(this.fragCurrent),this.fragCurrent=null,this.fragPrevious=null,this.state=me,this.tick())}},i}(Oe);!function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(Yt||(Yt={}));var qt="undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null;function Xt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var $t=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHED,u.default.MANIFEST_PARSED)||this)._widevineLicenseUrl=void 0,r._licenseXhrSetup=void 0,r._emeEnabled=void 0,r._requestMediaKeySystemAccess=void 0,r._drmSystemOptions=void 0,r._config=void 0,r._mediaKeysList=[],r._media=null,r._hasSetMediaKeys=!1,r._requestLicenseFailureCount=0,r.mediaKeysPromise=null,r._onMediaEncrypted=function(e){if(c.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),!r.mediaKeysPromise)return c.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void r.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var t=function(t){r._media&&(r._attemptSetMediaKeys(t),r._generateRequestWithPreferredKeySession(e.initDataType,e.initData))};r.mediaKeysPromise.then(t).catch(t)},r._config=t.config,r._widevineLicenseUrl=r._config.widevineLicenseUrl,r._licenseXhrSetup=r._config.licenseXhrSetup,r._emeEnabled=r._config.emeEnabled,r._requestMediaKeySystemAccess=r._config.requestMediaKeySystemAccessFunc,r._drmSystemOptions=t.config.drmSystemOptions,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n,a,s,l=i.prototype;return l.getLicenseServerUrl=function(e){switch(e){case Yt.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},l._attemptKeySystemAccess=function(e,t,r){var i=this,n=function(e,t,r,i){switch(e){case Yt.WIDEVINE:return function(e,t,r){var i={audioCapabilities:[],videoCapabilities:[]};return e.forEach((function(e){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||""})})),t.forEach((function(e){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||""})})),[i]}(t,r,i);default:throw new Error("Unknown key-system: "+e)}}(e,t,r,this._drmSystemOptions);c.logger.log("Requesting encrypted media key-system access");var a=this.requestMediaKeySystemAccess(e,n);this.mediaKeysPromise=a.then((function(t){return i._onMediaKeySystemAccessObtained(e,t)})),a.catch((function(t){c.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))},l._onMediaKeySystemAccessObtained=function(e,t){var r=this;c.logger.log('Access for key-system "'+e+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(i);var n=Promise.resolve().then((function(){return t.createMediaKeys()})).then((function(t){return i.mediaKeys=t,c.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated(),t}));return n.catch((function(e){c.logger.error("Failed to create media-keys:",e)})),n},l._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},l._onNewMediaKeySession=function(e){var t=this;c.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},l._onKeySessionMessage=function(e,t){c.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){c.logger.log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t)}))},l._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return c.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});c.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},l._generateRequestWithPreferredKeySession=function(e,t){var r=this,i=this._mediaKeysList[0];if(!i)return c.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(i.mediaKeysSessionInitialized)c.logger.warn("Key-Session already initialized but requested again");else{var n=i.mediaKeysSession;if(!n)return c.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return c.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});c.logger.log('Generating key-session request for "'+e+'" init data type'),i.mediaKeysSessionInitialized=!0,n.generateRequest(e,t).then((function(){c.logger.debug("Key-session generation succeeded")})).catch((function(e){c.logger.error("Error generating key-session request:",e),r.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},l._createLicenseXhr=function(e,t,r){var i=new XMLHttpRequest,n=this._licenseXhrSetup;try{if(n)try{n(i,e)}catch(t){i.open("POST",e,!0),n(i,e)}i.readyState||i.open("POST",e,!0)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,e,t,r),i},l._onLicenseRequestReadyStageChange=function(e,t,r,i){switch(e.readyState){case 4:if(200===e.status)this._requestLicenseFailureCount=0,c.logger.log("License request succeeded"),"arraybuffer"!==e.responseType&&c.logger.warn("xhr response type was not set to the expected arraybuffer for license request"),i(e.response);else{if(c.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var n=3-this._requestLicenseFailureCount+1;c.logger.warn("Retrying license request, "+n+" attempts left"),this._requestLicense(r,i)}}},l._generateLicenseRequestChallenge=function(e,t){switch(e.mediaKeySystemDomain){case Yt.WIDEVINE:return t}throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},l._requestLicense=function(e,t){c.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return c.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),n=this._createLicenseXhr(i,e,t);c.logger.log("Sending license request to URL: "+i);var a=this._generateLicenseRequestChallenge(r,e);n.send(a)}catch(e){c.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(u.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},l.onMediaAttached=function(e){if(this._emeEnabled){var t=e.media;this._media=t,t.addEventListener("encrypted",this._onMediaEncrypted)}},l.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},l.onManifestParsed=function(e){if(this._emeEnabled){var t=e.levels.map((function(e){return e.audioCodec})),r=e.levels.map((function(e){return e.videoCodec}));this._attemptKeySystemAccess(Yt.WIDEVINE,t,r)}},n=i,(a=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&Xt(n.prototype,a),s&&Xt(n,s),i}(h);function Zt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function Qt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Zt(Object(r),!0).forEach((function(t){Jt(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Jt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var er=Qt(Qt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ze,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:Ve,bufferController:We,capLevelController:qe,fpsController:$e,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:qt,testBandwidth:!0},{cueHandler:i,enableCEA708Captions:!0,enableWebVTT:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:zt,subtitleTrackController:Vt,timelineController:jt,audioStreamController:rt,audioTrackController:Je,emeController:$t});function tr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function rr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(r),!0).forEach((function(t){ir(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ir(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ar(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function sr(e,t,r){return t&&ar(e.prototype,t),r&&ar(e,r),e}var or=function(e){var t,r;function i(t){var r;void 0===t&&(t={}),(r=e.call(this)||this).config=void 0,r._autoLevelCapping=void 0,r.abrController=void 0,r.capLevelController=void 0,r.levelController=void 0,r.streamController=void 0,r.networkControllers=void 0,r.audioTrackController=void 0,r.subtitleTrackController=void 0,r.emeController=void 0,r.coreComponents=void 0,r.media=null,r.url=null;var n=i.DefaultConfig;if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");r.config=rr(rr({},n),t);var a=nr(r).config;if(void 0!==a.liveMaxLatencyDurationCount&&a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==a.liveMaxLatencyDuration&&(void 0===a.liveSyncDuration||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(c.enableLogs)(a.debug),r._autoLevelCapping=-1;var s=r.abrController=new a.abrController(nr(r)),o=new a.bufferController(nr(r)),l=r.capLevelController=new a.capLevelController(nr(r)),u=new a.fpsController(nr(r)),d=new x(nr(r)),h=new N(nr(r)),f=new M(nr(r)),g=new Be(nr(r)),p=r.levelController=new Ne(nr(r)),v=new G(nr(r)),m=[p,r.streamController=new Pe(nr(r),v)],A=a.audioStreamController;A&&m.push(new A(nr(r),v)),r.networkControllers=m;var y=[d,h,f,s,o,l,u,g,v];if(A=a.audioTrackController){var E=new A(nr(r));r.audioTrackController=E,y.push(E)}if(A=a.subtitleTrackController){var _=new A(nr(r));r.subtitleTrackController=_,m.push(_)}if(A=a.emeController){var T=new A(nr(r));r.emeController=T,y.push(T)}return(A=a.subtitleStreamController)&&m.push(new A(nr(r),v)),(A=a.timelineController)&&y.push(new A(nr(r))),r.coreComponents=y,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i.isSupported=function(){return function(){var e=z();if(!e)return!1;var t=self.SourceBuffer||self.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!i}()},sr(i,null,[{key:"version",get:function(){return"0.14.17"}},{key:"Events",get:function(){return u.default}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return i.defaultConfig?i.defaultConfig:er},set:function(e){i.defaultConfig=e}}]);var n=i.prototype;return n.destroy=function(){c.logger.log("destroy"),this.trigger(u.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach((function(e){e.destroy()})),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},n.attachMedia=function(e){c.logger.log("attachMedia"),this.media=e,this.trigger(u.default.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){c.logger.log("detachMedia"),this.trigger(u.default.MEDIA_DETACHING),this.media=null},n.loadSource=function(e){e=s.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),c.logger.log("loadSource:"+e),this.url=e,this.trigger(u.default.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){void 0===e&&(e=-1),c.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},n.stopLoad=function(){c.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},n.swapAudioCodec=function(){c.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){c.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},sr(i,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){c.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){c.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){c.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){c.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){c.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){c.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"bandwidthEstimate",get:function(){var e=this.abrController._bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,r=e?e.length:0,i=0;i<r;i++)if((e[i].realBitrate?Math.max(e[i].realBitrate,e[i].bitrate):e[i].bitrate)>t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),i}(X);or.defaultConfig=void 0},"./src/polyfills/number.js":
|
|
159
|
+
!*** ./src/loader/level-key.ts ***!
|
|
160
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{LevelKey:()=>a});var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e,t){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=t?(0,i.buildAbsoluteURL)(e,t,{alwaysNormalize:!0}):e}var t,r,a;return e.fromURL=function(t,r){return new e(t,r)},e.fromURI=function(t){return new e(t)},t=e,(r=[{key:"uri",get:function(){return this._uri}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/load-stats.ts":
|
|
161
|
+
/*!**********************************!*\
|
|
162
|
+
!*** ./src/loader/load-stats.ts ***!
|
|
163
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{LoadStats:()=>i});var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
|
|
164
|
+
/*!***********************************!*\
|
|
165
|
+
!*** ./src/loader/m3u8-parser.ts ***!
|
|
166
|
+
\***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ./date-range */"./src/loader/date-range.ts"),s=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),l=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),v=/\.(mp4|m4s|m4v|m4a)$/i,m=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e},e.resolve=function(e,t){return n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,n=[],a=[],s={},o=!1;for(h.lastIndex=0;null!=(i=h.exec(t));)if(i[1]){var l,c=new u.AttrList(i[1]),d={attrs:c,bitrate:c.decimalInteger("AVERAGE-BANDWIDTH")||c.decimalInteger("BANDWIDTH"),name:c.NAME,url:e.resolve(i[2],r)},f=c.decimalResolution("RESOLUTION");f&&(d.width=f.width,d.height=f.height),y((c.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),d),d.videoCodec&&-1!==d.videoCodec.indexOf("avc1")&&(d.videoCodec=e.convertAVC1ToAVCOTI(d.videoCodec)),null!==(l=d.unknownCodecs)&&void 0!==l&&l.length||a.push(d),n.push(d)}else if(i[3]){var g=new u.AttrList(i[3]);g["DATA-ID"]&&(o=!0,s[g["DATA-ID"]]=g)}return{levels:a.length>0&&a.length<n.length?a:n,sessionData:o?s:null}},e.parseMasterPlaylistMedia=function(t,r,i,n){var a;void 0===n&&(n=[]);var s=[],o=0;for(f.lastIndex=0;null!==(a=f.exec(t));){var l=new u.AttrList(a[1]);if(l.TYPE===i){var c={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE||"",type:i,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:l.LANGUAGE,url:l.URI?e.resolve(l.URI,r):""};if(n.length){var d=e.findGroup(n,c.groupId)||n[0];A(c,d,"audioCodec"),A(c,d,"textCodec")}s.push(c)}}return s},e.parseLevelPlaylist=function(e,t,r,d,h){var f,m,y,A=new o.LevelDetails(t),b=A.fragments,S=null,_=0,k=0,L=0,D=0,R=null,C=new s.Fragment(d,t),I=-1,O=!1;for(g.lastIndex=0,A.m3u8=e;null!==(f=g.exec(e));){O&&(O=!1,(C=new s.Fragment(d,t)).start=L,C.sn=_,C.cc=D,C.level=r,S&&(C.initSegment=S,C.rawProgramDateTime=S.rawProgramDateTime,S.rawProgramDateTime=null));var w=f[1];if(w){C.duration=parseFloat(w);var P=(" "+f[2]).slice(1);C.title=P||null,C.tagList.push(P?["INF",w,P]:["INF",w])}else if(f[3])(0,i.isFiniteNumber)(C.duration)&&(C.start=L,y&&(C.levelkey=y),C.sn=_,C.level=r,C.cc=D,C.urlId=h,b.push(C),C.relurl=(" "+f[3]).slice(1),E(C,R),R=C,L+=C.duration,_++,k=0,O=!0);else if(f[4]){var x=(" "+f[4]).slice(1);R?C.setByteRange(x,R):C.setByteRange(x)}else if(f[5])C.rawProgramDateTime=(" "+f[5]).slice(1),C.tagList.push(["PROGRAM-DATE-TIME",C.rawProgramDateTime]),-1===I&&(I=b.length);else{if(!(f=f[0].match(p))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m<f.length&&void 0===f[m];m++);var N=(" "+f[m]).slice(1),F=(" "+f[m+1]).slice(1),M=f[m+2]?(" "+f[m+2]).slice(1):"";switch(N){case"PLAYLIST-TYPE":A.type=F.toUpperCase();break;case"MEDIA-SEQUENCE":_=A.startSN=parseInt(F);break;case"SKIP":var U=new u.AttrList(F),B=U.decimalInteger("SKIPPED-SEGMENTS");if((0,i.isFiniteNumber)(B)){A.skippedSegments=B;for(var G=B;G--;)b.unshift(null);_+=B}var j=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");j&&(A.recentlyRemovedDateranges=j.split("\t"));break;case"TARGETDURATION":A.targetduration=parseFloat(F);break;case"VERSION":A.version=parseInt(F);break;case"EXTM3U":break;case"ENDLIST":A.live=!1;break;case"#":(F||M)&&C.tagList.push(M?[F,M]:[F]);break;case"DISCONTINUITY":D++,C.tagList.push(["DIS"]);break;case"GAP":C.tagList.push([N]);break;case"BITRATE":C.tagList.push([N,F]);break;case"DATERANGE":var K=new u.AttrList(F),H=new a.DateRange(K,A.dateRanges[K.ID]);H.isValid||A.skippedSegments?A.dateRanges[H.id]=H:c.logger.warn('Ignoring invalid DATERANGE tag: "'+F+'"'),C.tagList.push(["EXT-X-DATERANGE",F]);break;case"DISCONTINUITY-SEQUENCE":D=parseInt(F);break;case"KEY":var V,Y=new u.AttrList(F),W=Y.enumeratedString("METHOD"),z=Y.URI,q=Y.hexadecimalInteger("IV"),X=Y.enumeratedString("KEYFORMATVERSIONS"),$=Y.enumeratedString("KEYID"),Z=null!=(V=Y.enumeratedString("KEYFORMAT"))?V:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(Z)>-1){c.logger.warn("Keyformat "+Z+" is not supported from the manifest");continue}if("identity"!==Z)continue;W&&(y=l.LevelKey.fromURL(t,z),z&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(W)>=0&&(y.method=W,y.keyFormat=Z,$&&(y.keyID=$),X&&(y.keyFormatVersions=X),y.iv=q));break;case"START":var Q=new u.AttrList(F).decimalFloatingPoint("TIME-OFFSET");(0,i.isFiniteNumber)(Q)&&(A.startTimeOffset=Q);break;case"MAP":var J=new u.AttrList(F);if(C.duration){var ee=new s.Fragment(d,t);T(ee,J,r,y),S=ee,C.initSegment=S,S.rawProgramDateTime&&!C.rawProgramDateTime&&(C.rawProgramDateTime=S.rawProgramDateTime)}else T(C,J,r,y),S=C,O=!0;break;case"SERVER-CONTROL":var te=new u.AttrList(F);A.canBlockReload=te.bool("CAN-BLOCK-RELOAD"),A.canSkipUntil=te.optionalFloat("CAN-SKIP-UNTIL",0),A.canSkipDateRanges=A.canSkipUntil>0&&te.bool("CAN-SKIP-DATERANGES"),A.partHoldBack=te.optionalFloat("PART-HOLD-BACK",0),A.holdBack=te.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var re=new u.AttrList(F);A.partTarget=re.decimalFloatingPoint("PART-TARGET");break;case"PART":var ie=A.partList;ie||(ie=A.partList=[]);var ne=k>0?ie[ie.length-1]:void 0,ae=k++,se=new s.Part(new u.AttrList(F),C,t,ae,ne);ie.push(se),C.duration+=se.duration;break;case"PRELOAD-HINT":var oe=new u.AttrList(F);A.preloadHint=oe;break;case"RENDITION-REPORT":var le=new u.AttrList(F);A.renditionReports=A.renditionReports||[],A.renditionReports.push(le);break;default:c.logger.warn("line parsed but not handled: "+f)}}}R&&!R.relurl?(b.pop(),L-=R.duration,A.partList&&(A.fragmentHint=R)):A.partList&&(E(C,R),C.cc=D,A.fragmentHint=C);var ue=b.length,ce=b[0],de=b[ue-1];if((L+=A.skippedSegments*A.targetduration)>0&&ue&&de){A.averagetargetduration=L/ue;var he=de.sn;A.endSN="initSegment"!==he?he:0,ce&&(A.startCC=ce.cc,ce.initSegment||A.fragments.every((function(e){return e.relurl&&(t=e.relurl,v.test(null!=(r=null===(i=n.parseURL(t))||void 0===i?void 0:i.path)?r:""));var t,r,i}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(C=new s.Fragment(d,t)).relurl=de.relurl,C.level=r,C.sn="initSegment",ce.initSegment=C,A.needSidxRanges=!0))}else A.endSN=0,A.startCC=0;return A.fragmentHint&&(L+=A.fragmentHint.duration),A.totalduration=L,A.endCC=D,I>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(b,I),A},e}();function y(e,t){["video","audio","text"].forEach((function(r){var i=e.filter((function(e){return(0,d.isCodecType)(e,r)}));if(i.length){var n=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}function A(e,t,r){var i=t[r];i&&(e[r]=i)}function E(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),(0,i.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function T(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkey=i),e.initSegment=null}},"./src/loader/playlist-loader.ts":
|
|
167
|
+
/*!***************************************!*\
|
|
168
|
+
!*** ./src/loader/playlist-loader.ts ***!
|
|
169
|
+
\***************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function d(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var h=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return e.loader=n,this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:u.PlaylistContextType.LEVEL,url:n,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n,a,o,l=this.hls.config,c=this.getInternalLoader(e);if(c){var d=c.context;if(d&&d.url===e.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),c.abort()}switch(e.type){case u.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,i=l.manifestLoadingTimeOut,n=l.manifestLoadingRetryDelay,a=l.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:r=0,i=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,i=l.levelLoadingTimeOut,n=l.levelLoadingRetryDelay,a=l.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(e),null!==(t=e.deliveryDirectives)&&void 0!==t&&t.part&&(e.type===u.PlaylistContextType.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===u.PlaylistContextType.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o)){var h=o.partTarget,f=o.targetduration;h&&f&&(i=Math.min(1e3*Math.max(3*h,.8*f),i))}var g={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:a,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(e,g,p)},t.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this.handleSidxRequest(e,r),void this.handlePlaylistLoaded(e,t,r,i);this.resetInternalLoader(r.type);var n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,r,i):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},t.loaderror=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!1,e)},t.loadtimeout=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!0)},t.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,u=d(e,r),h=l.default.parseMasterPlaylist(o,u),f=h.levels,g=h.sessionData;if(f.length){var p=f.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),v=f.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",p),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",v),A=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.some((function(e){return!e.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),a.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:m,subtitles:y,captions:A,url:u,stats:t,networkDetails:i,sessionData:g})}else this.handleManifestParsingError(e,r,"no level found in manifest",i)},t.handleTrackOrLevelPlaylist=function(e,t,r,s){var o=this.hls,h=r.id,f=r.level,g=r.type,p=d(e,r),v=(0,i.isFiniteNumber)(h)?h:0,m=(0,i.isFiniteNumber)(f)?f:v,y=function(e){switch(e.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(r),A=l.default.parseLevelPlaylist(e.data,p,m,y,v);if(A.fragments.length){if(g===u.PlaylistContextType.MANIFEST){var E={attrs:new c.AttrList({}),bitrate:0,details:A,name:"",url:p};o.trigger(n.Events.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:p,stats:t,networkDetails:s,sessionData:null})}if(t.parsing.end=performance.now(),A.needSidxRanges){var T,b=null===(T=A.fragments[0].initSegment)||void 0===T?void 0:T.url;this.load({url:b,isSidxRequest:!0,type:g,level:f,levelDetails:A,id:h,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=A,this.handlePlaylistLoaded(e,t,r,s)}else o.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},t.handleSidxRequest=function(e,t){var r=new Uint8Array(e.data),i=(0,o.findBox)(r,["sidx"])[0];if(i){var n=(0,o.parseSegmentIndex)(i);if(n){var a=n.references,s=t.levelDetails;a.forEach((function(e,t){var i=e.info,n=s.fragments[t];if(0===n.byteRange.length&&n.setByteRange(String(1+i.end-i.start)+"@"+String(i.start)),n.initSegment){var a=(0,o.findBox)(r,["moov"])[0],l=a?a.length:null;n.initSegment.setByteRange(String(l)+"@0")}}))}}},t.handleManifestParsingError=function(e,t,r,i){this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===u.PlaylistContextType.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:i})},t.handleNetworkError=function(e,t,r,i){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,l=!1,c=this.getInternalLoader(e);switch(e.type){case u.PlaylistContextType.MANIFEST:o=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case u.PlaylistContextType.LEVEL:o=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=r?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);var d={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(n.Events.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,i){var a=r.type,s=r.level,o=r.id,l=r.groupId,c=r.loader,d=r.levelDetails,h=r.deliveryDirectives;if(null!=d&&d.targetduration){if(c)switch(d.live&&(c.getCacheAge&&(d.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(d.ageHeader)||(d.ageHeader=0)),a){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:d,level:s||0,id:o||0,stats:t,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:i,deliveryDirectives:h})}}else this.handleManifestParsingError(e,r,"invalid target duration",i)},e}();const f=h},"./src/polyfills/number.ts":
|
|
170
|
+
/*!*********************************!*\
|
|
171
|
+
!*** ./src/polyfills/number.ts ***!
|
|
172
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{MAX_SAFE_INTEGER:()=>n,isFiniteNumber:()=>i});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
173
|
+
/*!*********************************!*\
|
|
174
|
+
!*** ./src/remux/aac-helper.ts ***!
|
|
175
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}()},"./src/remux/mp4-generator.ts":
|
|
176
|
+
/*!************************************!*\
|
|
177
|
+
!*** ./src/remux/mp4-generator.ts ***!
|
|
178
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=Math.pow(2,32)-1,n=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,n=t.duration*t.timescale,a=t.width,s=t.height,o=Math.floor(n/(i+1)),l=Math.floor(n%(i+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var n=e.sdtp(t),a=t.id,s=Math.floor(r/(i+1)),o=Math.floor(r%(i+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,a,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,h=new Uint8Array(d);for(r+=8+d,h.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)a=(n=u[i]).duration,s=n.size,o=n.flags,l=n.cts,h.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,h)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),i=new Uint8Array(e.FTYP.byteLength+r.byteLength);return i.set(e.FTYP),i.set(r,e.FTYP.byteLength),i},e}();n.types=void 0,n.HDLR_TYPES=void 0,n.STTS=void 0,n.STSC=void 0,n.STCO=void 0,n.STSZ=void 0,n.VMHD=void 0,n.SMHD=void 0,n.STSD=void 0,n.FTYP=void 0,n.DINF=void 0;const a=n},"./src/remux/mp4-remuxer.ts":
|
|
179
|
+
/*!**********************************!*\
|
|
180
|
+
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
181
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>g,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>m,normalizePts:()=>p});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),a=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}var h=null,f=null,g=function(){function e(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===h){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=n?parseInt(n[1]):0}if(null===f){var a=navigator.userAgent.match(/Safari\/(\d+)/i);f=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,p(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var c,d,h,f,g,y,A=n,E=n,T=e.pid>-1,b=t.pid>-1,S=t.samples.length,_=e.samples.length>0,k=s&&S>0||S>1;if((!T||_)&&(!b||k)||this.ISGenerated||s){this.ISGenerated||(h=this.generateIS(e,t,n));var L,D=this.isVideoContiguous,R=-1;if(k&&(R=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,R>0){l.logger.warn("[mp4-remuxer]: Dropped "+R+" out of "+S+" video samples due to a missing keyframe");var C=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(R),t.dropped+=R,L=E+=(t.samples[0].pts-C)/t.inputTimeScale}else-1===R&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),y=!1);if(this.ISGenerated){if(_&&k){var I=this.getVideoStartPts(t.samples),O=(p(e.samples[0].pts,I)-I)/t.inputTimeScale;A+=Math.max(0,O),E+=Math.max(0,-O)}if(_){if(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n)),d=this.remuxAudio(e,A,this.isAudioContiguous,a,b||k||o===u.PlaylistLevelType.AUDIO?E:void 0),k){var w=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,n)),c=this.remuxVideo(t,E,D,w)}}else k&&(c=this.remuxVideo(t,E,D,0));c&&(c.firstKeyFrame=R,c.independent=-1!==R,c.firstKeyFramePTS=L)}}return this.ISGenerated&&(r.samples.length&&(g=v(r,n,this._initPTS,this._initDTS)),i.samples.length&&(f=m(i,n,this._initPTS))),{audio:d,video:c,initSegment:h,independent:y,text:f,id3:g}},t.generateIS=function(e,t,r){var n,s,o,l=e.samples,u=t.samples,c=this.typeSupported,d={},h=!(0,i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(h&&(n=s=1/0),e.config&&l.length&&(e.timescale=e.samplerate,"mp3"===e.segmentCodec&&(c.mpeg?(f="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&c.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(o=e.inputTimeScale,n=s=l[0].pts-Math.round(o*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},h)){o=t.inputTimeScale;var g=this.getVideoStartPts(u),v=Math.round(o*r);s=Math.min(s,p(u[0].dts,g)-v),n=Math.min(n,g-v)}if(Object.keys(d).length)return this.ISGenerated=!0,h&&(this._initPTS=n,this._initDTS=s),{tracks:d,initPTS:n,timescale:o}},t.remuxVideo=function(e,t,r,i){var n,u,g=e.inputTimeScale,v=e.samples,m=[],A=v.length,E=this._initPTS,T=this.nextAvcDts,b=8,S=this.videoSampleDuration,_=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY,L=!1;r&&null!==T||(T=t*g-(v[0].pts-p(v[0].dts,v[0].pts)));for(var D=0;D<A;D++){var R=v[D];R.pts=p(R.pts-E,T),R.dts=p(R.dts-E,T),R.dts<v[D>0?D-1:D].dts&&(L=!0)}L&&v.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=v[0].dts;var C=(u=v[v.length-1].dts)-n,I=C?Math.round(C/(A-1)):S||e.inputTimeScale/30;if(r){var O=n-T,w=O>I,P=O<-1;if((w||P)&&(w?l.logger.warn("AVC: "+(0,c.toMsFromMpegTsClock)(O,!0)+" ms ("+O+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+(0,c.toMsFromMpegTsClock)(-O,!0)+" ms ("+O+"dts) overlapping between fragments detected"),!P||T>v[0].pts)){n=T;var x=v[0].pts-O;v[0].dts=n,v[0].pts=x,l.logger.log("Video: First PTS/DTS adjusted: "+(0,c.toMsFromMpegTsClock)(x,!0)+"/"+(0,c.toMsFromMpegTsClock)(n,!0)+", delta: "+(0,c.toMsFromMpegTsClock)(O,!0)+" ms")}}n=Math.max(0,n);for(var N=0,F=0,M=0;M<A;M++){for(var U=v[M],B=U.units,G=B.length,j=0,K=0;K<G;K++)j+=B[K].data.length;F+=j,N+=G,U.length=j,U.dts=Math.max(U.dts,n),_=Math.min(U.pts,_),k=Math.max(U.pts,k)}u=v[A-1].dts;var H,V=F+4*N+8;try{H=new Uint8Array(V)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:V,reason:"fail allocating video mdat "+V})}var Y=new DataView(H.buffer);Y.setUint32(0,V),H.set(a.default.types.mdat,4);for(var W=!1,z=Number.POSITIVE_INFINITY,q=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,$=Number.NEGATIVE_INFINITY,Z=0;Z<A;Z++){for(var Q=v[Z],J=Q.units,ee=0,te=0,re=J.length;te<re;te++){var ie=J[te],ne=ie.data,ae=ie.data.byteLength;Y.setUint32(b,ae),b+=4,H.set(ne,b),b+=ae,ee+=4+ae}var se=void 0;if(Z<A-1)S=v[Z+1].dts-Q.dts,se=v[Z+1].pts-Q.pts;else{var oe=this.config,le=Z>0?Q.dts-v[Z-1].dts:I;if(se=Z>0?Q.pts-v[Z-1].pts:I,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ue=Math.floor(oe.maxBufferHole*g),ce=(i?_+i*g:this.nextAudioPts)-Q.pts;ce>ue?((S=ce-le)<0?S=le:W=!0,l.logger.log("[mp4-remuxer]: It is approximately "+ce/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=le}else S=le}var de=Math.round(Q.pts-Q.dts);z=Math.min(z,S),X=Math.max(X,S),q=Math.min(q,se),$=Math.max($,se),m.push(new y(Q.key,S,ee,de))}if(m.length)if(h){if(h<70){var he=m[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(f&&$-q<X-z&&I/X<.025&&0===m[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,ge=0,pe=m.length;ge<pe;ge++){var ve=fe+m[ge].duration,me=fe+m[ge].cts;if(ge<pe-1){var ye=ve+m[ge+1].cts;m[ge].duration=ye-me}else m[ge].duration=ge?m[ge-1].duration:I;m[ge].cts=0,fe=ve}}console.assert(null!==S,"mp4SampleDuration must be computed"),S=W||!S?I:S,this.nextAvcDts=T=u+S,this.videoSampleDuration=S,this.isVideoContiguous=!0;var Ae={data1:a.default.moof(e.sequenceNumber++,n,d({},e,{samples:m})),data2:H,startPTS:_/g,endPTS:(k+S)/g,startDTS:n/g,endDTS:T/g,type:"video",hasAudio:!1,hasVideo:!0,nb:m.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(H.length,"MDAT length must not be zero"),Ae},t.remuxAudio=function(e,t,r,i,u){var c=e.inputTimeScale,h=c/(e.samplerate?e.samplerate:c),f="aac"===e.segmentCodec?1024:1152,g=f*h,v=this._initPTS,m="mp3"===e.segmentCodec&&this.typeSupported.mpeg,A=[],E=void 0!==u,T=e.samples,b=m?0:8,S=this.nextAudioPts||-1,_=t*c;if(this.isAudioContiguous=r=r||T.length&&S>0&&(i&&Math.abs(_-S)<9e3||Math.abs(p(T[0].pts-v,_)-S)<20*g),T.forEach((function(e){e.pts=p(e.pts-v,_)})),!r||S<0){if(T=T.filter((function(e){return e.pts>=0})),!T.length)return;S=0===u?0:i&&!E?Math.max(0,_):T[0].pts}if("aac"===e.segmentCodec)for(var k=this.config.maxAudioFramesDrift,L=0,D=S;L<T.length;L++){var R=T[L],C=R.pts,I=C-D,O=Math.abs(1e3*I/c);if(I<=-k*g&&E)0===L&&(l.logger.warn("Audio frame @ "+(C/c).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*I/c)+" ms."),this.nextAudioPts=S=D=C);else if(I>=k*g&&O<1e4&&E){var w=Math.round(I/g);(D=C-w*g)<0&&(w--,D+=g),0===L&&(this.nextAudioPts=S=D),l.logger.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(D/c).toFixed(3)+"s due to "+Math.round(1e3*I/c)+" ms gap.");for(var P=0;P<w;P++){var x=Math.max(D,0),N=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);N||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),N=R.unit.subarray()),T.splice(L,0,{unit:N,pts:x}),D+=g,L++}}R.pts=D,D+=g}for(var F,M=null,U=null,B=0,G=T.length;G--;)B+=T[G].unit.byteLength;for(var j=0,K=T.length;j<K;j++){var H=T[j],V=H.unit,Y=H.pts;if(null!==U)A[j-1].duration=Math.round((Y-U)/h);else{if(r&&"aac"===e.segmentCodec&&(Y=S),M=Y,!(B>0))return;B+=b;try{F=new Uint8Array(B)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}m||(new DataView(F.buffer).setUint32(0,B),F.set(a.default.types.mdat,4))}F.set(V,b);var W=V.byteLength;b+=W,A.push(new y(!0,f,W,0)),U=Y}var z=A.length;if(z){var q=A[A.length-1];this.nextAudioPts=S=U+h*q.duration;var X=m?new Uint8Array(0):a.default.moof(e.sequenceNumber++,M/h,d({},e,{samples:A}));e.samples=[];var $=M/c,Z=S/c,Q={data1:X,data2:F,startPTS:$,endPTS:Z,startDTS:$,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,console.assert(F.length,"MDAT length must not be zero"),Q}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,u=(null!==o?o:i.startDTS*a)+this._initDTS,c=i.endDTS*a+this._initDTS,d=1024*s,h=Math.ceil((c-u)/d),f=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var g=[],p=0;p<h;p++){var v=u+p*d;g.push({unit:f,pts:v,dts:v})}return e.samples=g,this.remuxAudio(e,t,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function p(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function v(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=p(o.pts-r,t*a)/a,o.dts=p(o.dts-i,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function m(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=p(s.pts-r,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var y=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new A(e)},A=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
182
|
+
/*!******************************************!*\
|
|
183
|
+
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
184
|
+
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts");function l(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}const u=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=(0,a.parseInitSegment)(e);t||(t=l(i.audio,s.ElementaryStreamTypes.AUDIO)),r||(r=l(i.video,s.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,s,l){var u,c=this.initPTS,d=this.lastEndTime,h={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};(0,i.isFiniteNumber)(d)||(d=this.lastEndTime=l||0);var f=t.samples;if(!f||!f.length)return h;var g={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(f),p=this.initData),!p||!p.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var v=(0,a.getStartDTS)(p,f);(0,i.isFiniteNumber)(c)||(this.initPTS=g.initPTS=c=v-l);var m=(0,a.getDuration)(f,p),y=e?v-c:d,A=y+m;(0,a.offsetStartDTS)(p,f,c),m>0?this.lastEndTime=A:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!p.audio,T=!!p.video,b="";E&&(b+="audio"),T&&(b+="video");var S={data1:f,startPTS:y,startDTS:y,endPTS:A,endDTS:A,type:b,hasAudio:E,hasVideo:T,nb:1,dropped:0};h.audio="audio"===S.type?S:void 0,h.video="audio"!==S.type?S:void 0,h.initSegment=g;var _=null!=(u=this.initPTS)?u:0;return h.id3=(0,n.flushTextTrackMetadataCueSamples)(r,l,_,_),s.samples.length&&(h.text=(0,n.flushTextTrackUserdataCueSamples)(s,l,_)),h},e}()},"./src/task-loop.ts":
|
|
185
|
+
/*!**************************!*\
|
|
186
|
+
!*** ./src/task-loop.ts ***!
|
|
187
|
+
\**************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}()},"./src/types/cmcd.ts":
|
|
188
|
+
/*!***************************!*\
|
|
189
|
+
!*** ./src/types/cmcd.ts ***!
|
|
190
|
+
\***************************/(e,t,r)=>{r.r(t),r.d(t,{CMCDObjectType:()=>i,CMCDStreamType:()=>a,CMCDStreamingFormat:()=>n,CMCDVersion:()=>s});var i,n,a,s=1;!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(i||(i={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(n||(n={})),function(e){e.VOD="v",e.LIVE="l"}(a||(a={}))},"./src/types/demuxer.ts":
|
|
191
|
+
/*!******************************!*\
|
|
192
|
+
!*** ./src/types/demuxer.ts ***!
|
|
193
|
+
\******************************/(e,t,r)=>{var i;r.r(t),r.d(t,{MetadataSchema:()=>i}),function(e){e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3"}(i||(i={}))},"./src/types/level.ts":
|
|
194
|
+
/*!****************************!*\
|
|
195
|
+
!*** ./src/types/level.ts ***!
|
|
196
|
+
\****************************/(e,t,r)=>{function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var n;function a(e,t){var r=e.canSkipUntil,i=e.canSkipDateRanges,a=e.endSN;return r&&(void 0!==t?t-a:0)<r?i?n.v2:n.Yes:n.No}r.r(t),r.d(t,{HlsSkip:()=>n,HlsUrlParameters:()=>s,Level:()=>o,getSkipValue:()=>a}),function(e){e.No="",e.Yes="YES",e.v2="v2"}(n||(n={}));var s=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.toString()},e}(),o=function(){function e(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this.attrs=e.attrs,this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}var t,r,n;return t=e,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.details=void 0,this._urlId=t)}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/types/loader.ts":
|
|
197
|
+
/*!*****************************!*\
|
|
198
|
+
!*** ./src/types/loader.ts ***!
|
|
199
|
+
\*****************************/(e,t,r)=>{var i,n;r.r(t),r.d(t,{PlaylistContextType:()=>i,PlaylistLevelType:()=>n}),function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(i||(i={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(n||(n={}))},"./src/types/transmuxer.ts":
|
|
73
200
|
/*!*********************************!*\
|
|
74
|
-
!*** ./src/
|
|
75
|
-
\*********************************/
|
|
76
|
-
|
|
201
|
+
!*** ./src/types/transmuxer.ts ***!
|
|
202
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{ChunkMetadata:()=>i});var i=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a}},"./src/utils/attr-list.ts":
|
|
203
|
+
/*!********************************!*\
|
|
204
|
+
!*** ./src/utils/attr-list.ts ***!
|
|
205
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{AttrList:()=>a});var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=i.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(n.lastIndex=0;null!==(t=n.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}()},"./src/utils/binary-search.ts":
|
|
206
|
+
/*!************************************!*\
|
|
207
|
+
!*** ./src/utils/binary-search.ts ***!
|
|
208
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={search:function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
209
|
+
/*!************************************!*\
|
|
210
|
+
!*** ./src/utils/buffer-helper.ts ***!
|
|
211
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{BufferHelper:()=>a});var i=r(/*! ./logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,d=0;d<i.length;d++){var h=i[d].start,f=i[d].end;if(t+r>=h&&t<f)u=h,l=(c=f)-t;else if(t+r<h){o=h;break}}return{len:l,start:u||0,end:c||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return i.logger.log("failed to get media.buffered",e),n}},e}()},"./src/utils/cea-608-parser.ts":
|
|
77
212
|
/*!*************************************!*\
|
|
78
|
-
!*** ./src/utils/
|
|
79
|
-
\*************************************/
|
|
80
|
-
/*! exports provided: getSelfScope */function(e,t,r){function i(){return"undefined"==typeof window?self:window}r.r(t),r.d(t,"getSelfScope",(function(){return i}))},"./src/utils/logger.js":
|
|
213
|
+
!*** ./src/utils/cea-608-parser.ts ***!
|
|
214
|
+
\*************************************/(e,t,r)=>{r.r(t),r.d(t,{CaptionScreen:()=>A,Row:()=>y,default:()=>S});var i,n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},s=function(e){var t=e;return a.hasOwnProperty(e)&&(t=a[e]),String.fromCharCode(t)},o=15,l=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},c={17:2,18:4,21:6,22:8,23:10,19:13,20:15},d={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},h={25:2,26:4,29:6,30:8,31:10,27:13,28:15},f=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(e){e[e.ERROR=0]="ERROR",e[e.TEXT=1]="TEXT",e[e.WARNING=2]="WARNING",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.DATA=3]="DATA"}(i||(i={}));var g=function(){function e(){this.time=null,this.verboseLevel=i.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&n.logger.log(this.time+" ["+e+"] "+t)},e}(),p=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},v=function(){function e(e,t,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),m=function(){function e(e,t,r,i,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new v(t,r,i,n,a)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),y=function(){function e(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<l;t++)this.chars.push(new m);this.logger=e,this.pos=0,this.currPenState=new v}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<l;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<l;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<l;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(i.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>l&&(this.logger.log(i.DEBUG,"Too large cursor position "+this.pos),this.pos=l)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=s(e);this.pos>=l?this.logger.log(i.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<l;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<l;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),A=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<o;t++)this.rows.push(new y(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<o;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<o;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<o;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<o;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(i.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(i.INFO,"pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<o;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var s=a.rows[n].cueStartTime,l=this.logger.time;if(s&&null!==l&&s<l)for(var u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(a.rows[n+u])}}this.currRow=t;var c=this.rows[this.currRow];if(null!==e.indent){var d=e.indent,h=Math.max(d-1,0);c.setCursor(e.indent),e.color=c.chars[h].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)},t.setBkgData=function(e){this.logger.log(i.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(i.TEXT,this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(i.INFO,"Rolling up")}else this.logger.log(i.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,n=0;n<o;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),E=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new A(r),this.nonDisplayedMemory=new A(r),this.lastOutputScreen=new A(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(i.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(i.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(i.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(i.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(i.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(i.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(i.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(i.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(i.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(i.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(i.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(i.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(i.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(i.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(this.logger.log(i.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(i.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(i.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(i.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}();function T(e,t,r){r.a=e,r.b=t}function b(e,t,r){return r.a===e&&r.b===t}const S=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new g;this.channels=[null,new E(e,t,i),new E(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,n,a,s=!1;this.logger.time=e;for(var o=0;o<t.length;o+=2)if(n=127&t[o],a=127&t[o+1],0!==n||0!==a){if(this.logger.log(i.DATA,"["+p([t[o],t[o+1]])+"] -> ("+p([n,a])+")"),(r=this.parseCmd(n,a))||(r=this.parseMidrow(n,a)),r||(r=this.parsePAC(n,a)),r||(r=this.parseBackgroundAttributes(n,a)),!r&&(s=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(s):this.logger.log(i.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(i.WARNING,"Couldn't parse cleaned data "+p([n,a])+" orig: "+p([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(b(e,t,r))return T(null,null,r),this.logger.log(i.DEBUG,"Repeated command ("+p([e,t])+") is dropped"),!0;var n=20===e||21===e||23===e?1:2,a=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?a.ccRCL():33===t?a.ccBS():34===t?a.ccAOF():35===t?a.ccAON():36===t?a.ccDER():37===t?a.ccRU(2):38===t?a.ccRU(3):39===t?a.ccRU(4):40===t?a.ccFON():41===t?a.ccRDC():42===t?a.ccTR():43===t?a.ccRTD():44===t?a.ccEDM():45===t?a.ccCR():46===t?a.ccENM():47===t&&a.ccEOC():a.ccTO(t-32),T(e,t,r),this.currentChannel=n,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(i.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(t),this.logger.log(i.DEBUG,"MIDROW ("+p([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(b(e,t,i))return T(null,null,i),!0;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?u[e]:d[e]:1===n?c[e]:h[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),T(e,t,i),this.currentChannel=n,!0)},t.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.parseChars=function(e,t){var r,n,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(n=17===o?t+80:18===o?t+112:t+144,this.logger.log(i.INFO,"Special char '"+s(n)+"' in channel "+r),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]),a){var l=p(a);this.logger.log(i.DEBUG,"Char codes = "+l.join(",")),T(e,t,this.cmdHistory)}return a},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=f[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),T(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}()},"./src/utils/codecs.ts":
|
|
81
215
|
/*!*****************************!*\
|
|
82
|
-
!*** ./src/utils/
|
|
83
|
-
\*****************************/
|
|
84
|
-
/*! exports provided: enableLogs, logger */function(e,t,r){r.r(t),r.d(t,"enableLogs",(function(){return c})),r.d(t,"logger",(function(){return d}));var i=r(/*! ./get-self-scope */"./src/utils/get-self-scope.js");function n(){}var a={trace:n,debug:n,log:n,warn:n,info:n,error:n},s=a;function o(e,t){return t="["+e+"] > "+t}var l=Object(i.getSelfScope)();function u(e){var t=l.console[e];return t?function(){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];i[0]&&(i[0]=o(e,i[0])),t.apply(l.console,i)}:n}var c=function(e){if(l.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){s[t]=e[t]?e[t].bind(e):u(t)}))}(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=a}}else s=a},d=s}}).default},ut.exports=ct());var ht=lt(dt.exports),ft=se,gt=oe;Ae.register("PLAYBACK_FRAGMENT_CHANGED"),Ae.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var pt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(f,e);var n,o,d,h=l(f);function f(){var e;r(this,f);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=h.call.apply(h,[this].concat(n))).options.hlsPlayback=t(t({},e.defaultOptions),e.options.hlsPlayback),e._setInitialState(),e}return n=f,d=[{key:"HLSJS",get:function(){return ht}}],(o=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(e){this._currentLevel=e,this.trigger(Ae.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===Fe.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return ft()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var e=this._localStartTimeCorrelation,t=this._now-e.local,r=(e.remote+t)/1e3;return Math.min(r,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var e=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return e;var t=this._localEndTimeCorrelation,r=this._now-t.local,i=(t.remote+r)/1e3;return Math.max(e-this._extrapolatedWindowDuration,Math.min(i,e))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=Fe.VOD,this._lastTimeUpdate={current:0,total:0},this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestParsed=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var e=t({},this.options.playback.hlsjsConfig);this._hls=new ht(e)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var e=this;this._hls&&(this._hls.once(ht.Events.MEDIA_ATTACHED,(function(){e.options.hlsPlayback.preload&&e._hls.loadSource(e.options.src)})),this._hls.on(ht.Events.MANIFEST_PARSED,(function(){return e._manifestParsed=!0})),this._hls.on(ht.Events.LEVEL_LOADED,(function(t,r){return e._updatePlaybackType(t,r)})),this._hls.on(ht.Events.LEVEL_UPDATED,(function(t,r){return e._onLevelUpdated(t,r)})),this._hls.on(ht.Events.LEVEL_SWITCHING,(function(t,r){return e._onLevelSwitch(t,r)})),this._hls.on(ht.Events.FRAG_CHANGED,(function(t,r){return e._onFragmentChanged(t,r)})),this._hls.on(ht.Events.FRAG_LOADED,(function(t,r){return e._onFragmentLoaded(t,r)})),this._hls.on(ht.Events.FRAG_PARSING_METADATA,(function(t,r){return e._onFragmentParsingMetadata(t,r)})),this._hls.on(ht.Events.ERROR,(function(t,r){return e._onHLSJSError(t,r)})),this._hls.on(ht.Events.SUBTITLE_TRACK_LOADED,(function(t,r){return e._onSubtitleLoaded(t,r)})),this._hls.on(ht.Events.SUBTITLE_TRACKS_UPDATED,(function(){return e._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName,i=t.once?"once":"on";r&&e._hls["".concat(i)](r,t.callback)}))}},{key:"unbindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName;r&&e._hls.off(r,t.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(e,t){this.trigger(Ae.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:e,data:t})}},{key:"render",value:function(){return this._ready(),u(a(f.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(Ae.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(e,t,r){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){fe.error("hlsjs: failed to recover",{evt:e,data:t}),r.level=Pe.Levels.FATAL;var i=this.createError(r);this.trigger(Ae.PLAYBACK_ERROR,i),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError();else this._recoveredDecodingError=!0,this._hls.recoverMediaError()}},{key:"_setupSrc",value:function(e){}},{key:"_startTimeUpdateTimer",value:function(){var e=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){e._onDurationChange(),e._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(e){var t=e>0?this._duration*(e/100):this._duration;this.seek(t)}},{key:"seek",value:function(e){e<0&&(fe.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this._startTime,this.el.currentTime=e}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateDvr",value:function(e){this.trigger(Ae.PLAYBACK_DVR,e),this.trigger(Ae.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"_updateSettings",value:function(){this._playbackType===Fe.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Ae.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(e,t){var r,i={code:"".concat(t.type,"_").concat(t.details),description:"".concat(this.name," error: type: ").concat(t.type,", details: ").concat(t.details),raw:t};if(t.response&&(i.description+=", response: ".concat(JSON.stringify(t.response))),t.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,t.type){case ht.ErrorTypes.NETWORK_ERROR:switch(t.details){case ht.ErrorDetails.MANIFEST_LOAD_ERROR:case ht.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case ht.ErrorDetails.MANIFEST_PARSING_ERROR:case ht.ErrorDetails.LEVEL_LOAD_ERROR:case ht.ErrorDetails.LEVEL_LOAD_TIMEOUT:fe.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:t}),r=this.createError(i),this.trigger(Ae.PLAYBACK_ERROR,r),this.stop();break;default:fe.warn("hlsjs: trying to recover from network error.",{evt:e,data:t}),i.level=Pe.Levels.WARN,this._hls.startLoad()}break;case ht.ErrorTypes.MEDIA_ERROR:fe.warn("hlsjs: trying to recover from media error.",{evt:e,data:t}),i.level=Pe.Levels.WARN,this._recover(e,t,i);break;default:fe.error("hlsjs: could not recover from error.",{evt:e,data:t}),r=this.createError(i),this.trigger(Ae.PLAYBACK_ERROR,r),this.stop()}else fe.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:t}),r=this.createError(i),this.trigger(Ae.PLAYBACK_ERROR,r),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(t))return fe.error("hlsjs: could not load decrypt key.",{evt:e,data:t}),r=this.createError(i),this.trigger(Ae.PLAYBACK_ERROR,r),void this.stop();i.level=Pe.Levels.WARN,fe.warn("hlsjs: non-fatal error occurred",{evt:e,data:t})}}},{key:"_keyIsDenied",value:function(e){return e.type===ht.ErrorTypes.NETWORK_ERROR&&e.details===ht.ErrorDetails.KEY_LOAD_ERROR&&e.response&&e.response.code>=400}},{key:"_onTimeUpdate",value:function(){var e={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._lastTimeUpdate&&e.current===this._lastTimeUpdate.current&&e.total===this._lastTimeUpdate.total||(this._lastTimeUpdate=e,this.trigger(Ae.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_onDurationChange",value:function(){var e=this.getDuration();this._lastDuration!==e&&(this._lastDuration=e,u(a(f.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(c(e),[{start:Math.max(0,this.el.buffered.start(r)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(r)-this._playableRegionStartTime)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.getDuration()};this.trigger(Ae.PLAYBACK_PROGRESS,i,e)}}},{key:"load",value:function(e){this._stopTimeUpdateTimer(),this.options.src=e,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestParsed&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),u(a(f.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(this.el.pause(),this.dvrEnabled&&this._updateDvr(!0))}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&u(a(f.prototype),"stop",this).call(this),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),u(a(f.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(e,t){this._playbackType=t.details.live?Fe.LIVE:Fe.VOD,this._onLevelUpdated(e,t),this._ccTracksUpdated&&this._playbackType===Fe.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map((function(e,t){return{id:t,level:e,label:"".concat(e.bitrate/1e3,"Kbps")}})),this.trigger(Ae.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,t){this._segmentTargetDuration=t.details.targetduration,this._playlistType=t.details.type||null;var r=!1,i=!1,n=t.details.fragments,a=this._playableRegionStartTime,s=this._playableRegionDuration;if(0!==n.length){if(n[0].rawProgramDateTime&&(this._programDateTime=n[0].rawProgramDateTime),this._playableRegionStartTime!==n[0].start&&(r=!0,this._playableRegionStartTime=n[0].start),r)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,u=(o.remote+l)/1e3;u<n[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*n[0].start}:u>a+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(n[0].start,a+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(n[0].start+this._extrapolatedWindowDuration/2)};var c=t.details.totalduration;if(this._playbackType===Fe.LIVE){var d=t.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||ht.DefaultConfig.liveSyncDurationCount);d<=c?(c-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}c!==this._playableRegionDuration&&(i=!0,this._playableRegionDuration=c);var h=n[0].start+c,f=a+s;if(h!==f)if(this._localEndTimeCorrelation){var g=this._localEndTimeCorrelation,p=this._now-g.local,v=(g.remote+p)/1e3;v>h?this._localEndTimeCorrelation={local:this._now,remote:1e3*h}:v<h-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(h-this._extrapolatedWindowDuration)}:v>f&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*h};i&&this._onDurationChange(),r&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(e,t){this.trigger(Ae.Custom.PLAYBACK_FRAGMENT_CHANGED,t)}},{key:"_onFragmentLoaded",value:function(e,t){this.trigger(Ae.PLAYBACK_FRAGMENT_LOADED,t)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(Ae.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===Fe.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,t){this.levels.length||this._fillLevels(),this.trigger(Ae.PLAYBACK_LEVEL_SWITCH_END),this.trigger(Ae.PLAYBACK_LEVEL_SWITCH,t);var r=this._hls.levels[t.level];r&&(this.highDefinition=r.height>=720||r.bitrate/1e3>=2e3,this.trigger(Ae.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(Ae.PLAYBACK_BITRATE,{height:r.height,width:r.width,bandwidth:r.bitrate,bitrate:r.bitrate,level:t.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Fe.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Fe.VOD||this.dvrEnabled}}])&&i(n.prototype,o),d&&i(n,d),f}(rt);return pt.canPlay=function(e,t){var r=e.split("?")[0].match(/.*\.(.*)$/)||[],i=r.length>1&&"m3u8"===r[1].toLowerCase()||gt(t,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!ht.isSupported()||!i)},pt}();
|
|
216
|
+
!*** ./src/utils/codecs.ts ***!
|
|
217
|
+
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{isCodecSupportedInMp4:()=>a,isCodecType:()=>n});var i={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function n(e,t){var r=i[t];return!!r&&!0===r[e.slice(0,4)]}function a(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},"./src/utils/cues.ts":
|
|
218
|
+
/*!***************************!*\
|
|
219
|
+
!*** ./src/utils/cues.ts ***!
|
|
220
|
+
\***************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),a=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),s=/\s/;const o={newCue:function(e,t,r,o){for(var l,u,c,d,h,f=[],g=self.VTTCue||self.TextTrackCue,p=0;p<o.rows.length;p++)if(c=!0,d=0,h="",!(l=o.rows[p]).isEmpty()){for(var v=0;v<l.chars.length;v++)s.test(l.chars[v].uchar)&&c?d++:(h+=l.chars[v].uchar,c=!1);l.cueStartTime=t,t===r&&(r+=1e-4),d>=16?d--:d++;var m=(0,i.fixLineBreaks)(h.trim()),y=(0,n.generateCueId)(t,r,m);e&&e.cues&&e.cues.getCueById(y)||((u=new g(t,r,m)).id=y,u.line=p+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*d/32)),f.push(u))}return e&&f.length&&(f.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),f.forEach((function(t){return(0,a.addCueToTrack)(e,t)}))),f}}},"./src/utils/discontinuities.ts":
|
|
221
|
+
/*!**************************************!*\
|
|
222
|
+
!*** ./src/utils/discontinuities.ts ***!
|
|
223
|
+
\**************************************/(e,t,r)=>{r.r(t),r.d(t,{adjustSlidingStart:()=>c,alignMediaPlaylistByPDT:()=>f,alignPDT:()=>h,alignStream:()=>d,findDiscontinuousReferenceFrag:()=>l,findFirstFragWithCC:()=>s,shouldAlignOnDiscontinuities:()=>o});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./logger */"./src/utils/logger.ts"),a=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function s(e,t){for(var r=null,i=0,n=e.length;i<n;i++){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function l(e,t,r){var i=e.fragments,a=t.fragments;if(a.length&&i.length){var o=s(i,a[0].cc);if(o&&(!o||o.startPTS))return o;n.logger.log("No frag in previous level to align on")}else n.logger.log("No fragments to align")}function u(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function c(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)u(r[i],e);t.fragmentHint&&u(t.fragmentHint,e),t.alignedSliding=!0}function d(e,t,r){t&&(function(e,t,r){if(o(e,r,t)){var a=l(r.details,t);a&&(0,i.isFiniteNumber)(a.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),c(a.start,t))}}(e,r,t),!r.alignedSliding&&t.details&&h(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||(0,a.adjustSliding)(t.details,r))}function h(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,s=(a-r)/1e3+t.fragments[0].start;s&&(0,i.isFiniteNumber)(s)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(a-r)+"ms, sliding:"+s.toFixed(3)+" "+e.url+" "),c(s,e))}}function f(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n=i[Math.round(i.length/2)-1],a=s(r,n.cc)||r[Math.round(r.length/2)-1],o=n.programDateTime,l=a.programDateTime;null!==o&&null!==l&&c((l-o)/1e3-(a.start-n.start),e)}}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
224
|
+
/*!***********************************************!*\
|
|
225
|
+
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
226
|
+
\***********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/ewma */"./src/utils/ewma.ts");const n=function(){function e(e,t,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new i.default(e),this.fast_=new i.default(t)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new i.default(e,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new i.default(t,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}()},"./src/utils/ewma.ts":
|
|
227
|
+
/*!***************************!*\
|
|
228
|
+
!*** ./src/utils/ewma.ts ***!
|
|
229
|
+
\***************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}()},"./src/utils/fetch-loader.ts":
|
|
230
|
+
/*!***********************************!*\
|
|
231
|
+
!*** ./src/utils/fetch-loader.ts ***!
|
|
232
|
+
\***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>v,fetchSupported:()=>h});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,c(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),u(i,e)},s(e)}function o(e,t,r){return o=l()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&u(n,r.prototype),n},o.apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}function h(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var f=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||g,this.controller=new self.AbortController,this.stats=new n.LoadStats}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(d({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),t.timeout),self.fetch(this.request).then((function(r){if(n.response=n.loader=r,!r.ok){var s=r.status,u=r.statusText;throw new p(u||"fetch, bad network response",s,r)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),o&&(0,i.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(r,a,e,t.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(s){var l=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var c=s[u];c&&(a.loaded=a.total=c);var d={url:l.url,data:s};o&&!(0,i.isFiniteNumber)(t.highWaterMark)&&o(a,e,s,l),r.onSuccess(d,a,e,l)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!a.aborted){var i=t&&t.code||0,s=t?t.message:null;r.onError({code:i,text:s},e,t?t.details:null)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var s=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return s.dataLength&&n(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return t.loaded+=u,u<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush(),e)):n(t,r,l,e),a()})).catch((function(){return Promise.reject()}))}()},e}();function g(e,t){return new self.Request(e.url,t)}var p=function(e){var t,r;function i(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,u(t,r),i}(s(Error));const v=f},"./src/utils/imsc1-ttml-parser.ts":
|
|
233
|
+
/*!****************************************!*\
|
|
234
|
+
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
235
|
+
\****************************************/(e,t,r)=>{r.r(t),r.d(t,{IMSC1_CODEC:()=>c,parseIMSC1:()=>g});var i=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ./vttcue */"./src/utils/vttcue.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},u.apply(this,arguments)}var c="stpp.ttml.im1t",d=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,h=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(e,t,r,n,c){var d=(0,i.findBox)(new Uint8Array(e),["mdat"]);if(0!==d.length){var h=d.map((function(e){return(0,s.utf8ArrayToStr)(e)})),g=(0,o.toTimescaleFromScale)(t,1,r);try{h.forEach((function(e){return n(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((function(e,t){return e[t]=i.getAttribute("ttp:"+t)||n[t],e}),{}),o="preserve"!==i.getAttribute("xml:space"),c=v(p(i,"styling","style")),d=v(p(i,"layout","region")),h=p(i,"body","[begin]");return[].map.call(h,(function(e){var r=m(e,o);if(!r||!e.hasAttribute("begin"))return null;var i=E(e.getAttribute("begin"),s),n=E(e.getAttribute("dur"),s),h=E(e.getAttribute("end"),s);if(null===i)throw A(e);if(null===h){if(null===n)throw A(e);h=i+n}var g=new a.default(i-t,h-t,r);g.id=(0,l.generateCueId)(g.startTime,g.endTime,g.text);var p=d[e.getAttribute("region")],v=c[e.getAttribute("style")];g.position=10,g.size=80;var T=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),a.reduce((function(r,a){var s=y(t,i,a)||y(e,i,a)||y(n,i,a);return s&&(r[a]=s),r}),{})}(p,v,c),b=T.textAlign;if(b){var S=f[b];S&&(g.lineAlign=S),g.align=b}return u(g,T),g})).filter((function(e){return null!==e}))}(e,g))}))}catch(e){c(e)}}else c(new Error("Could not parse IMSC1 mdat"))}function p(e,t,r){var i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function v(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function m(e,t){return[].slice.call(e.childNodes).reduce((function(e,r,i){var n;return"br"===r.nodeName&&i?e+"\n":null!==(n=r.childNodes)&&void 0!==n&&n.length?m(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent}),"")}function y(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function A(e){return new Error("Could not parse ttml timestamp "+e)}function E(e,t){if(!e)return null;var r=(0,n.parseTimeStamp)(e);return null===r&&(d.test(e)?r=function(e,t){var r=d.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):h.test(e)&&(r=function(e,t){var r=h.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}},"./src/utils/logger.ts":
|
|
236
|
+
/*!*****************************!*\
|
|
237
|
+
!*** ./src/utils/logger.ts ***!
|
|
238
|
+
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{enableLogs:()=>o,logger:()=>l});var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},a=n;function s(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):i}function o(e,t){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){a[t]=e[t]?e[t].bind(e):s(t)}))}(e,"debug","log","info","warn","error");try{a.log('Debug logs enabled for "'+t+'"')}catch(e){a=n}}else a=n}var l=n},"./src/utils/mediakeys-helper.ts":
|
|
239
|
+
/*!***************************************!*\
|
|
240
|
+
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
241
|
+
\***************************************/(e,t,r)=>{var i;r.r(t),r.d(t,{KeySystems:()=>i,requestMediaKeySystemAccess:()=>n}),function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(i||(i={}));var n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
|
|
242
|
+
/*!*****************************************!*\
|
|
243
|
+
!*** ./src/utils/mediasource-helper.ts ***!
|
|
244
|
+
\*****************************************/(e,t,r)=>{function i(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,{getMediaSource:()=>i})},"./src/utils/mp4-tools.ts":
|
|
245
|
+
/*!********************************!*\
|
|
246
|
+
!*** ./src/utils/mp4-tools.ts ***!
|
|
247
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{RemuxerTrackIdConfig:()=>l,appendUint8Array:()=>b,bin2str:()=>u,computeRawDurationFromSamples:()=>A,discardEPB:()=>L,findBox:()=>g,getDuration:()=>y,getStartDTS:()=>m,offsetStartDTS:()=>E,parseEmsg:()=>D,parseInitSegment:()=>v,parseSEIMessageFromNALu:()=>k,parseSamples:()=>S,parseSegmentIndex:()=>p,readSint32:()=>h,readUint16:()=>c,readUint32:()=>d,segmentValidRange:()=>T,writeUint32:()=>f});var i=r(/*! ./typed-array */"./src/utils/typed-array.ts"),n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=Math.pow(2,32)-1,o=[].push,l={video:1,audio:2,id3:3,text:4};function u(e){return String.fromCharCode.apply(null,e)}function c(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function d(e,t){var r=h(e,t);return r<0?4294967296+r:r}function h(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function f(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function g(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=d(e,n),s=a>1?n+a:i;if(u(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var l=g(e.subarray(n+8,s),t.slice(1));l.length&&o.apply(r,l)}n=s}return r}function p(e){var t=[],r=e[0],i=8,n=d(e,i);i+=4,i+=0===r?8:16,i+=2;var a=e.length+0,s=c(e,i);i+=2;for(var o=0;o<s;o++){var l=i,u=d(e,l);l+=4;var h=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var f=d(e,l);l+=4,t.push({referenceSize:h,subsegmentDuration:f,info:{duration:f/n,start:a,end:a+h-1}}),a+=h,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:t}}function v(e){for(var t=[],r=g(e,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],s=g(a,["tkhd"])[0];if(s){var o=s[0],l=0===o?12:20,c=d(s,l),h=g(a,["mdia","mdhd"])[0];if(h){var f=d(h,l=0===(o=h[0])?12:20),p=g(a,["mdia","hdlr"])[0];if(p){var v=u(p.subarray(8,12)),m={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[v];if(m){var y=g(a,["mdia","minf","stbl","stsd"])[0],A=void 0;y&&(A=u(y.subarray(12,16))),t[c]={timescale:f,type:m},t[m]={timescale:f,id:c,codec:A}}}}}}return g(e,["moov","mvex","trex"]).forEach((function(e){var r=d(e,4),i=t[r];i&&(i.default={duration:d(e,12),flags:d(e,20)})})),t}function m(e,t){return g(t,["moof","traf"]).reduce((function(t,r){var i=g(r,["tfdt"])[0],n=i[0],a=g(r,["tfhd"]).reduce((function(t,r){var a=d(r,4),s=e[a];if(s){var o=d(i,4);1===n&&(o*=Math.pow(2,32),o+=d(i,8));var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)||0}function y(e,t){for(var r=0,i=0,a=0,s=g(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],u=g(l,["tfhd"])[0],c=t[d(u,4)];if(c){var h=c.default,f=d(u,0)|(null==h?void 0:h.flags),v=null==h?void 0:h.duration;8&f&&(v=d(u,2&f?12:8));for(var m=c.timescale||9e4,y=g(l,["trun"]),E=0;E<y.length;E++)!(r=A(y[E]))&&v&&(r=v*d(y[E],4)),c.type===n.ElementaryStreamTypes.VIDEO?i+=r/m:c.type===n.ElementaryStreamTypes.AUDIO&&(a+=r/m)}}if(0===i&&0===a){for(var T=0,b=g(e,["sidx"]),S=0;S<b.length;S++){var _=p(b[S]);null!=_&&_.references&&(T+=_.references.reduce((function(e,t){return e+t.info.duration||0}),0))}return T}return i||a}function A(e){var t=d(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=d(e,4),a=0;a<n;a++)256&t&&(i+=d(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function E(e,t,r){g(t,["moof","traf"]).forEach((function(t){g(t,["tfhd"]).forEach((function(i){var n=d(i,4),a=e[n];if(a){var o=a.timescale||9e4;g(t,["tfdt"]).forEach((function(e){var t=e[0],i=d(e,4);if(0===t)i-=r*o,f(e,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=d(e,8),i-=r*o,i=Math.max(i,0);var n=Math.floor(i/(s+1)),a=Math.floor(i%(s+1));f(e,4,n),f(e,8,a)}}))}}))}))}function T(e){var t={valid:null,remainder:null},r=g(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var n=r[r.length-1];return t.valid=(0,i.sliceUint8)(e,0,n.byteOffset-8),t.remainder=(0,i.sliceUint8)(e,n.byteOffset-8),t}function b(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function S(e,t){var r=[],i=t.samples,a=t.timescale,s=t.id,o=!1;return g(i,["moof"]).map((function(l){var u=l.byteOffset-8;g(l,["traf"]).map((function(l){var c=g(l,["tfdt"]).map((function(e){var t=e[0],r=d(e,4);return 1===t&&(r*=Math.pow(2,32),r+=d(e,8)),r/a}))[0];return void 0!==c&&(e=c),g(l,["tfhd"]).map((function(c){var f=d(c,4),p=16777215&d(c,0),v=0,m=0!=(16&p),y=0,A=0!=(32&p),E=8;f===s&&(0!=(1&p)&&(E+=8),0!=(2&p)&&(E+=4),0!=(8&p)&&(v=d(c,E),E+=4),m&&(y=d(c,E),E+=4),A&&(E+=4),"video"===t.type&&(o=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),g(l,["trun"]).map((function(s){var l=s[0],c=16777215&d(s,0),f=0!=(1&c),g=0,p=0!=(4&c),m=0!=(256&c),A=0,E=0!=(512&c),T=0,b=0!=(1024&c),S=0!=(2048&c),L=0,D=d(s,4),R=8;f&&(g=d(s,R),R+=4),p&&(R+=4);for(var C=g+u,I=0;I<D;I++){if(m?(A=d(s,R),R+=4):A=v,E?(T=d(s,R),R+=4):T=y,b&&(R+=4),S&&(L=0===l?d(s,R):h(s,R),R+=4),t.type===n.ElementaryStreamTypes.VIDEO)for(var O=0;O<T;){var w=d(i,C);_(o,i[C+=4])&&k(i.subarray(C,C+w),o?2:1,e+L/a,r),C+=w,O+=w+4}e+=A/a}})))}))}))})),r}function _(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function k(e,t,r,i){var n=L(e),s=0;s+=t;for(var o=0,l=0,u=!1,h=0;s<n.length;){o=0;do{if(s>=n.length)break;o+=h=n[s++]}while(255===h);l=0;do{if(s>=n.length)break;l+=h=n[s++]}while(255===h);var f=n.length-s;if(!u&&4===o&&s<n.length){if(u=!0,181===n[s++]){var g=c(n,s);if(s+=2,49===g){var p=d(n,s);if(s+=4,1195456820===p){var v=n[s++];if(3===v){var m=n[s++],y=64&m,A=y?2+3*(31&m):0,E=new Uint8Array(A);if(y){E[0]=m;for(var T=1;T<A;T++)E[T]=n[s++]}i.push({type:v,payloadType:o,pts:r,bytes:E})}}}}}else if(5===o&&l<f){if(u=!0,l>16){for(var b=[],S=0;S<16;S++){var _=n[s++].toString(16);b.push(1==_.length?"0"+_:_),3!==S&&5!==S&&7!==S&&9!==S||b.push("-")}for(var k=l-16,D=new Uint8Array(k),R=0;R<k;R++)D[R]=n[s++];i.push({payloadType:o,pts:r,uuid:b.join(""),userData:(0,a.utf8ArrayToStr)(D),userDataBytes:D})}}else if(l<f)s+=l;else if(l>f)break}}function L(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function D(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==u(e.subarray(c,c+1));)r+=u(e.subarray(c,c+1)),c+=1;for(r+=u(e.subarray(c,c+1)),c+=1;"\0"!==u(e.subarray(c,c+1));)i+=u(e.subarray(c,c+1)),c+=1;i+=u(e.subarray(c,c+1)),c+=1,n=d(e,12),a=d(e,16),o=d(e,20),l=d(e,24),c=28}else if(1===t){n=d(e,c+=4);var h=d(e,c+=4),f=d(e,c+=4);for(c+=4,s=Math.pow(2,32)*h+f,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=d(e,c),l=d(e,c+=4),c+=4;"\0"!==u(e.subarray(c,c+1));)r+=u(e.subarray(c,c+1)),c+=1;for(r+=u(e.subarray(c,c+1)),c+=1;"\0"!==u(e.subarray(c,c+1));)i+=u(e.subarray(c,c+1)),c+=1;i+=u(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}},"./src/utils/output-filter.ts":
|
|
248
|
+
/*!************************************!*\
|
|
249
|
+
!*** ./src/utils/output-filter.ts ***!
|
|
250
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}()},"./src/utils/texttrack-utils.ts":
|
|
251
|
+
/*!**************************************!*\
|
|
252
|
+
!*** ./src/utils/texttrack-utils.ts ***!
|
|
253
|
+
\**************************************/(e,t,r)=>{r.r(t),r.d(t,{addCueToTrack:()=>a,clearCurrentCues:()=>s,getCuesInRange:()=>l,removeCuesInRange:()=>o,sendAddTrackEvent:()=>n});var i=r(/*! ./logger */"./src/utils/logger.ts");function n(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function a(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}"disabled"===r&&(e.mode=r)}function s(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=l(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function l(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":
|
|
254
|
+
/*!**********************************!*\
|
|
255
|
+
!*** ./src/utils/time-ranges.ts ***!
|
|
256
|
+
\**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts":
|
|
257
|
+
/*!*******************************************!*\
|
|
258
|
+
!*** ./src/utils/timescale-conversion.ts ***!
|
|
259
|
+
\*******************************************/(e,t,r)=>{function i(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}function n(e,t,r,n){return void 0===r&&(r=1),void 0===n&&(n=!1),i(e,t,1/r,n)}function a(e,t){return void 0===t&&(t=!1),i(e,1e3,1/9e4,t)}function s(e,t){return void 0===t&&(t=1),i(e,9e4,1/t)}r.r(t),r.d(t,{toMpegTsClockFromTimescale:()=>s,toMsFromMpegTsClock:()=>a,toTimescaleFromBase:()=>i,toTimescaleFromScale:()=>n})},"./src/utils/typed-array.ts":
|
|
260
|
+
/*!**********************************!*\
|
|
261
|
+
!*** ./src/utils/typed-array.ts ***!
|
|
262
|
+
\**********************************/(e,t,r)=>{function i(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}r.r(t),r.d(t,{sliceUint8:()=>i})},"./src/utils/vttcue.ts":
|
|
263
|
+
/*!*****************************!*\
|
|
264
|
+
!*** ./src/utils/vttcue.ts ***!
|
|
265
|
+
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,d=t,h=a,f=s,g=null,p="",v=!0,m="auto",y="start",A=50,E="middle",T=50,b="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return g},set:function(e){g=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return p},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");p=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return v},set:function(e){v=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return A},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return b},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts":
|
|
266
|
+
/*!********************************!*\
|
|
267
|
+
!*** ./src/utils/vttparser.ts ***!
|
|
268
|
+
\********************************/(e,t,r)=>{r.r(t),r.d(t,{VTTParser:()=>h,fixLineBreaks:()=>d,parseTimeStamp:()=>a});var i=r(/*! ./vttcue */"./src/utils/vttcue.ts"),n=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function a(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var s=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},e}();function o(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);2===s.length&&t(s[0],s[1])}}var l=new i.default(0,0,""),u="middle"===l.align?"middle":"center";function c(e,t,r){var i=e;function n(){var t=a(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function c(){e=e.replace(/^\s+/,"")}if(c(),t.startTime=n(),c(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),c(),t.endTime=n(),c(),function(e,t){var i=new s;o(e,(function(e,t){var n;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",u,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",u,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===l.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",u);var a=i.get("position","auto");"auto"===a&&50===l.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function d(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var h=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new n,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=d(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var s=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:n=r(),t.state){case"HEADER":/:/.test(n)?o(n,(function(e,t){}),/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new i.default(0,0,""),t.state="CUE",-1===n.indexOf("--\x3e")){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{c(n,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=-1!==n.indexOf("--\x3e");if(!n||l&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},e}()},"./src/utils/webvtt-parser.ts":
|
|
269
|
+
/*!************************************!*\
|
|
270
|
+
!*** ./src/utils/webvtt-parser.ts ***!
|
|
271
|
+
\************************************/(e,t,r)=>{r.r(t),r.d(t,{generateCueId:()=>d,parseWebVTT:()=>h});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(e,t,r){return void 0===r&&(r=0),e.slice(r,r+t.length)===t},c=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function d(e,t,r){return c(e.toString())+c(t.toString())+c(r)}function h(e,t,r,c,h,f,g,p){var v,m=new n.VTTParser,y=(0,a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(l,"\n").split("\n"),A=[],E=(0,s.toMpegTsClockFromTimescale)(t,r),T="00:00.000",b=0,S=0,_=!0;m.oncue=function(e){var t=c[h],r=c.ccOffset,i=(b-E)/9e4;null!=t&&t.new&&(void 0!==S?r=c.ccOffset=t.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!==(a=n)&&void 0!==a&&a.new;){var a;e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC]}e.presentationOffset=r}(c,h,i)),i&&(r=i-c.presentationOffset);var n=e.endTime-e.startTime,a=(0,o.normalizePts)(9e4*(e.startTime+r-S),9e4*f)/9e4;e.startTime=Math.max(a,0),e.endTime=Math.max(a+n,0);var s=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(s)),e.id||(e.id=d(e.startTime,e.endTime,s)),e.endTime>0&&A.push(e)},m.onparsingerror=function(e){v=e},m.onflush=function(){v?p(v):g(A)},y.forEach((function(e){if(_){if(u(e,"X-TIMESTAMP-MAP=")){_=!1,e.slice(16).split(",").forEach((function(e){u(e,"LOCAL:")?T=e.slice(6):u(e,"MPEGTS:")&&(b=parseInt(e.slice(7)))}));try{S=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!((0,i.isFiniteNumber)(t)&&(0,i.isFiniteNumber)(r)&&(0,i.isFiniteNumber)(n)&&(0,i.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,(t+=6e4*n)+36e5*a}(T)/1e3}catch(e){v=e}return}""===e&&(_=!1)}m.parse(e+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts":
|
|
272
|
+
/*!*********************************!*\
|
|
273
|
+
!*** ./src/utils/xhr-loader.ts ***!
|
|
274
|
+
\*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m;const s=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,t.url)}catch(e){r.open("GET",t.url,!0),n(r,t.url)}r.readyState||r.open("GET",t.url,!0);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),r.send()}},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="arraybuffer"===t.responseType;if(s>=200&&s<300&&(o&&t.response||null!==t.responseText)){var l,u;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),u=o?(l=t.response).byteLength:(l=t.responseText).length,r.loaded=r.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var d={url:t.responseURL,data:l};this.callbacks.onSuccess(d,r,e,t)}else r.retry>=a.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:t.statusText},e,t)):(i.logger.warn(s+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},t.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},e}()},"./node_modules/eventemitter3/index.js":
|
|
275
|
+
/*!*********************************************!*\
|
|
276
|
+
!*** ./node_modules/eventemitter3/index.js ***!
|
|
277
|
+
\*********************************************/e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,a),!0;case 6:return c.fn.call(c.context,t,i,n,a,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var h,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c[u].fn.apply(c[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var l=0,u=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
278
|
+
/*!*****************************************************!*\
|
|
279
|
+
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
280
|
+
\*****************************************************/function(e){var t,r,i,n,a;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=a.normalizePath(n.path),a.buildURLFromParts(n)}var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var c=o.path,d=c.substring(0,c.lastIndexOf("/")+1)+s.path;u.path=a.normalizePath(d)}else u.path=o.path,s.params||(u.params=o.params,s.query||(u.query=o.query));return null===u.path&&(u.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(u)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports}r.m=e,r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r("./src/hls.ts");return i=i.default})(),ht.exports=ft());var pt=dt(gt.exports),vt=ue,mt=ce;Te.register("PLAYBACK_FRAGMENT_CHANGED"),Te.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var yt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}(f,e);var n,o,u,h=l(f);function f(){var e;r(this,f);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=h.call.apply(h,[this].concat(n))).options.hlsPlayback=t(t({},e.defaultOptions),e.options.hlsPlayback),e._setInitialState(),e}return n=f,u=[{key:"HLSJS",get:function(){return pt}}],(o=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(e){this._currentLevel=e,this.trigger(Te.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===Ge.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return vt()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var e=this._localStartTimeCorrelation,t=this._now-e.local,r=(e.remote+t)/1e3;return Math.min(r,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var e=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return e;var t=this._localEndTimeCorrelation,r=this._now-t.local,i=(t.remote+r)/1e3;return Math.max(e-this._extrapolatedWindowDuration,Math.min(i,e))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"currentTimestamp",get:function(){return this._currentFragment?(this._currentFragment.programDateTime+1e3*(this.el.currentTime-this._currentFragment.start))/1e3:null}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=Ge.VOD,this._lastTimeUpdate={current:0,total:0},this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestParsed=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var e=t({},this.options.playback.hlsjsConfig);this._hls=new pt(e)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var e=this;this._hls&&(this._hls.once(pt.Events.MEDIA_ATTACHED,(function(){e.options.hlsPlayback.preload&&e._hls.loadSource(e.options.src)})),this._hls.on(pt.Events.MANIFEST_PARSED,(function(){return e._manifestParsed=!0})),this._hls.on(pt.Events.LEVEL_LOADED,(function(t,r){return e._updatePlaybackType(t,r)})),this._hls.on(pt.Events.LEVEL_UPDATED,(function(t,r){return e._onLevelUpdated(t,r)})),this._hls.on(pt.Events.LEVEL_SWITCHING,(function(t,r){return e._onLevelSwitch(t,r)})),this._hls.on(pt.Events.FRAG_CHANGED,(function(t,r){return e._onFragmentChanged(t,r)})),this._hls.on(pt.Events.FRAG_LOADED,(function(t,r){return e._onFragmentLoaded(t,r)})),this._hls.on(pt.Events.FRAG_PARSING_METADATA,(function(t,r){return e._onFragmentParsingMetadata(t,r)})),this._hls.on(pt.Events.ERROR,(function(t,r){return e._onHLSJSError(t,r)})),this._hls.on(pt.Events.SUBTITLE_TRACK_LOADED,(function(t,r){return e._onSubtitleLoaded(t,r)})),this._hls.on(pt.Events.SUBTITLE_TRACKS_UPDATED,(function(){return e._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName,i=t.once?"once":"on";r&&e._hls["".concat(i)](r,t.callback)}))}},{key:"unbindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName;r&&e._hls.off(r,t.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(e,t){this.trigger(Te.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:e,data:t})}},{key:"render",value:function(){return this._ready(),c(a(f.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(Te.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(e,t,r){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){ve.error("hlsjs: failed to recover",{evt:e,data:t}),r.level=Fe.Levels.FATAL;var i=this.createError(r);this.trigger(Te.PLAYBACK_ERROR,i),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError();else this._recoveredDecodingError=!0,this._hls.recoverMediaError()}},{key:"_setupSrc",value:function(e){}},{key:"_startTimeUpdateTimer",value:function(){var e=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){e._onDurationChange(),e._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(e){var t=e>0?this._duration*(e/100):this._duration;this.seek(t)}},{key:"seek",value:function(e){e<0&&(ve.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this._startTime,this.el.currentTime=e}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateDvr",value:function(e){this.trigger(Te.PLAYBACK_DVR,e),this.trigger(Te.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"_updateSettings",value:function(){this._playbackType===Ge.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(Te.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(e,t){var r,i={code:"".concat(t.type,"_").concat(t.details),description:"".concat(this.name," error: type: ").concat(t.type,", details: ").concat(t.details),raw:t};if(t.response&&(i.description+=", response: ".concat(JSON.stringify(t.response))),t.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,t.type){case pt.ErrorTypes.NETWORK_ERROR:switch(t.details){case pt.ErrorDetails.MANIFEST_LOAD_ERROR:case pt.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case pt.ErrorDetails.MANIFEST_PARSING_ERROR:case pt.ErrorDetails.LEVEL_LOAD_ERROR:case pt.ErrorDetails.LEVEL_LOAD_TIMEOUT:ve.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:t}),r=this.createError(i),this.trigger(Te.PLAYBACK_ERROR,r),this.stop();break;default:ve.warn("hlsjs: trying to recover from network error.",{evt:e,data:t}),i.level=Fe.Levels.WARN,this._hls.startLoad()}break;case pt.ErrorTypes.MEDIA_ERROR:ve.warn("hlsjs: trying to recover from media error.",{evt:e,data:t}),i.level=Fe.Levels.WARN,this._recover(e,t,i);break;default:ve.error("hlsjs: could not recover from error.",{evt:e,data:t}),r=this.createError(i),this.trigger(Te.PLAYBACK_ERROR,r),this.stop()}else ve.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:t}),r=this.createError(i),this.trigger(Te.PLAYBACK_ERROR,r),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(t))return ve.error("hlsjs: could not load decrypt key.",{evt:e,data:t}),r=this.createError(i),this.trigger(Te.PLAYBACK_ERROR,r),void this.stop();i.level=Fe.Levels.WARN,ve.warn("hlsjs: non-fatal error occurred",{evt:e,data:t})}}},{key:"_keyIsDenied",value:function(e){return e.type===pt.ErrorTypes.NETWORK_ERROR&&e.details===pt.ErrorDetails.KEY_LOAD_ERROR&&e.response&&e.response.code>=400}},{key:"_onTimeUpdate",value:function(){var e={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._lastTimeUpdate&&e.current===this._lastTimeUpdate.current&&e.total===this._lastTimeUpdate.total||(this._lastTimeUpdate=e,this.trigger(Te.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_onDurationChange",value:function(){var e=this.getDuration();this._lastDuration!==e&&(this._lastDuration=e,c(a(f.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(d(e),[{start:Math.max(0,this.el.buffered.start(r)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(r)-this._playableRegionStartTime)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.getDuration()};this.trigger(Te.PLAYBACK_PROGRESS,i,e)}}},{key:"load",value:function(e){this._stopTimeUpdateTimer(),this.options.src=e,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestParsed&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),c(a(f.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(this.el.pause(),this.dvrEnabled&&this._updateDvr(!0))}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&c(a(f.prototype),"stop",this).call(this),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),c(a(f.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(e,t){this._playbackType=t.details.live?Ge.LIVE:Ge.VOD,this._onLevelUpdated(e,t),this._ccTracksUpdated&&this._playbackType===Ge.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map((function(e,t){return{id:t,level:e,label:"".concat(e.bitrate/1e3,"Kbps")}})),this.trigger(Te.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,t){this._segmentTargetDuration=t.details.targetduration,this._playlistType=t.details.type||null;var r=!1,i=!1,n=t.details.fragments,a=this._playableRegionStartTime,s=this._playableRegionDuration;if(0!==n.length){if(n[0].rawProgramDateTime&&(this._programDateTime=n[0].rawProgramDateTime),this._playableRegionStartTime!==n[0].start&&(r=!0,this._playableRegionStartTime=n[0].start),r)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,u=(o.remote+l)/1e3;u<n[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*n[0].start}:u>a+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(n[0].start,a+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(n[0].start+this._extrapolatedWindowDuration/2)};var c=t.details.totalduration;if(this._playbackType===Ge.LIVE){var d=t.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||pt.DefaultConfig.liveSyncDurationCount);d<=c?(c-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}c!==this._playableRegionDuration&&(i=!0,this._playableRegionDuration=c);var h=n[0].start+c,f=a+s;if(h!==f)if(this._localEndTimeCorrelation){var g=this._localEndTimeCorrelation,p=this._now-g.local,v=(g.remote+p)/1e3;v>h?this._localEndTimeCorrelation={local:this._now,remote:1e3*h}:v<h-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(h-this._extrapolatedWindowDuration)}:v>f&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*h};i&&this._onDurationChange(),r&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(e,t){this._currentFragment=t.frag,this.trigger(Te.Custom.PLAYBACK_FRAGMENT_CHANGED,t)}},{key:"_onFragmentLoaded",value:function(e,t){this.trigger(Te.PLAYBACK_FRAGMENT_LOADED,t)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(Te.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===Ge.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,t){this.levels.length||this._fillLevels(),this.trigger(Te.PLAYBACK_LEVEL_SWITCH_END),this.trigger(Te.PLAYBACK_LEVEL_SWITCH,t);var r=this._hls.levels[t.level];r&&(this.highDefinition=r.height>=720||r.bitrate/1e3>=2e3,this.trigger(Te.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(Te.PLAYBACK_BITRATE,{height:r.height,width:r.width,bandwidth:r.bitrate,bitrate:r.bitrate,level:t.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Ge.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Ge.VOD||this.dvrEnabled}}])&&i(n.prototype,o),u&&i(n,u),Object.defineProperty(n,"prototype",{writable:!1}),f}(at);return yt.canPlay=function(e,t){var r=e.split("?")[0].match(/.*\.(.*)$/)||[],i=r.length>1&&"m3u8"===r[1].toLowerCase()||mt(t,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!pt.isSupported()||!i)},yt}();
|
|
85
281
|
//# sourceMappingURL=hlsjs-playback.min.js.map
|