@hippovideo/video-sdk 0.0.46-beta.13 → 0.0.46-beta.14
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/app/{107-bundle-hippo-b0cjjxe24ts-3fad86f11646f0cd2296.js → 107-bundle-hippo-o40miwj3h8-3fad86f11646f0cd2296.js} +0 -0
- package/app/{157-bundle-hippo-b0cjjxe24ts-2b5878b0c6ae9352890b.js → 157-bundle-hippo-o40miwj3h8-2b5878b0c6ae9352890b.js} +0 -0
- package/app/{238-bundle-hippo-b0cjjxe24ts-b61acbf599b47f15e1ff.js → 238-bundle-hippo-o40miwj3h8-b61acbf599b47f15e1ff.js} +0 -0
- package/app/{239-bundle-hippo-b0cjjxe24ts-29765f212c5b82b9b5c9.js → 239-bundle-hippo-o40miwj3h8-29765f212c5b82b9b5c9.js} +0 -0
- package/app/245-bundle-hippo-o40miwj3h8-5a68c37cc467a075f1be.js +2 -0
- package/app/245-bundle-hippo-o40miwj3h8-5a68c37cc467a075f1be.js.LICENSE.txt +125 -0
- package/app/283-bundle-hippo-o40miwj3h8-b4f1175f62dfea10463f.js +1 -0
- package/app/{307-bundle-hippo-b0cjjxe24ts-46ceaa5b69d013f1a160.js → 307-bundle-hippo-o40miwj3h8-46ceaa5b69d013f1a160.js} +0 -0
- package/app/362-bundle-hippo-o40miwj3h8-221f4dfcb02832d2ec09.js +1 -0
- package/app/{37-bundle-hippo-b0cjjxe24ts-6b69a1ea0738281150c0.js → 37-bundle-hippo-o40miwj3h8-6b69a1ea0738281150c0.js} +0 -0
- package/app/{442-bundle-hippo-b0cjjxe24ts-a40760aafd35feb385c9.js → 442-bundle-hippo-o40miwj3h8-a40760aafd35feb385c9.js} +0 -0
- package/app/{454-bundle-hippo-b0cjjxe24ts-640863e104cb8d4444b5.js → 454-bundle-hippo-o40miwj3h8-640863e104cb8d4444b5.js} +0 -0
- package/app/{487-bundle-hippo-b0cjjxe24ts-a8a4683af31cd239bdfa.js → 487-bundle-hippo-o40miwj3h8-a8a4683af31cd239bdfa.js} +0 -0
- package/app/520-bundle-hippo-o40miwj3h8-2e9576ca9db90de362a4.js +2 -0
- package/app/520-bundle-hippo-o40miwj3h8-2e9576ca9db90de362a4.js.LICENSE.txt +19 -0
- package/app/{525-bundle-hippo-b0cjjxe24ts-9e22fb533f478807c968.js → 525-bundle-hippo-o40miwj3h8-9e22fb533f478807c968.js} +0 -0
- package/app/{528-bundle-hippo-b0cjjxe24ts-e7c6879087f0bc809436.js → 528-bundle-hippo-o40miwj3h8-e7c6879087f0bc809436.js} +0 -0
- package/app/{582-bundle-hippo-b0cjjxe24ts-a9eac0a0dff2505acd77.js → 582-bundle-hippo-o40miwj3h8-a9eac0a0dff2505acd77.js} +0 -0
- package/app/{605-bundle-hippo-b0cjjxe24ts-3d6e46646daa3d9ffc77.js → 605-bundle-hippo-o40miwj3h8-3d6e46646daa3d9ffc77.js} +0 -0
- package/app/{611-bundle-hippo-b0cjjxe24ts-f7d2a84b0b194f07a962.js → 611-bundle-hippo-o40miwj3h8-f7d2a84b0b194f07a962.js} +0 -0
- package/app/{652-bundle-hippo-b0cjjxe24ts-2446a2200548df5c62f3.js → 652-bundle-hippo-o40miwj3h8-2446a2200548df5c62f3.js} +0 -0
- package/app/{66-bundle-hippo-b0cjjxe24ts-d26ab7f3718ca8adb7b9.js → 66-bundle-hippo-o40miwj3h8-d26ab7f3718ca8adb7b9.js} +0 -0
- package/app/{660-bundle-hippo-b0cjjxe24ts-e4d99213565d245f92b3.js → 660-bundle-hippo-o40miwj3h8-e4d99213565d245f92b3.js} +0 -0
- package/app/{692-bundle-hippo-b0cjjxe24ts-98e2778801517c6d709f.js → 692-bundle-hippo-o40miwj3h8-98e2778801517c6d709f.js} +0 -0
- package/app/{751-bundle-hippo-b0cjjxe24ts-d3e1ee01d1e1f8c54119.js → 751-bundle-hippo-o40miwj3h8-d3e1ee01d1e1f8c54119.js} +0 -0
- package/app/{771-bundle-hippo-b0cjjxe24ts-5a6062e3490ee9261b7e.js → 771-bundle-hippo-o40miwj3h8-5a6062e3490ee9261b7e.js} +0 -0
- package/app/{780-bundle-hippo-b0cjjxe24ts-4e7a932e3d7564dbfd08.js → 780-bundle-hippo-o40miwj3h8-4e7a932e3d7564dbfd08.js} +0 -0
- package/app/{795-bundle-hippo-b0cjjxe24ts-fa5dee47c4eb61932834.js → 795-bundle-hippo-o40miwj3h8-fa5dee47c4eb61932834.js} +0 -0
- package/app/{823-bundle-hippo-b0cjjxe24ts-2b0bbd0da340d8be2937.js → 823-bundle-hippo-o40miwj3h8-2b0bbd0da340d8be2937.js} +0 -0
- package/app/{847-bundle-hippo-b0cjjxe24ts-a7274fcf2651c06dc9cc.js → 847-bundle-hippo-o40miwj3h8-a7274fcf2651c06dc9cc.js} +0 -0
- package/app/{85-bundle-hippo-b0cjjxe24ts-cee943b1271f7f21df76.js → 85-bundle-hippo-o40miwj3h8-cee943b1271f7f21df76.js} +0 -0
- package/app/{869-bundle-hippo-b0cjjxe24ts-ba44b48c8f4a26fe0e40.js → 869-bundle-hippo-o40miwj3h8-ba44b48c8f4a26fe0e40.js} +0 -0
- package/app/881-bundle-hippo-o40miwj3h8-1e41c84326fac8446b66.js +1 -0
- package/app/{892-bundle-hippo-b0cjjxe24ts-6dc5a8967bfd8695b74a.js → 892-bundle-hippo-o40miwj3h8-6dc5a8967bfd8695b74a.js} +0 -0
- package/app/{907-bundle-hippo-b0cjjxe24ts-6b974d5b2e5cef32804d.js → 907-bundle-hippo-o40miwj3h8-6b974d5b2e5cef32804d.js} +0 -0
- package/app/963-bundle-hippo-o40miwj3h8-26bd9b29dc1838602c06.js +1 -0
- package/app/99-bundle-hippo-o40miwj3h8-e04c3e7b0d7ef56bfaba.js +1 -0
- package/app/hv_recorder.css +1 -519
- package/app/hv_recorder.js +2 -261
- package/app/hv_recorder.js.LICENSE.txt +278 -0
- package/app/webpack-common-manifest.json +35 -35
- package/package.json +1 -1
- package/app/245-bundle-hippo-b0cjjxe24ts-6ecd1062435f49a5eee2.js +0 -84
- package/app/283-bundle-hippo-b0cjjxe24ts-6c2a63f94d1ea9993d1e.js +0 -1
- package/app/362-bundle-hippo-b0cjjxe24ts-1595fb7dfc3604d62d16.js +0 -1
- package/app/520-bundle-hippo-b0cjjxe24ts-459fa808a9c12b5121b8.js +0 -19
- package/app/881-bundle-hippo-b0cjjxe24ts-3cac5a046f018bd7f1b6.js +0 -1
- package/app/963-bundle-hippo-b0cjjxe24ts-83dc1213ffa628d8df02.js +0 -1
- package/app/99-bundle-hippo-b0cjjxe24ts-9185970d06a658303a29.js +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
(self.webpackChunkHVRecorder=self.webpackChunkHVRecorder||[]).push([[245],{11373:function(e){var t;"undefined"!=typeof window&&(t=function(){return r={"./node_modules/eventemitter3/index.js":
|
|
2
|
-
/*!*********************************************!*\
|
|
3
|
-
!*** ./node_modules/eventemitter3/index.js ***!
|
|
4
|
-
\*********************************************/
|
|
5
|
-
/*! no static exports found */
|
|
6
|
-
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,f="~";function a(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new n(r,i||e,a),i=f?f+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function o(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(f=!1)),o.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(f?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},o.prototype.listeners=function(e){var e=f?f+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,a=new Array(i);r<i;r++)a[r]=t[r].fn;return a},o.prototype.listenerCount=function(e){e=f?f+e:e,e=this._events[e];return e?e.fn?1:e.length:0},o.prototype.emit=function(e,t,r,i,a,n){var s=f?f+e:e;if(!this._events[s])return!1;var o,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,a),!0;case 6:return l.fn.call(l.context,t,r,i,a,n),!0}for(h=1,o=new Array(d-1);h<d;h++)o[h-1]=arguments[h];l.fn.apply(l.context,o)}else for(var u,c=l.length,h=0;h<c;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),d){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,t);break;case 3:l[h].fn.call(l[h].context,t,r);break;case 4:l[h].fn.call(l[h].context,t,r,i);break;default:if(!o)for(u=1,o=new Array(d-1);u<d;u++)o[u-1]=arguments[u];l[h].fn.apply(l[h].context,o)}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,r,i){e=f?f+e:e;if(this._events[e])if(t){var a=this._events[e];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||l(this,e);else{for(var n=0,s=[],o=a.length;n<o;n++)(a[n].fn!==t||i&&!a[n].once||r&&a[n].context!==r)&&s.push(a[n]);s.length?this._events[e]=1===s.length?s[0]:s:l(this,e)}}else l(this,e);return this},o.prototype.removeAllListeners=function(e){return e?(e=f?f+e:e,this._events[e]&&l(this,e)):(this._events=new a,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=f,e.exports=o.EventEmitter=o},"./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)return i.path=o.normalizePath(i.path),o.buildURLFromParts(i);throw new Error("Error trying to parse base URL.")}i=o.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=o.normalizePath(i.path),o.buildURLFromParts(i)):t;t=o.parseURL(e);if(!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=n.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var a,e={scheme:t.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(e.netLoc=t.netLoc,"/"!==i.path[0]&&(i.path?(a=(a=t.path).substring(0,a.lastIndexOf("/")+1)+i.path,e.path=o.normalizePath(a)):(e.path=t.path,i.params||(e.params=t.params,i.query)||(e.query=t.query)))),null===e.path&&(e.path=r.alwaysNormalize?o.normalizePath(i.path):i.path),o.buildURLFromParts(e)},parseURL:function(e){e=i.exec(e);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[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":
|
|
12
|
-
/*!**************************************************!*\
|
|
13
|
-
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
14
|
-
\**************************************************/
|
|
15
|
-
/*! no static exports found */
|
|
16
|
-
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,c){function n(r){var i={};function a(e){var t;return(i[e]||(t=i[e]={i:e,l:!1,exports:{}},r[e].call(t.exports,t,t.exports,a),t.l=!0,t)).exports}a.m=r,a.c=i,a.i=function(e){return e},a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},a.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/",a.oe=function(e){throw console.error(e),e};var e=a(a.s=ENTRY_MODULE);return e.default||e}var h="[\\.|\\-|\\+|\\w|/|@]+",f="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+h+").*?\\)";function g(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function p(e,t,r){var i={},a=(i[r]=[],t.toString()),t=a.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(t){for(var n,t=t[1],s=new RegExp("(\\\\n|\\W)"+g(t)+f,"g");n=s.exec(a);)"dll-reference"!==n[3]&&i[r].push(n[3]);for(s=new RegExp("\\("+g(t)+'\\("(dll-reference\\s('+h+'))"\\)\\)'+f,"g");n=s.exec(a);)e[n[2]]||(i[r].push(n[1]),e[n[2]]=c(n[1]).m),i[n[2]]=i[n[2]]||[],i[n[2]].push(n[4]);for(var o,l=Object.keys(i),d=0;d<l.length;d++)for(var u=0;u<i[l[d]].length;u++)o=i[l[d]][u],isNaN(+o)||(i[l[d]][u]=+i[l[d]][u])}return i}function s(e,t){for(var r={main:[t]},i={main:[]},a={main:{}};function(r){return Object.keys(r).reduce(function(e,t){return e||0<r[t].length},!1)}(r);)for(var n=Object.keys(r),s=0;s<n.length;s++){var o=n[s],l=r[o].pop();if(a[o]=a[o]||{},!a[o][l]&&e[o][l]){a[o][l]=!0,i[o]=i[o]||[],i[o].push(l);for(var d=p(e,e[o][l],o),u=Object.keys(d),c=0;c<u.length;c++)r[u[c]]=r[u[c]]||[],r[u[c]]=r[u[c]].concat(d[u[c]])}}return i}e.exports=function(e,t){var r={main:c.m},i=(t=t||{}).all?{main:Object.keys(r.main)}:s(r,e),a="",e=(Object.keys(i).filter(function(e){return"main"!==e}).forEach(function(t){for(var e=0;i[t][e];)e++;i[t].push(e),r[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+t+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i[t].map(function(e){return JSON.stringify(e)+": "+r[t][e].toString()}).join(",")+"});\n"}),a=a+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i.main.map(function(e){return JSON.stringify(e)+": "+r.main[e].toString()}).join(",")+"}))(self);",new window.Blob([a],{type:"text/javascript"}));return t.bare||(t=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(e),(e=new window.Worker(t)).objectURL=t),e}},"./src/crypt/decrypter.js":
|
|
17
|
-
/*!********************************************!*\
|
|
18
|
-
!*** ./src/crypt/decrypter.js + 3 modules ***!
|
|
19
|
-
\********************************************/
|
|
20
|
-
/*! exports provided: default */
|
|
21
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/hls.ts */
|
|
22
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/hls.ts */
|
|
23
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/hls.ts */
|
|
24
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.ts */function(e,t,r){"use strict";r.r(t);var o=function(){function e(e,t){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}(),l=function(){function e(e,t){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}();var d=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.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(){for(var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],r=this.invSubMix,o=r[0],l=r[1],d=r[2],u=r[3],c=new Uint32Array(256),h=0,f=0,g=0,g=0;g<256;g++)c[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=f^f<<1^f<<2^f<<3^f<<4,m=(e[h]=p=p>>>8^255&p^99,c[t[p]=h]),v=c[m],y=c[v],E=257*c[p]^16843008*p;i[h]=E<<24|E>>>8,a[h]=E<<16|E>>>16,n[h]=E<<8|E>>>24,s[h]=E,o[p]=(E=16843009*y^65537*v^257*m^16843008*h)<<24|E>>>8,l[p]=E<<16|E>>>16,d[p]=E<<8|E>>>24,u[p]=E,h?(h=m^c[c[c[y^m]]],f^=c[c[f]]):h=f=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 a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);for(var n,s,o,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),u=this.invKeySchedule=new Uint32Array(l),c=this.sBox,h=this.rcon,e=this.invSubMix,f=e[0],g=e[1],p=e[2],m=e[3],v=0;v<l;v++)v<a?s=d[v]=t[v]:(o=s,v%a==0?(o=c[(o=o<<8|o>>>24)>>>24]<<24|c[o>>>16&255]<<16|c[o>>>8&255]<<8|c[255&o],o^=h[v/a|0]<<24):6<a&&v%a==4&&(o=c[o>>>24]<<24|c[o>>>16&255]<<16|c[o>>>8&255]<<8|c[255&o]),d[v]=s=(d[v-a]^o)>>>0);for(n=0;n<l;n++)v=l-n,o=3&n?d[v]:d[v-4],u[n]=n<4||v<=4?o:f[c[o>>>24]]^g[c[o>>>16&255]]^p[c[o>>>8&255]]^m[c[255&o]],u[n]=u[n]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r,i){for(var a,n,s,o,l,d,u,c,h,f,g,p,m,v,y=this.keySize+6,E=this.invKeySchedule,T=this.invSBox,S=this.invSubMix,b=S[0],_=S[1],A=S[2],R=S[3],S=this.uint8ArrayToUint32Array_(r),w=S[0],D=S[1],L=S[2],k=S[3],C=new Int32Array(e),O=new Int32Array(C.length),I=this.networkToHostOrderSwap;t<C.length;){for(h=I(C[t]),f=I(C[t+1]),g=I(C[t+2]),p=I(C[t+3]),l=h^E[0],d=p^E[1],u=g^E[2],c=f^E[3],m=4,v=1;v<y;v++)a=b[l>>>24]^_[d>>16&255]^A[u>>8&255]^R[255&c]^E[m],n=b[d>>>24]^_[u>>16&255]^A[c>>8&255]^R[255&l]^E[m+1],s=b[u>>>24]^_[c>>16&255]^A[l>>8&255]^R[255&d]^E[m+2],o=b[c>>>24]^_[l>>16&255]^A[d>>8&255]^R[255&u]^E[m+3],l=a,d=n,u=s,c=o,m+=4;a=T[l>>>24]<<24^T[d>>16&255]<<16^T[u>>8&255]<<8^T[255&c]^E[m],n=T[d>>>24]<<24^T[u>>16&255]<<16^T[c>>8&255]<<8^T[255&l]^E[m+1],s=T[u>>>24]<<24^T[c>>16&255]<<16^T[l>>8&255]<<8^T[255&d]^E[m+2],o=T[c>>>24]<<24^T[l>>16&255]<<16^T[d>>8&255]<<8^T[255&u]^E[m+3],m+=3,O[t]=I(a^w),O[t+1]=I(o^D),O[t+2]=I(s^L),O[t+3]=I(n^k),w=h,D=f,L=g,k=p,t+=4}return i?(r=O.buffer,S=r.byteLength,(e=S&&new DataView(r).getUint8(S-1))?r.slice(0,S-e):r):O.buffer},t.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},e}(),n=r("./src/errors.ts"),u=r("./src/utils/logger.js"),s=r("./src/events.js"),r=r("./src/utils/get-self-scope.js"),a=Object(r.getSelfScope)(),r=function(){function e(e,t,r){r=(void 0===r?{}:r).removePKCS7Padding,r=void 0===r||r;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=r)try{var i=a.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}var t=e.prototype;return t.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.decrypt=function(t,r,i,a){var e,n,s=this;this.disableWebCrypto&&this.config.enableSoftwareAES?(this.logEnabled&&(u.logger.log("JS AES decrypt"),this.logEnabled=!1),(e=this.decryptor)||(this.decryptor=e=new d),e.expandKey(r),a(e.decrypt(t,0,i,this.removePKCS7Padding))):(this.logEnabled&&(u.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1),n=this.subtle,this.key!==r&&(this.key=r,this.fastAesKey=new l(n,r)),this.fastAesKey.expandKey().then(function(e){new o(n,i).decrypt(t,e).catch(function(e){s.onWebCryptoError(e,t,r,i,a)}).then(function(e){a(e)})}).catch(function(e){s.onWebCryptoError(e,t,r,i,a)}))},t.onWebCryptoError=function(e,t,r,i,a){this.config.enableSoftwareAES?(u.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,i,a)):(u.logger.error("decrypting error : "+e.message),this.observer.trigger(s.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},t.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},e}();t.default=r},"./src/demux/demuxer-inline.js":
|
|
25
|
-
/*!**************************************************!*\
|
|
26
|
-
!*** ./src/demux/demuxer-inline.js + 12 modules ***!
|
|
27
|
-
\**************************************************/
|
|
28
|
-
/*! exports provided: default */
|
|
29
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/hls.ts */
|
|
30
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/hls.ts */
|
|
31
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/hls.ts */
|
|
32
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/hls.ts */
|
|
33
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/hls.ts */
|
|
34
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number.js because of ./src/hls.ts */
|
|
35
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/hls.ts */
|
|
36
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.ts */function(f,e,t){"use strict";t.r(e);var H=t("./src/events.js"),V=t("./src/errors.ts"),p=t("./src/crypt/decrypter.js"),g=t("./src/polyfills/number.js"),Y=t("./src/utils/logger.js"),r=t("./src/utils/get-self-scope.js");function a(e,t){return 255===e[t]&&240==(246&e[t+1])}function o(e,t){return 1&e[t+1]?7:9}function l(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function m(e,t){return!!(t+1<e.length&&a(e,t))}function v(e,t,r,i,a){e.samplerate||(t=function(e,t,r,i){var a,n,s=navigator.userAgent.toLowerCase(),o=i,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],d=1+((192&t[r+2])>>>6),u=(60&t[r+2])>>>2;if(!(l.length-1<u))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,Y.logger.log("manifest codec:"+i+",ADTS data:type:"+d+",sampleingIndex:"+u+"["+l[u]+"Hz],channelConfig:"+a),t=/firefox/i.test(s)?6<=u?(d=5,n=new Array(4),u-3):(d=2,n=new Array(2),u):-1!==s.indexOf("android")?(d=2,n=new Array(2),u):(d=5,n=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=u?u-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=u&&1==a||/vivaldi/i.test(s))||!i&&1==a)&&(d=2,n=new Array(2)),u)),n[0]=d<<3,n[0]|=(14&u)>>1,n[1]|=(1&u)<<7,n[1]|=a<<3,5===d&&(n[1]|=(14&t)>>1,n[2]=(1&t)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:l[u],channelCount:a,codec:"mp4a.40."+d,manifestCodec:o};e.trigger(H.default.ERROR,{type:V.ErrorTypes.MEDIA_ERROR,details:V.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+u})}(t,r,i,a),e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,Y.logger.log("parsed codec:"+e.codec+",rate:"+t.samplerate+",nb channel:"+t.channelCount))}function h(e){return 9216e4/e}function y(e,t,r,i,a){var n,i=function(e,t,r,i,a){var n=e.length,s=o(e,t),e=l(e,t);if(0<(e-=s)&&t+s+e<=n)return{headerLength:s,frameLength:e,stamp:r+i*a}}(t,r,i,a,h(e.samplerate));if(i)return a=i.stamp,n=i.headerLength,i=i.frameLength,t={unit:t.subarray(r+n,r+n+i),pts:a,dts:a},e.samples.push(t),{sample:t,length:i+n}}var R=t("./src/demux/id3.js"),S=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)for(var t=(R.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(function(e,t){if(m(e,t)){var r=o(e,t);if(t+r>=e.length)return;var i=l(e,t);if(i<=r)return;r=t+i;if(r===e.length||r+1<e.length&&a(e,r))return 1}}(e,t))return Y.logger.log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,r,i){for(var a=this._audioTrack,n=R.default.getID3Data(e,0)||[],s=R.default.getTimeStamp(n),o=Object(g.isFiniteNumber)(s)?90*s:9e4*t,l=0,d=o,u=e.length,c=n.length,h=[{pts:d,dts:d,data:n}];c<u-1;)if(m(e,c)&&c+5<u){v(a,this.observer,e,c,a.manifestCodec);var f=y(a,e,c,o,l);if(!f){Y.logger.log("Unable to parse AAC frame");break}c+=f.length,d=f.sample.pts,l++}else R.default.isHeader(e,c)?(n=R.default.getID3Data(e,c),h.push({pts:d,dts:d,data:n}),c+=n.length):c++;this.remuxer.remux(a,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),b=t("./src/demux/mp4demuxer.js"),d={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,a){var n;return!(r+24>t.length)&&(n=this.parseHeader(t,r))&&r+n.frameLength<=t.length?(i=i+a*(9e4*n.samplesPerFrame/n.sampleRate),a={unit:t.subarray(r,r+n.frameLength),pts:i,dts:i},e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(a),{sample:a,length:n.frameLength}):void 0},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!=r&&0!=a&&15!=a&&3!=n)return a=1e3*d.BitratesMap[14*(3==r?3-i:3==i?3:4)+a-1],n=d.SamplingRateMap[3*(3==r?0:2==r?1:2)+n],e=e[t+3]>>6==3?1:2,i=8*(t=d.SamplesCoefficients[r][i])*(r=d.BytesInSlot[i]),{sampleRate:n,channelCount:e,frameLength:parseInt(t*a/n+s,10)*r,samplesPerFrame:i}},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,t=t+(i=r&&r.frameLength?r.frameLength:i);if(t===e.length||t+1<e.length&&this.isHeaderPattern(e,t))return!0}return!1}},E=d,w=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),t=Math.min(4,t);if(0===t)throw new Error("no bytes available");i.set(e.subarray(r,r+t)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*t,this.bytesAvailable-=t},t.skipBits=function(e){var t;this.bitsAvailable>e||(e=(e-=this.bitsAvailable)-((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 32<e&&Y.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable?this.word<<=t:0<this.bytesAvailable&&this.loadWord(),0<(t=e-t)&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){for(var 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++)t=0===(r=0!==r?(t+this.readEG()+256)%256:r)?t:r},t.readSPS=function(){var e,t,r,i=0,a=0,n=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),d=this.readUEG.bind(this),u=this.readBoolean.bind(this),c=this.skipBits.bind(this),h=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);if(o(),p=o(),l(5),c(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var p=d();if(3===p&&c(1),f(),f(),c(1),u())for(t=3!==p?8:12,r=0;r<t;r++)u()&&g(r<6?16:64)}f();var p=d();if(0===p)d();else if(1===p)for(c(1),h(),h(),e=d(),r=0;r<e;r++)h();f(),c(1),p=d(),f=d(),0===(l=l(1))&&c(1),c(1),u()&&(i=d(),a=d(),n=d(),s=d());var m=[1,1];if(u()&&u())switch(o()){case 1:m=[1,1];break;case 2:m=[12,11];break;case 3:m=[10,11];break;case 4:m=[16,11];break;case 5:m=[40,33];break;case 6:m=[24,11];break;case 7:m=[20,11];break;case 8:m=[32,11];break;case 9:m=[80,33];break;case 10:m=[18,11];break;case 11:m=[15,11];break;case 12:m=[64,33];break;case 13:m=[160,99];break;case 14:m=[4,3];break;case 15:m=[3,2];break;case 16:m=[2,1];break;case 255:m=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(p+1)-2*i-2*a),height:(2-l)*(f+1)*16-(l?2:4)*(n+s),pixelRatio:m}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),i=function(){function e(e,t,r,i){this.decryptdata=r,this.discardEPB=i,this.decrypter=new p.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(t,r,i,a){var n=t[r].unit,e=n.subarray(16,n.length-n.length%16),e=e.buffer.slice(e.byteOffset,e.byteOffset+e.length),s=this;this.decryptBuffer(e,function(e){e=new Uint8Array(e),n.set(e,16),a||s.decryptAacSamples(t,r+1,i)})},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,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+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(t,r,i,a,n,s){var o=this.discardEPB(n.data),e=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(e.buffer,function(e){n.data=l.getAvcDecryptedUnit(o,e),s||l.decryptAvcSamples(t,r,i+1,a)})},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),n={video:1,audio:2,id3:3,text:4},_=function(){function O(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null,this.pmtUnknownTypes={}}var e=O.prototype;return e.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new i(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},O.probe=function(e){e=O._syncOffset(e);return!(e<0||(e&&Y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?"),0))},O._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},O.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:n[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}},e.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this.pmtUnknownTypes={},this._avcTrack=O.createTrack("video",i),this._audioTrack=O.createTrack("audio",i),this._id3Track=O.createTrack("id3",i),this._txtTrack=O.createTrack("text",i),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},e.resetTimeStamp=function(){},e.append=function(e,t,r,i){var a,n,s,o,l,d=e.length,u=!1,c=(this.pmtUnknownTypes={},this.contiguous=r,this.pmtParsed),h=this._avcTrack,f=this._audioTrack,g=this._id3Track,p=h.pid,m=f.pid,v=g.pid,y=this._pmtId,E=h.pesData,T=f.pesData,S=g.pesData,b=this._parsePAT,_=this._parsePMT.bind(this),A=this._parsePES,R=this._parseAVCPES.bind(this),w=this._parseAACPES.bind(this),D=this._parseMPEGPES.bind(this),L=this._parseID3PES.bind(this),k=O._syncOffset(e);for(d-=(d+k)%188,a=k;a<d;a+=188)if(71===e[a]){if(n=!!(64&e[a+1]),s=((31&e[a+1])<<8)+e[a+2],1<(48&e[a+3])>>4){if((o=a+5+e[a+4])===a+188)continue}else o=a+4;switch(s){case p:n&&(E&&(l=A(E))&&R(l,!1),E={data:[],size:0}),E&&(E.data.push(e.subarray(o,a+188)),E.size+=a+188-o);break;case m:n&&(T&&(l=A(T))&&(f.isAAC?w:D)(l),T={data:[],size:0}),T&&(T.data.push(e.subarray(o,a+188)),T.size+=a+188-o);break;case v:n&&(S&&(l=A(S))&&L(l),S={data:[],size:0}),S&&(S.data.push(e.subarray(o,a+188)),S.size+=a+188-o);break;case 0:n&&(o+=e[o]+1),y=this._pmtId=b(e,o);break;case y:n&&(o+=e[o]+1);var C=_(e,o,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(p=C.avc)&&(h.pid=p),0<(m=C.audio)&&(f.pid=m,f.isAAC=C.isAAC),0<(v=C.id3)&&(g.pid=v),u&&!c&&(Y.logger.log("reparse from beginning"),u=!1,a=k-188),c=this.pmtParsed=!0;break;case 17:case 8191:break;default:u=!0}}else this.observer.trigger(H.default.ERROR,{type:V.ErrorTypes.MEDIA_ERROR,details:V.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E&&(l=A(E))?(R(l,!0),h.pesData=null):h.pesData=E,T&&(l=A(T))?((f.isAAC?w:D)(l),f.pesData=null):(T&&T.size&&Y.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=T),S&&(l=A(S))?(L(l),g.pesData=null):g.pesData=S,null==this.sampleAes?this.remuxer.remux(f,h,g,this._txtTrack,t,r,i):this.decryptAndRemux(f,h,g,this._txtTrack,t,r,i)},e.decryptAndRemux=function(e,t,r,i,a,n,s){var o;e.samples&&e.isAAC?(o=this).sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}):this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},e.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){var o;t.samples?(o=this).sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,i,a,n,s)}):this.remuxer.remux(e,t,r,i,a,n,s)},e.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e._trackUnknownPmt=function(e,t,r){var i=this.pmtUnknownTypes[e]||0;return 0===i&&(this.pmtUnknownTypes[e]=0,t.call(Y.logger,r)),this.pmtUnknownTypes[e]++,i},e._parsePMT=function(e,t,r,i){var a,n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){switch(a=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!i){this._trackUnknownPmt(e[t],Y.logger.warn,"ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=a);break;case 21:-1===n.id3&&(n.id3=a);break;case 219:if(!i){this._trackUnknownPmt(e[t],Y.logger.warn,"H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=a);break;case 3:case 4:r?-1===n.audio&&(n.audio=a,n.isAAC=!1):this._trackUnknownPmt(e[t],Y.logger.warn,"MPEG audio found, not supported in this browser");break;case 36:this._trackUnknownPmt(e[t],Y.logger.warn,"Unsupported HEVC stream type found");break;default:this._trackUnknownPmt(e[t],Y.logger.log,"Unknown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return n},e._parsePES=function(e){var t,r,i,a,n,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&1<o.length;){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!==((h=o[0])[0]<<16)+(h[1]<<8)+h[2])return null;if((t=(h[4]<<8)+h[5])&&t>e.size-6)return null;if(192&(r=h[7])&&(i=536870912*(14&h[9])+4194304*(255&h[10])+16384*(254&h[11])+128*(255&h[12])+(254&h[13])/2,64&r?54e5<i-(a=536870912*(14&h[14])+4194304*(255&h[15])+16384*(254&h[16])+128*(255&h[17])+(254&h[18])/2)&&(Y.logger.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i),r=h[8],e.size<=(n=r+9))return null;e.size-=n;for(var d=new Uint8Array(e.size),u=0,c=o.length;u<c;u++){var h,f=(h=o[u]).byteLength;if(n){if(f<n){n-=f;continue}h=h.subarray(n),f-=n,n=0}d.set(h,s),s+=f}return t&&(t-=r+3),{data:d,pts:i,dts:a,len:t}},e.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 a=r[i-1];e.pts=a.pts,e.dts=a.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&Y.logger.log(e.pts+"/"+e.dts+":"+e.debug)},e._parseAVCPES=function(p,e){function m(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}}var v,y,E,T=this,S=this._avcTrack,t=this._parseAVCNALu(p.data),b=this.avcSample,_=!1,A=this.pushAccesUnit.bind(this);p.data=null,b&&t.length&&!S.audFound&&(A(b,S),b=this.avcSample=m(!1,p.pts,p.dts,"")),t.forEach(function(e){switch(e.type){case 1:y=!0,(b=b||(T.avcSample=m(!0,p.pts,p.dts,""))).frame=!0;var t=e.data;_&&4<t.length&&(2!==(t=new w(t).readSliceType())&&4!==t&&7!==t&&9!==t||(b.key=!0));break;case 5:y=!0,(b=b||(T.avcSample=m(!0,p.pts,p.dts,""))).key=!0,b.frame=!0;break;case 6:y=!0,(v=new w(T.discardEPB(e.data))).readUByte();for(var r=0,i=0,a=!1,n=0;!a&&1<v.bytesAvailable;){for(r=0;r+=n=v.readUByte(),255===n;);for(i=0;i+=n=v.readUByte(),255===n;);if(4===r&&0!==v.bytesAvailable){var a=!0,s=v.readUByte();if(181===s)if(49===v.readUShort()){s=v.readUInt();if(1195456820===s)if(3===v.readUByte()){var s=v.readUByte(),o=31&s,l=[s,v.readUByte()];for(E=0;E<o;E++)l.push(v.readUByte()),l.push(v.readUByte()),l.push(v.readUByte());T._insertSampleInOrder(T._txtTrack.samples,{type:3,pts:p.pts,bytes:l})}}}else if(5===r&&0!==v.bytesAvailable){if(a=!0,16<i){var d=[];for(E=0;E<16;E++)d.push(v.readUByte().toString(16)),3!==E&&5!==E&&7!==E&&9!==E||d.push("-");var u=i-16,c=new Uint8Array(u);for(E=0;E<u;E++)c[E]=v.readUByte();T._insertSampleInOrder(T._txtTrack.samples,{pts:p.pts,payloadType:r,uuid:d.join(""),userDataBytes:c,userData:Object(R.utf8ArrayToStr)(c.buffer)})}}else if(i<v.bytesAvailable)for(E=0;E<i;E++)v.readUByte()}break;case 7:if(_=y=!0,!S.sps){var t=(v=new w(e.data)).readSPS(),h=(S.width=t.width,S.height=t.height,S.pixelRatio=t.pixelRatio,S.sps=[e.data],S.duration=T._duration,e.data.subarray(1,4)),f="avc1.";for(E=0;E<3;E++){var g=h[E].toString(16);f+=g=g.length<2?"0"+g:g}S.codec=f}break;case 8:y=!0,S.pps||(S.pps=[e.data]);break;case 9:y=!1,S.audFound=!0,b&&A(b,S),b=T.avcSample=m(!1,p.pts,p.dts,"");break;case 12:y=!1;break;default:y=!1,b&&(b.debug+="unknown NAL "+e.type+" ")}b&&y&&b.units.push(e)}),e&&b&&(A(b,S),this.avcSample=null)},e._insertSampleInOrder=function(e,t){var r=e.length;if(0<r){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.pts<e[i].pts){e.splice(i,0,t);break}}else e.push(t)},e._getLastNalUnit=function(){var e,t,r=this.avcSample;return t=(r=r&&0!==r.units.length?r:(e=this._avcTrack.samples)[e.length-1])?(e=r.units)[e.length-1]:t},e._parseAVCNALu=function(e){var t,r,i,a,n,s=0,o=e.byteLength,l=this._avcTrack,d=g=l.naluState||0,u=[],c=-1;for(-1===g&&(i=31&e[c=0],g=0,s=1);s<o;){var h,f,g,p=e[s++];g?g=1===g?p?0:2:p?1===p?(0<=c?(r={data:e.subarray(c,s-g-1),type:i},u.push(r)):(h=this._getLastNalUnit())&&(d&&s<=4-d&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-d)),0<(t=s-g-1))&&((f=new Uint8Array(h.data.byteLength+t)).set(h.data,0),f.set(e.subarray(0,t),h.data.byteLength),h.data=f),s<o?(i=31&e[c=s],0):-1):0:3:g=p?0:1}return 0<=c&&0<=g&&(r={data:e.subarray(c,o),type:i,state:g},u.push(r)),0===u.length&&(a=this._getLastNalUnit())&&((n=new Uint8Array(a.data.byteLength+e.byteLength)).set(a.data,0),n.set(e,a.data.byteLength),a.data=n),l.naluState=g,u},e.discardEPB=function(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;for(var a=t-r.length,n=new Uint8Array(a),s=0,i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=e[s];return n},e._parseAACPES=function(e){var t,r,i,a,n=this._audioTrack,s=e.data,o=e.pts,e=this.aacOverFlow,l=this.aacLastPTS;for(e&&((u=new Uint8Array(e.byteLength+s.byteLength)).set(e,0),u.set(s,e.byteLength),s=u),r=0,a=s.length;r<a-1&&!m(s,r);r++);if(r){var d,u=r<a-1?(d="AAC PES did not start with ADTS header,offset:"+r,!1):(d="no ADTS header found in AAC PES",!0);if(Y.logger.warn("parsing error:"+d),this.observer.trigger(H.default.ERROR,{type:V.ErrorTypes.MEDIA_ERROR,details:V.ErrorDetails.FRAG_PARSING_ERROR,fatal:u,reason:d}),u)return}for(v(n,this.observer,s,r,this.audioCodec),t=0,d=h(n.samplerate),e&&l&&(u=l+d,1<Math.abs(u-o))&&(Y.logger.log("AAC: align PTS for overlapping frames by "+Math.round((u-o)/90)),o=u);r<a;){if(m(s,r)){if(r+5<a){var c=y(n,s,r,o,t);if(c){r+=c.length,i=c.sample.pts,t++;continue}}break}r++}e=r<a?s.subarray(r,a):null,this.aacOverFlow=e,this.aacLastPTS=i},e._parseMPEGPES=function(e){for(var t=e.data,r=t.length,i=0,a=0,n=e.pts;a<r;)if(E.isHeader(t,a)){var s=E.appendFrame(this._audioTrack,t,a,n,i);if(!s)break;a+=s.length,i++}else a++},e._parseID3PES=function(e){this._id3Track.samples.push(e)},O}(),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/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=R.default.getID3Data(e,0);if(i&&void 0!==R.default.getTimeStamp(i))for(t=i.length,r=Math.min(e.length-1,t+100);t<r;t++)if(E.probe(e,t))return Y.logger.log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,r,i){for(var a=R.default.getID3Data(e,0)||[],n=R.default.getTimeStamp(a),s=void 0!==n?90*n:9e4*t,o=a.length,l=e.length,d=0,u=0,c=this._audioTrack,h=[{pts:s,dts:s,data:a}];o<l;)if(E.isHeader(e,o)){var f=E.appendFrame(c,e,o,s,d);if(!f)break;o+=f.length,u=f.sample.pts,d++}else R.default.isHeader(e,o)?(a=R.default.getID3Data(e,o),h.push({pts:u,dts:u,data:a}),o+=a.length):o++;this.remuxer.remux(c,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),N=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])}return null},e}(),s=Math.pow(2,32)-1,W=function(){function c(){}return c.init=function(){for(var e in c.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:[]})c.types.hasOwnProperty(e)&&(c.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=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]),r=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]),t=(c.HDLR_TYPES={video:t,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(c.STTS=c.STSC=c.STCO=r,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);c.FTYP=c.box(c.types.ftyp,r,a,r,i),c.DINF=c.box(c.types.dinf,c.box(c.types.dref,t))},c.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),i=8,a=r.length,n=a;a--;)i+=r[a].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),a=0,i=8;a<n;a++)t.set(r[a],i),i+=r[a].byteLength;return t},c.hdlr=function(e){return c.box(c.types.hdlr,c.HDLR_TYPES[e])},c.mdat=function(e){return c.box(c.types.mdat,e)},c.mdhd=function(e,t){t*=e;var r=Math.floor(t/(1+s)),t=Math.floor(t%(1+s));return c.box(c.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},c.mdia=function(e){return c.box(c.types.mdia,c.mdhd(e.timescale,e.duration),c.hdlr(e.type),c.minf(e))},c.mfhd=function(e){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},c.minf=function(e){return"audio"===e.type?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(e)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(e))},c.moof=function(e,t,r){return c.box(c.types.moof,c.mfhd(e),c.traf(r,t))},c.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trak(e[t]);return c.box.apply(null,[c.types.moov,c.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(c.mvex(e)))},c.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trex(e[t]);return c.box.apply(null,[c.types.mvex].concat(r))},c.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+s)),t=Math.floor(t%(1+s)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,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 c.box(c.types.mvhd,e)},c.sdtp=function(e){for(var t,r=e.samples||[],i=new Uint8Array(4+r.length),a=0;a<r.length;a++)t=r[a].flags,i[a+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return c.box(c.types.sdtp,i)},c.stbl=function(e){return c.box(c.types.stbl,c.stsd(e),c.box(c.types.stts,c.STTS),c.box(c.types.stsc,c.STSC),c.box(c.types.stsz,c.STSZ),c.box(c.types.stco,c.STCO))},c.avc1=function(e){for(var t,r,i=[],a=[],n=0;n<e.sps.length;n++)r=(t=e.sps[n]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(n=0;n<e.pps.length;n++)r=(t=e.pps[n]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var s=c.box(c.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(a))),o=e.width,l=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return c.box(c.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,o>>8&255,255&o,l>>8&255,255&l,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]),s,c.box(c.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),c.box(c.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))},c.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]))},c.mp4a=function(e){var t=e.samplerate;return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),c.box(c.types.esds,c.esds(e)))},c.mp3=function(e){var t=e.samplerate;return c.box(c.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},c.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?c.box(c.types.stsd,c.STSD,c.mp4a(e)):c.box(c.types.stsd,c.STSD,c.mp3(e)):c.box(c.types.stsd,c.STSD,c.avc1(e))},c.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,a=Math.floor(r/(1+s)),r=Math.floor(r%(1+s));return c.box(c.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,r>>24,r>>16&255,r>>8&255,255&r,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,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))},c.traf=function(e,t){var r=c.sdtp(e),i=e.id,a=Math.floor(t/(1+s)),t=Math.floor(t%(1+s));return c.box(c.types.traf,c.box(c.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),c.box(c.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,t>>24,t>>16&255,t>>8&255,255&t])),c.trun(e,r.length+16+20+8+16+8+8),r)},c.trak=function(e){return e.duration=e.duration||4294967295,c.box(c.types.trak,c.tkhd(e),c.mdia(e))},c.trex=function(e){e=e.id;return c.box(c.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},c.trun=function(e,t){var r,i,a,n,s,o=e.samples||[],l=o.length,e=12+16*l,d=new Uint8Array(e);for(d.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<l;r++)i=(s=o[r]).duration,a=s.size,n=s.flags,s=s.cts,d.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return c.box(c.types.trun,d)},c.initSegment=function(e){c.types||c.init();var e=c.moov(e),t=new Uint8Array(c.FTYP.byteLength+e.byteLength);return t.set(c.FTYP),t.set(e,c.FTYP.byteLength),t},c}();function u(e,t,r,i){e=e*t*(r=void 0===r?1:r);return(i=void 0===i?!1:i)?Math.round(e):e}function q(e,t){return u(e,1e3,1/9e4,t=void 0===t?!1:t)}function c(e,t){return u(e,9e4,1/(t=void 0===t?1:t))}var U=c(10),J=c(.2),X=null;function z(e,t){var r;if(void 0!==t)for(r=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=r;return e}var T,D=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===X&&(e=navigator.userAgent.match(/Chrome\/(\d+)/i),X=e?parseInt(e[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 i=!1,e=e.reduce(function(e,t){var r=t.pts-e;return r<-4294967296?(i=!0,e):0<r?e:t.pts},e[0].pts);return i&&Y.logger.debug("PTS rollover detected"),e},t.remux=function(e,t,r,i,a,n,s){var o,l,d,u,c,h;this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated&&(h=e.samples.length,o=t.samples.length,d=l=a,h&&o&&(u=this.getVideoStartPts(t.samples),u=(e.samples[0].pts-u)/t.inputTimeScale,l+=Math.max(0,u),d+=Math.max(0,-u)),h?(e.timescale||(Y.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a)),u=this.remuxAudio(e,l,n,s),o&&(u&&(c=u.endPTS-u.startPTS),t.timescale||(Y.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,d,n,c))):o&&(h=this.remuxVideo(t,d,n,0,s))&&e.codec&&this.remuxEmptyAudio(e,l,n,h)),r.samples.length&&this.remuxID3(r,a),i.samples.length&&this.remuxText(i,a),this.observer.trigger(H.default.FRAG_PARSED)},t.generateIS=function(e,t,r){var i,a,n=this.observer,s=e.samples,o=t.samples,l=this.typeSupported,d="audio/mp4",u={},c={tracks:u},h=void 0===this._initPTS;h&&(a=i=1/0),e.config&&s.length&&(e.timescale=e.samplerate,Y.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(l.mpeg?(d="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3")),u.audio={container:d,codec:e.codec,initSegment:!e.isAAC&&l.mpeg?new Uint8Array:W.initSegment([e]),metadata:{channelCount:e.channelCount}},h)&&(a=i=s[0].pts-Math.round(e.inputTimeScale*r)),t.sps&&t.pps&&o.length?(d=t.inputTimeScale,t.timescale=d,u.video={container:"video/mp4",codec:t.codec,initSegment:W.initSegment([t]),metadata:{width:t.width,height:t.height}},h&&(l=this.getVideoStartPts(o),s=Math.round(d*r),i=Math.min(i,o[0].dts-s),a=Math.min(a,l-s),this.observer.trigger(H.default.INIT_PTS_FOUND,{initPTS:a}))):h&&u.audio&&this.observer.trigger(H.default.INIT_PTS_FOUND,{initPTS:a}),Object.keys(u).length?(n.trigger(H.default.FRAG_PARSING_INIT_SEGMENT,c),this.ISGenerated=!0,h&&(this._initPTS=a,this._initDTS=i)):n.trigger(H.default.ERROR,{type:V.ErrorTypes.MEDIA_ERROR,details:V.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,i){var a,n,s=e.timescale,o=e.samples,l=[],d=o.length,u=this._initPTS,c=8,h=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,g=0,p=!1,m=this.nextAvcDts;if(0!==d){r||(m=t*s-(o[0].pts-z(o[0].dts,o[0].pts)));for(var v=0;v<d;v++){var y=o[v];y.pts=z(y.pts-u,m),y.dts=z(y.dts-u,m),y.dts>y.pts&&(g=Math.max(Math.min(g,y.pts-y.dts),-1*J)),y.dts<o[0<v?v-1:v].dts&&(p=!0)}p&&o.sort(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id}),E=o[0].dts;var E,t=o[d-1].dts,T=Math.round((t-E)/(d-1));if(g<0){if(g<-2*T){Y.logger.warn("PTS < DTS detected in video samples, offsetting DTS to PTS "+q(-T,!0)+" ms");for(var S=0;S<d;S++)o[S].dts=o[S].pts-T}else{Y.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+q(g,!0)+" ms to overcome this issue");for(var b=0;b<d;b++)o[b].dts=o[b].dts+g}E=o[0].dts,t=o[d-1].dts}r&&((k=T<(r=E-m))||r<-1)&&(k?Y.logger.warn("AVC: "+q(r,!0)+" ms ("+r+"dts) hole between fragments detected, filling it"):Y.logger.warn("AVC: "+q(-r,!0)+" ms ("+r+"dts) overlapping between fragments detected"),E=m,k=o[0].pts-r,o[0].dts=E,o[0].pts=k,Y.logger.log("Video: First PTS/DTS adjusted: "+q(k,!0)+"/"+q(E,!0)+", delta: "+q(r,!0)+" ms")),X&&X<75&&(E=Math.max(0,E));for(var _=0,A=0,R=0;R<d;R++){for(var w=o[R],M=w.units,N=M.length,D=0,L=0;L<N;L++)D+=M[L].data.length;A+=D,_+=N,w.length=D,w.dts=Math.max(w.dts,E),w.pts=Math.max(w.pts,w.dts,0),h=Math.min(w.pts,h),f=Math.max(w.pts,f)}t=o[d-1].dts;var k=A+4*_+8;try{n=new Uint8Array(k)}catch(e){return void this.observer.trigger(H.default.ERROR,{type:V.ErrorTypes.MUX_ERROR,details:V.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:k,reason:"fail allocating video mdat "+k})}var U=new DataView(n.buffer);U.setUint32(0,k),n.set(W.types.mdat,4);for(var C=0;C<d;C++){for(var O,I,P=o[C],B=P.units,G=0,x=0,j=B.length;x<j;x++){var F=B[x],K=F.data,F=F.data.byteLength;U.setUint32(c,F),c+=4,n.set(K,c),c+=F,G+=4+F}C<d-1?a=o[C+1].dts-P.dts:(I=this.config,O=P.dts-o[0<C?C-1:C].dts,I.stretchShortVideoTrack&&(I=I.maxBufferHole,Math.floor(I*s)<(I=(i?h+i*s:this.nextAudioPts)-P.pts))?((a=I-O)<0&&(a=O),Y.logger.log("It is approximately "+q(I,!1)+" ms to the next segment; using duration "+q(a,!1)+" ms for the last video frame.")):a=O),I=Math.round(P.pts-P.dts),l.push({size:G,duration:a,cts:I,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:P.key?2:1,isNonSync:P.key?0:1}})}this.nextAvcDts=t+a;r=e.dropped,k=(e.nbNalu=0,e.dropped=0,l.length&&-1<navigator.userAgent.toLowerCase().indexOf("chrome")&&((k=l[0].flags).dependsOn=2,k.isNonSync=0),e.samples=l,t=W.moof(e.sequenceNumber++,E,e),e.samples=[],{data1:t,data2:n,startPTS:h/s,endPTS:(f+a)/s,startDTS:E/s,endDTS:this.nextAvcDts/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:r});return this.observer.trigger(H.default.FRAG_PARSING_DATA,k),k}},t.remuxAudio=function(e,t,r,i){var a,n,s,o,l=e.inputTimeScale,d=e.timescale,u=l/d,c=(e.isAAC?1024:1152)*u,h=this._initPTS,f=!e.isAAC&&this.typeSupported.mpeg,g=f?0:8,p=e.samples,m=[],v=this.nextAudioPts;if(r|=p.length&&v&&(i&&Math.abs(t-v/l)<.1||Math.abs(p[0].pts-v-h)<20*c),p.forEach(function(e){e.pts=e.dts=z(e.pts-h,t*l)}),0!==(p=p.filter(function(e){return 0<=e.pts})).length){if(r||(v=i?Math.max(0,t*l):p[0].pts),e.isAAC)for(var y=this.config.maxAudioFramesDrift,E=0,T=v;E<p.length;){var S=p[E],b=S.pts,_=b-T;if(_<=-y*c)r||0<E?(Y.logger.warn("Dropping 1 audio frame @ "+q(T,!0)/1e3+"s due to "+q(_,!0)+" ms overlap."),p.splice(E,1)):(Y.logger.warn("Audio frame @ "+q(b,!0)/1e3+"s overlaps nextAudioPts by "+q(_,!0)+" ms."),T=b+c,E++);else{if(y*c<=_&&_<U&&T){var A=Math.round(_/c);Y.logger.warn("Injecting "+A+" audio frames @ "+q(T,!0)/1e3+"s due to "+q(_,!0)+" ms gap.");for(var R=0;R<A;R++){var w,D=Math.max(T,0);(w=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(Y.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),w=S.unit.subarray()),p.splice(E,0,{unit:w,pts:D,dts:D}),T+=c,E++}}else Math.abs(_);S.pts=S.dts=T,T+=c,E++}}for(var L=p.length,k=0;L--;)k+=p[L].unit.byteLength;for(var C=0,M=p.length;C<M;C++){var O=p[C],I=O.unit,O=O.pts;if(void 0!==o&&a)a.duration=Math.round((O-o)/u);else{var P=O-v,x=0;if(r&&e.isAAC&&P){if(0<P&&P<U)x=Math.round((O-v)/c),Y.logger.log(q(P,!0)+" ms hole between AAC samples detected,filling it"),0<x&&(k+=x*(w=(w=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||I.subarray()).length);else if(P<-12){Y.logger.log("drop overlapping AAC sample, expected/parsed/delta: "+q(v,!0)+" ms / "+q(O,!0)+" ms / "+q(-P,!0)+" ms"),k-=I.byteLength;continue}O=v}if(s=O,!(0<k))return;k+=g;try{n=new Uint8Array(k)}catch(e){return void this.observer.trigger(H.default.ERROR,{type:V.ErrorTypes.MUX_ERROR,details:V.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:k,reason:"fail allocating audio mdat "+k})}f||(new DataView(n.buffer).setUint32(0,k),n.set(W.types.mdat,4));for(var F=0;F<x;F++)(w=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(Y.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),w=I.subarray()),n.set(w,g),g+=w.byteLength,a={size:w.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},m.push(a)}n.set(I,g);P=I.byteLength;g+=P,m.push(a={size:P,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}}),o=O}var d=0;return 2<=(L=m.length)&&(d=m[L-2].duration,a.duration=d),L?(this.nextAudioPts=v=o+u*d,e.samples=m,i=f?new Uint8Array:W.moof(e.sequenceNumber++,s/u,e),e.samples=[],this.observer.trigger(H.default.FRAG_PARSING_DATA,d={data1:i,data2:n,startPTS:d=s/l,endPTS:i=v/l,startDTS:d,endDTS:i,type:"audio",hasAudio:!0,hasVideo:!1,nb:L}),d):null}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,n=e.samplerate||a,s=this.nextAudioPts,o=(void 0!==s?s:i.startDTS*a)+this._initDTS,s=i.endDTS*a+this._initDTS,l=1024*(a/n),d=Math.ceil((s-o)/l),u=N.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(Y.logger.warn("remux empty Audio"),u){for(var c=[],h=0;h<d;h++){var f=o+h*l;c.push({unit:u,pts:f,dts:f})}e.samples=c,this.remuxAudio(e,t,r)}else Y.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 i=e.inputTimeScale,a=this._initPTS,n=this._initDTS,s=0;s<r;s++){var o=e.samples[s];o.pts=z(o.pts-a,t*i)/i,o.dts=z(o.dts-n,t*i)/i}this.observer.trigger(H.default.FRAG_PARSING_METADATA,{samples:e.samples}),e.samples=[]}},t.remuxText=function(e,t){var r=e.samples.length,i=e.inputTimeScale,a=this._initPTS;if(r){for(var n=0;n<r;n++){var s=e.samples[n];s.pts=z(s.pts-a,t*i)/i}e.samples.sort(function(e,t){return e.pts-t.pts}),this.observer.trigger(H.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]},e}(),L=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,i,a,n,s,o){var l=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),l.trigger(H.default.FRAG_PARSING_DATA,{data1:o,startPTS:a,startDTS:a,type:d,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),l.trigger(H.default.FRAG_PARSED)},e}(),t=Object(r.getSelfScope)();try{T=t.performance.now.bind(t.performance)}catch(e){Y.logger.debug("Unable to use Performance API on this environment"),T=t.Date.now}e.default=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,r,i,a,n,s,o,l,d,u,c,h){var t,f,g=this;0<e.byteLength&&null!=r&&null!=r.key&&"AES-128"===r.method?(null==(t=this.decrypter)&&(t=this.decrypter=new p.default(this.observer,this.config)),f=T(),t.decrypt(e,r.key.buffer,r.iv.buffer,function(e){var t=T();g.observer.trigger(H.default.FRAG_DECRYPTED,{stats:{tstart:f,tdecrypt:t}}),g.pushDecrypted(new Uint8Array(e),r,new Uint8Array(i),a,n,s,o,l,d,u,c,h)})):this.pushDecrypted(new Uint8Array(e),r,new Uint8Array(i),a,n,s,o,l,d,u,c,h)},t.pushDecrypted=function(e,t,r,i,a,n,s,o,l,d,u,c){var h=this.demuxer,f=this.remuxer;if(!h||s||o){for(var g,p=this.observer,m=this.typeSupported,v=this.config,y=[{demux:_,remux:D},{demux:b.default,remux:L},{demux:S,remux:D},{demux:A,remux:D}],E=0,T=y.length;E<T&&!(g=y[E]).demux.probe(e);E++);if(!g)return void p.trigger(H.default.ERROR,{type:V.ErrorTypes.MEDIA_ERROR,details:V.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});f&&f instanceof g.remux||(f=new g.remux(p,v,m,this.vendor)),h&&h instanceof g.demux||(h=new g.demux(p,f,v,m),this.probe=g.demux.probe),this.demuxer=h,this.remuxer=f}(s||o)&&(h.resetInitSegment(r,i,a,d),f.resetInitSegment()),s&&(h.resetTimeStamp(c),f.resetTimeStamp(c)),"function"==typeof h.setDecryptData&&h.setDecryptData(t),h.append(e,n,l,u)},e}()},"./src/demux/demuxer-worker.js":
|
|
37
|
-
/*!*************************************!*\
|
|
38
|
-
!*** ./src/demux/demuxer-worker.js ***!
|
|
39
|
-
\*************************************/
|
|
40
|
-
/*! exports provided: default */
|
|
41
|
-
/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./src/demux/demuxer.js (referenced with require.resolve) */function(e,t,r){"use strict";r.r(t);var s=r(/*! ../demux/demuxer-inline */"./src/demux/demuxer-inline.js"),o=r(/*! ../events */"./src/events.js"),l=r(/*! ../utils/logger */"./src/utils/logger.js"),d=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");t.default=function(i){function a(e,t){i.postMessage({event:e,data:t})}var n=new d.EventEmitter;n.trigger=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n.emit.apply(n,[e,e].concat(r))},n.off=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n.removeListener.apply(n,[e].concat(r))};i.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var r=JSON.parse(t.config);i.demuxer=new s.default(n,t.typeSupported,r,t.vendor),Object(l.enableLogs)(r.debug),a("init",null);break;case"demux":i.demuxer.push(t.data,t.decryptdata,t.initSegment,t.audioCodec,t.videoCodec,t.timeOffset,t.discontinuity,t.trackSwitch,t.contiguous,t.duration,t.accurateTimeOffset,t.defaultInitPTS)}}),n.on(o.default.FRAG_DECRYPTED,a),n.on(o.default.FRAG_PARSING_INIT_SEGMENT,a),n.on(o.default.FRAG_PARSED,a),n.on(o.default.ERROR,a),n.on(o.default.FRAG_PARSING_METADATA,a),n.on(o.default.FRAG_PARSING_USERDATA,a),n.on(o.default.INIT_PTS_FOUND,a),n.on(o.default.FRAG_PARSING_DATA,function(e,t){var r=[],e={event:e,data:t};t.data1&&(e.data1=t.data1.buffer,r.push(t.data1.buffer),delete t.data1),t.data2&&(e.data2=t.data2.buffer,r.push(t.data2.buffer),delete t.data2),i.postMessage(e,r)})}},"./src/demux/id3.js":
|
|
42
|
-
/*!**************************!*\
|
|
43
|
-
!*** ./src/demux/id3.js ***!
|
|
44
|
-
\**************************/
|
|
45
|
-
/*! exports provided: default, utf8ArrayToStr */function(e,t,r){"use strict";r.r(t),r.d(t,"utf8ArrayToStr",function(){return i});var u,c=r(/*! ../utils/get-self-scope */"./src/utils/get-self-scope.js"),r=function(){function o(){}return o.isHeader=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},o.isFooter=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},o.getID3Data=function(e,t){for(var r=t,i=0;o.isHeader(e,t);){i=(i+=10)+o._readSize(e,t+6);o.isFooter(e,t+10)&&(i+=10),t+=i}if(0<i)return e.subarray(r,r+i)},o._readSize=function(e,t){var r=(127&e[t])<<21;return(r|=(127&e[t+1])<<14)|(127&e[t+2])<<7|127&e[t+3]},o.getTimeStamp=function(e){for(var t=o.getID3Frames(e),r=0;r<t.length;r++){var i=t[r];if(o.isTimeStampFrame(i))return o._readTimeStamp(i)}},o.isTimeStampFrame=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},o._getFrameData=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o._readSize(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},o.getID3Frames=function(e){for(var t=0,r=[];o.isHeader(e,t);){for(var i=o._readSize(e,t+6),a=(t+=10)+i;t+8<a;){var n=o._getFrameData(e.subarray(t)),s=o._decodeFrame(n);s&&r.push(s),t+=n.size+10}o.isFooter(e,t)&&(t+=10)}return r},o._decodeFrame=function(e){return"PRIV"===e.type?o._decodePrivFrame(e):"T"===e.type[0]?o._decodeTextFrame(e):"W"===e.type[0]?o._decodeURLFrame(e):void 0},o._readTimeStamp=function(e){var t;if(8===e.data.byteLength)return t=1&(e=new Uint8Array(e.data))[3],e=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7],e/=45,t&&(e+=47721858.84),Math.round(e)},o._decodePrivFrame=function(e){var t,r;if(!(e.size<2))return t=o._utf8ArrayToStr(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:r.buffer}},o._decodeTextFrame=function(e){var t,r;if(!(e.size<2))return"TXXX"===e.type?(t=1,t+=(r=o._utf8ArrayToStr(e.data.subarray(1),!0)).length+1,t=o._utf8ArrayToStr(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=o._utf8ArrayToStr(e.data.subarray(1)),{key:e.type,data:r})},o._decodeURLFrame=function(e){var t,r;return"WXXX"!==e.type?(r=o._utf8ArrayToStr(e.data),{key:e.type,data:r}):e.size<2?void 0:(r=1,r+=(t=o._utf8ArrayToStr(e.data.subarray(1),!0)).length+1,r=o._utf8ArrayToStr(e.data.subarray(r)),{key:e.type,info:t,data:r})},o._utf8ArrayToStr=function(e,t){void 0===t&&(t=!1);var r,i=function(){var e=Object(c.getSelfScope)();u||void 0===e.TextDecoder||(u=new e.TextDecoder("utf-8"));return u}();if(i)return i=i.decode(e),t?-1!==(r=i.indexOf("\0"))?i.substring(0,r):i:i.replace(/\0/g,"");for(var a,n,s,o=e.length,l="",d=0;d<o;){if(0===(a=e[d++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:n=e[d++],l+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[d++],s=e[d++],l+=String.fromCharCode((15&a)<<12|(63&n)<<6|(63&s)<<0)}}return l},o}();var i=r._utf8ArrayToStr;t.default=r},"./src/demux/mp4demuxer.js":
|
|
46
|
-
/*!*********************************!*\
|
|
47
|
-
!*** ./src/demux/mp4demuxer.js ***!
|
|
48
|
-
\*********************************/
|
|
49
|
-
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../utils/logger */"./src/utils/logger.js"),o=r(/*! ../events */"./src/events.js"),s=Math.pow(2,32)-1;t.default=function(){function h(e,t){this.observer=e,this.remuxer=t}var e=h.prototype;return e.resetTimeStamp=function(e){this.initPTS=e},e.resetInitSegment=function(e,t,r,i){var a,n;e&&e.byteLength?(null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e"),n={},(a=this.initData=h.parseInitSegment(e)).audio&&a.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:i?e:null}:(a.audio&&(n.audio={container:"audio/mp4",codec:t,initSegment:i?e:null}),a.video&&(n.video={container:"video/mp4",codec:r,initSegment:i?e:null})),this.observer.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,{tracks:n})):(t&&(this.audioCodec=t),r&&(this.videoCodec=r))},h.probe=function(e){return 0<h.findBox({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length},h.bin2str=function(e){return String.fromCharCode.apply(null,e)},h.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);e=e[t]<<8|e[t+1];return e<0?65536+e:e},h.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);e=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return e<0?4294967296+e:e},h.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},h.findBox=function(e,t){var r,i,a,n,s,o=[];if(e.data?(n=e.start,i=e.end,e=e.data):(n=0,i=e.byteLength),!t.length)return null;for(r=n;r<i;)s=1<(s=h.readUint32(e,r))?r+s:i,h.bin2str(e.subarray(r+4,r+8))===t[0]&&(1===t.length?o.push({data:e,start:r+8,end:s}):(a=h.findBox({data:e,start:r+8,end:s},t.slice(1))).length&&(o=o.concat(a))),r=s;return o},h.parseSegmentIndex=function(e){var t=h.findBox(e,["moov"])[0],t=t?t.end:null,r=0,i=h.findBox(e,["sidx"]);if(!i||!i[0])return null;var a=[],e=(i=i[0]).data[0],r=0===e?8:16,n=h.readUint32(i,r),s=i.end+0,o=h.readUint16(i,r=(r+=4)+(0===e?8:16)+2);r+=2;for(var l=0;l<o;l++){var d=r,u=h.readUint32(i,d),c=(d+=4,2147483647&u);if(1==(2147483648&u)>>>31)return void console.warn("SIDX has hierarchical references (not supported)");u=h.readUint32(i,d);d+=4,a.push({referenceSize:c,subsegmentDuration:u,info:{duration:u/n,start:s,end:s+c-1}}),s+=c,r=d+=4}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:o,references:a,moovEndOffset:t}},h.parseInitSegment=function(e){var a=[];return h.findBox(e,["moov","trak"]).forEach(function(e){var t,r,i=h.findBox(e,["tkhd"])[0];i&&(r=i.data[i.start],i=h.readUint32(i,0===r?12:20),t=h.findBox(e,["mdia","mdhd"])[0])&&(r=t.data[t.start],t=h.readUint32(t,0===r?12:20),r=h.findBox(e,["mdia","hdlr"])[0])&&(r={soun:"audio",vide:"video"}[h.bin2str(r.data.subarray(r.start+8,r.start+12))])&&((e=h.findBox(e,["mdia","minf","stbl","stsd"])).length&&(e=e[0],e=h.bin2str(e.data.subarray(e.start+12,e.start+16)),n.logger.log("MP4Demuxer:"+r+":"+e+" found")),a[i]={timescale:t,type:r},a[r]={timescale:t,id:i})}),a},h.getStartDTS=function(r,e){e=h.findBox(e,["moof","traf"]),e=[].concat.apply([],e.map(function(t){return h.findBox(t,["tfhd"]).map(function(e){e=h.readUint32(e,4),e=r[e].timescale||9e4;return h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);return r=1===t?(r*=Math.pow(2,32))+h.readUint32(e,8):r})[0]/e})})),e=Math.min.apply(null,e);return isFinite(e)?e:0},h.offsetStartDTS=function(r,e,a){h.findBox(e,["moof","traf"]).map(function(t){return h.findBox(t,["tfhd"]).map(function(e){var e=h.readUint32(e,4),i=r[e].timescale||9e4;h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);0===t?h.writeUint32(e,4,r-a*i):(r=(r=(r*=Math.pow(2,32))+h.readUint32(e,8))-a*i,r=Math.max(r,0),t=Math.floor(r/(1+s)),r=Math.floor(r%(1+s)),h.writeUint32(e,4,t),h.writeUint32(e,8,r))})})})},e.append=function(e,t,r,i){var a=this.initData;a||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),a=this.initData);var n,s=this.initPTS;void 0===s&&(n=h.getStartDTS(a,e),this.initPTS=s=n-t,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:s})),h.offsetStartDTS(a,e,s),n=h.getStartDTS(a,e),this.remuxer.remux(a.audio,a.video,null,null,n,r,i,e)},e.destroy=function(){},h}()},"./src/errors.ts":
|
|
50
|
-
/*!***********************!*\
|
|
51
|
-
!*** ./src/errors.ts ***!
|
|
52
|
-
\***********************/
|
|
53
|
-
/*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){"use strict";var i,a;r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return a}),(r=i=i||{}).NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",(t=a=a||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException"},"./src/events.js":
|
|
54
|
-
/*!***********************!*\
|
|
55
|
-
!*** ./src/events.js ***!
|
|
56
|
-
\***********************/
|
|
57
|
-
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVELS_UPDATED:"hlsLevelsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",CUES_PARSED:"hlsCuesParsed",NON_NATIVE_TEXT_TRACKS_FOUND:"hlsNonNativeTextTracksFound",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":
|
|
58
|
-
/*!*********************************!*\
|
|
59
|
-
!*** ./src/hls.ts + 50 modules ***!
|
|
60
|
-
\*********************************/
|
|
61
|
-
/*! exports provided: default */
|
|
62
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/demux/demuxer-worker.js */
|
|
63
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/demuxer-inline.js because of ./src/demux/demuxer-worker.js */
|
|
64
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/demux/demuxer-worker.js */
|
|
65
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/demux/demuxer-worker.js */
|
|
66
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/demux/demuxer-worker.js */
|
|
67
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/demux/demuxer-worker.js */
|
|
68
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number.js because of ./src/demux/demuxer-worker.js */
|
|
69
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/demux/demuxer-worker.js */
|
|
70
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/demux/demuxer-worker.js */
|
|
71
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/eventemitter3/index.js (<- Module is not an ECMAScript module) */
|
|
72
|
-
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/url-toolkit/src/url-toolkit.js (<- Module is not an ECMAScript module) */function(M,e,t){"use strict";t.r(e),t.d(e,"default",function(){return rr});var f,n,e={},a=(t.r(e),t.d(e,"newCue",function(){return Et}),t("./node_modules/url-toolkit/src/url-toolkit.js")),p=t("./src/errors.ts"),k=t("./src/polyfills/number.js"),v=t("./src/events.js"),C=t("./src/utils/logger.js"),N={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},s=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(1<t?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(N[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(t,e){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,t,e).call()}catch(e){C.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,err:e})}},e}(),U=((r=f=f||{}).MANIFEST="manifest",r.LEVEL="level",r.AUDIO_TRACK="audioTrack",r.SUBTITLE_TRACK="subtitleTrack",(r=n=n||{}).MAIN="main",r.AUDIO="audio",r.SUBTITLE="subtitle",t("./src/demux/mp4demuxer.js"));function B(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,G=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(a.buildAbsoluteURL)(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}])&&B(t.prototype,r),i&&B(t,i),e}();function j(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)}}(r=o=o||{}).AUDIO="audio",r.VIDEO="video";var O=function(){function e(){var e;this._url=null,this._byteRange=null,this._decryptdata=null,this._elementaryStreams=((e={})[o.AUDIO]=!1,e[o.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=e.prototype;return i.setByteRange=function(e,t){var e=e.split("@",2),r=[];1===e.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(e[1]),r[1]=parseInt(e[0])+r[0],this._byteRange=r},i.addElementaryStream=function(e){this._elementaryStreams[e]=!0},i.hasElementaryStream=function(e){return!0===this._elementaryStreams[e]},i.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},i.setDecryptDataFromLevelKey=function(e,t){var r=e;return null!=e&&e.method&&e.uri&&!e.iv&&((r=new G(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},i=e,(t=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange||[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){var e;return this.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(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)),this._decryptdata):null}},{key:"endProgramDateTime",get:function(){var e;return null!==this.programDateTime&&Object(k.isFiniteNumber)(this.programDateTime)?(e=Object(k.isFiniteNumber)(this.duration)?this.duration:0,this.programDateTime+1e3*e):null}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&j(i.prototype,t),r&&j(i,r),e}();function K(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 H=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(k.isFiniteNumber)(this.fragments[0].programDateTime))}}])&&K(t.prototype,r),i&&K(t,i),e}(),V=/^(\d+)x(\d+)$/,Y=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,I=function(){function r(e){for(var t in e="string"==typeof e?r.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}var e=r.prototype;return e.decimalInteger=function(e){e=parseInt(this[e],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,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},e.hexadecimalIntegerAsNumber=function(e){e=parseInt(this[e],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.enumeratedString=function(e){return this[e]},e.decimalResolution=function(e){e=V.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},r.parseAttrList=function(e){var t,r={};for(Y.lastIndex=0;null!==(t=Y.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},r}(),W={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 q(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var X=/(?:#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)|#EXT-X-SESSION-DATA:([^\n\r]*)[\r\n]+)/g,z=/#EXT-X-MEDIA:(.*)/g,J=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),Z=/(?:(?:#(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?/,Q=/\.(mp4|m4s|m4v|m4a)$/i,g=function(){function u(){}return u.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},u.convertAVC1ToAVCOTI=function(e){var t=e.split("."),r=2<t.length?(r=t.shift()+".",(r+=parseInt(t.shift()).toString(16))+("000"+parseInt(t.shift()).toString(16)).substr(-4)):e;return r},u.resolve=function(e,t){return a.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},u.parseMasterPlaylist=function(e,t){var r,i,a,n,s=[],o={},l=!1;function d(i,a){["video","audio"].forEach(function(r){var e,t=i.filter(function(e){return e=e,!!(t=W[t=r])&&!0===t[e.slice(0,4)];var t});t.length&&(e=t.filter(function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}),a[r+"Codec"]=(0<e.length?e:t)[0],i=i.filter(function(e){return-1===t.indexOf(e)}))}),a.unknownCodecs=i}for(X.lastIndex=0;null!=(r=X.exec(e));)r[1]?(a=(i={}).attrs=new I(r[1]),i.url=u.resolve(r[2],t),(n=a.decimalResolution("RESOLUTION"))&&(i.width=n.width,i.height=n.height),i.bitrate=a.decimalInteger("AVERAGE-BANDWIDTH")||a.decimalInteger("BANDWIDTH"),i.name=a.NAME,d([].concat((a.CODECS||"").split(/[ ,]+/)),i),i.videoCodec&&-1!==i.videoCodec.indexOf("avc1")&&(i.videoCodec=u.convertAVC1ToAVCOTI(i.videoCodec)),s.push(i)):r[3]&&(n=new I(r[3]))["DATA-ID"]&&(l=!0,o[n["DATA-ID"]]=n);return{levels:s,sessionData:l?o:null}},u.parseMasterPlaylistMedia=function(e,t,r,i){void 0===i&&(i=[]);var a=[],n=0;for(z.lastIndex=0;null!==(o=z.exec(e));){var s,o=new I(o[1]);o.TYPE===r&&(s={attrs:o,id:n++,groupId:o["GROUP-ID"],instreamId:o["INSTREAM-ID"],name:o.NAME||o.LANGUAGE,type:r,default:"YES"===o.DEFAULT,autoselect:"YES"===o.AUTOSELECT,forced:"YES"===o.FORCED,lang:o.LANGUAGE},o.URI&&(s.url=u.resolve(o.URI,t)),i.length&&(o=u.findGroup(i,s.groupId),s.audioCodec=(o||i[0]).codec),a.push(s))}return a},u.parseLevelPlaylist=function(e,t,r,i,a){var n,s,o,l=0,d=0,u=new H(t),c=0,h=null,f=new O,g=null;for(J.lastIndex=0;null!==(n=J.exec(e));){var p=n[1];if(p){f.duration=parseFloat(p);var m=(" "+n[2]).slice(1);f.title=m||null,f.tagList.push(m?["INF",p,m]:["INF",p])}else if(n[3])Object(k.isFiniteNumber)(f.duration)&&(m=l++,f.type=i,f.start=d,o&&(f.levelkey=o),f.sn=m,f.level=r,f.cc=c,f.urlId=a,f.baseurl=t,f.relurl=(" "+n[3]).slice(1),v=p=void 0,v=h,(p=f).rawProgramDateTime?p.programDateTime=Date.parse(p.rawProgramDateTime):null!=v&&v.programDateTime&&(p.programDateTime=v.endProgramDateTime),Object(k.isFiniteNumber)(p.programDateTime)||(p.programDateTime=null,p.rawProgramDateTime=null),u.fragments.push(f),d+=(h=f).duration,f=new O);else if(n[4]){var v=(" "+n[4]).slice(1);h?f.setByteRange(v,h):f.setByteRange(v)}else if(n[5])f.rawProgramDateTime=(" "+n[5]).slice(1),f.tagList.push(["PROGRAM-DATE-TIME",f.rawProgramDateTime]),null===g&&(g=u.fragments.length);else if(n=n[0].match(Z)){for(s=1;s<n.length&&void 0===n[s];s++);var y=(" "+n[s+1]).slice(1),E=(" "+n[s+2]).slice(1);switch(n[s]){case"#":f.tagList.push(E?[y,E]:[y]);break;case"PLAYLIST-TYPE":u.type=y.toUpperCase();break;case"MEDIA-SEQUENCE":l=u.startSN=parseInt(y);break;case"TARGETDURATION":u.targetduration=parseFloat(y);break;case"VERSION":u.version=parseInt(y);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"DIS":c++,f.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":c=parseInt(y);break;case"KEY":var T=new I(y),S=T.enumeratedString("METHOD"),b=T.URI,_=T.hexadecimalInteger("IV");"com.apple.streamingkeydelivery"===(T.KEYFORMAT||"identity")?C.logger.warn("Keyformat com.apple.streamingkeydelivery is not supported"):S&&(o=new G(t,b),b)&&0<=["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(S)&&(o.method=S,o.key=null,o.iv=_);break;case"START":T=new I(y).decimalFloatingPoint("TIME-OFFSET");Object(k.isFiniteNumber)(T)&&(u.startTimeOffset=T);break;case"MAP":b=new I(y);f.relurl=b.URI,b.BYTERANGE&&f.setByteRange(b.BYTERANGE),f.baseurl=t,f.level=r,f.type=i,f.sn="initSegment",u.initSegment=f,(f=new O).rawProgramDateTime=u.initSegment.rawProgramDateTime;break;default:C.logger.warn("line parsed but not handled: "+n)}}else C.logger.warn("No matches on slow regex match for level playlist!")}if((f=h)&&!f.relurl&&(u.fragments.pop(),d-=f.duration),u.totalduration=d,u.averagetargetduration=d/u.fragments.length,u.endSN=l-1,u.startCC=u.fragments[0]?u.fragments[0].cc:0,u.endCC=c,!u.initSegment&&u.fragments.length&&u.fragments.every(function(e){return Q.test(e.relurl)})&&(C.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(f=new O).relurl=u.fragments[0].relurl,f.baseurl=t,f.level=r,f.type=i,f.sn="initSegment",u.initSegment=f,u.needSidxRanges=!0),g)for(var A=u.fragments,R=g,w=A[R],D=R-1;0<=D;D--){var L=A[D];L.programDateTime=w.programDateTime-1e3*L.duration,w=L}return u},u}();var $=window.performance,ee=function(t){var e;function h(e){e=t.call(this,e,v.default.MANIFEST_LOADING,v.default.LEVEL_LOADING,v.default.AUDIO_TRACK_LOADING,v.default.SUBTITLE_TRACK_LOADING)||this;return e.loaders={},e}e=t,(r=h).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e,h.canHaveQualityLevels=function(e){return e!==f.AUDIO_TRACK&&e!==f.SUBTITLE_TRACK},h.mapContextToLevelType=function(e){switch(e.type){case f.AUDIO_TRACK:return n.AUDIO;case f.SUBTITLE_TRACK:return n.SUBTITLE;default:return n.MAIN}},h.getResponseUrl=function(e,t){e=e.url;return e=void 0!==e&&0!==e.indexOf("data:")?e:t.url};var r=h.prototype;return r.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,r=new(r||i)(t);return e.loader=r,this.loaders[e.type]=r},r.getInternalLoader=function(e){return this.loaders[e.type]},r.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},r.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},r.destroy=function(){this.destroyInternalLoaders(),t.prototype.destroy.call(this)},r.onManifestLoading=function(e){this.load({url:e.url,type:f.MANIFEST,level:0,id:null,responseType:"text"})},r.onLevelLoading=function(e){this.load({url:e.url,type:f.LEVEL,level:e.level,id:e.id,responseType:"text"})},r.onAudioTrackLoading=function(e){this.load({url:e.url,type:f.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},r.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:f.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},r.load=function(e){var t,r,i,a,n=this.hls.config;if(C.logger.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id),o=this.getInternalLoader(e)){var s=o.context;if(s&&s.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 f.MANIFEST:t=n.manifestLoadingMaxRetry,r=n.manifestLoadingTimeOut,i=n.manifestLoadingRetryDelay,a=n.manifestLoadingMaxRetryTimeout;break;case f.LEVEL:i=a=t=0,r=n.levelLoadingTimeOut;break;default:t=n.levelLoadingMaxRetry,r=n.levelLoadingTimeOut,i=n.levelLoadingRetryDelay,a=n.levelLoadingMaxRetryTimeout}var o=this.createInternalLoader(e),s={timeout:r,maxRetry:t,retryDelay:i,maxRetryDelay:a},l={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,s,l),!0},r.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)this._handleSidxRequest(e,r),this._handlePlaylistLoaded(e,t,r,i);else{if(this.resetInternalLoader(r.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var a=e.data;t.tload=$.now(),0!==a.indexOf("#EXTM3U")?this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i):0<a.indexOf("#EXTINF:")||0<a.indexOf("#EXT-X-TARGETDURATION:")?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i)}},r.loaderror=function(e,t,r){this._handleNetworkError(t,r=void 0===r?null:r,!1,e)},r.loadtimeout=function(e,t,r){this._handleNetworkError(t,r=void 0===r?null:r,!0)},r._handleMasterPlaylist=function(e,t,r,i){var a,n,s,o=this.hls,l=e.data,d=h.getResponseUrl(e,r),u=g.parseMasterPlaylist(l,d),c=u.levels,u=u.sessionData;c.length?(a=c.map(function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}}),a=g.parseMasterPlaylistMedia(l,d,"AUDIO",a),n=g.parseMasterPlaylistMedia(l,d,"SUBTITLES"),l=g.parseMasterPlaylistMedia(l,d,"CLOSED-CAPTIONS"),a.length&&(s=!1,a.forEach(function(e){e.url||(s=!0)}),!1===s)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(C.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),a.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:{},url:""})),o.trigger(v.default.MANIFEST_LOADED,{levels:c,audioTracks:a,subtitles:n,captions:l,url:d,stats:t,networkDetails:i,sessionData:u})):this._handleManifestParsingError(e,r,"no level found in manifest",i)},r._handleTrackOrLevelPlaylist=function(e,t,r,i){var a=this.hls,n=r.id,s=r.level,o=r.type,l=h.getResponseUrl(e,r),d=Object(k.isFiniteNumber)(n)?n:0,u=Object(k.isFiniteNumber)(s)?s:d,c=h.mapContextToLevelType(r),u=g.parseLevelPlaylist(e.data,l,u,c,d);u.tload=t.tload,u.fragments.length?(o===f.MANIFEST&&a.trigger(v.default.MANIFEST_LOADED,{levels:[{url:l,details:u}],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null}),t.tparsed=$.now(),u.needSidxRanges?(c=u.initSegment.url,this.load({url:c,isSidxRequest:!0,type:o,level:s,levelDetails:u,id:n,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})):(r.levelDetails=u,this._handlePlaylistLoaded(e,t,r,i))):a.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:l,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},r._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r,i,e=U.default.parseSegmentIndex(new Uint8Array(e.data));e&&(r=e.references,i=t.levelDetails,r.forEach(function(e,t){e=e.info;i&&0===(t=i.fragments[t]).byteRange.length&&t.setByteRange(String(1+e.end-e.start)+"@"+String(e.start))}),i)&&i.initSegment.setByteRange(String(e.moovEndOffset)+"@0")},r._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})},r._handleNetworkError=function(e,t,r,i){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 a,n,s=this.getInternalLoader(e);switch(e.type){case f.MANIFEST:a=r?p.ErrorDetails.MANIFEST_LOAD_TIMEOUT:p.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case f.LEVEL:a=r?p.ErrorDetails.LEVEL_LOAD_TIMEOUT:p.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case f.AUDIO_TRACK:a=r?p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;default:n=!1}s&&(s.abort(),this.resetInternalLoader(e.type));s={type:p.ErrorTypes.NETWORK_ERROR,details:a,fatal:n,url:e.url,loader:s,context:e,networkDetails:t};i&&(s.response=i),this.hls.trigger(v.default.ERROR,s)},r._handlePlaylistLoaded=function(e,t,r,i){var a=r.type,n=r.level,s=r.id,o=r.levelDetails;if(o&&o.targetduration)if(h.canHaveQualityLevels(r.type))this.hls.trigger(v.default.LEVEL_LOADED,{details:o,level:n||0,id:s||0,stats:t,networkDetails:i});else switch(a){case f.AUDIO_TRACK:this.hls.trigger(v.default.AUDIO_TRACK_LOADED,{details:o,id:s,stats:t,networkDetails:i});break;case f.SUBTITLE_TRACK:this.hls.trigger(v.default.SUBTITLE_TRACK_LOADED,{details:o,id:s,stats:t,networkDetails:i})}else this._handleManifestParsingError(e,r,"invalid target duration",i)},h}(s);var te=function(i){var e;function t(e){e=i.call(this,e,v.default.FRAG_LOADING)||this;return e.loaders={},e}e=i,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.destroy=function(){var e,t=this.loaders;for(e in t){var r=t[e];r&&r.destroy()}this.loaders={},i.prototype.destroy.call(this)},r.onFragLoading=function(e){var e=e.frag,t=e.type,r=this.loaders,i=this.hls.config,a=i.fLoader,n=i.loader,s=(e.loaded=0,r[t]),t=(s&&(C.logger.warn("abort previous fragment loader for type: "+t),s.abort()),s=r[t]=e.loader=new(i.fLoader?a:n)(i),r={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1},e.byteRangeStartOffset),a=e.byteRangeEndOffset;Object(k.isFiniteNumber)(t)&&Object(k.isFiniteNumber)(a)&&(r.rangeStart=t,r.rangeEnd=a),n={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout},e={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},s.load(r,n,e)},r.loadsuccess=function(e,t,r,i){if(null!=(i=void 0===i?null:i)){var a=void 0;try{a=i.getResponseHeader("x-cache")}catch(e){C.logger.warn("Couldnt read x-cache header "+e),a=void 0}"Miss from cloudfront"==a&&(t.isCacheMiss=!0)}a=e.data,e=r.frag;e.loader=void 0,this.loaders[e.type]=void 0,this.hls.trigger(v.default.FRAG_LOADED,{payload:a,frag:e,stats:t,networkDetails:i})},r.loaderror=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},r.loadtimeout=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},r.loadprogress=function(e,t,r,i){void 0===i&&(i=null);t=t.frag;t.loaded=e.loaded,this.hls.trigger(v.default.FRAG_LOAD_PROGRESS,{frag:t,stats:e,networkDetails:i})},t}(s);var re=function(t){var e;function r(e){e=t.call(this,e,v.default.KEY_LOADING)||this;return e.loaders={},e.decryptkey=null,e.decrypturl=null,e}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){for(var e in this.loaders){e=this.loaders[e];e&&e.destroy()}this.loaders={},t.prototype.destroy.call(this)},i.onKeyLoading=function(e){var t,r,e=e.frag,i=e.type,a=this.loaders[i];e.decryptdata?(r=e.decryptdata.uri)!==this.decrypturl||null===this.decryptkey?(t=this.hls.config,a&&(C.logger.warn("abort previous key loader for type:"+i),a.abort()),r?(e.loader=this.loaders[i]=new t.loader(t),this.decrypturl=r,this.decryptkey=null,a={url:r,frag:e,responseType:"arraybuffer"},i={timeout:t.fragLoadingTimeOut,maxRetry:0,retryDelay:t.fragLoadingRetryDelay,maxRetryDelay:t.fragLoadingMaxRetryTimeout},r={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(a,i,r)):C.logger.warn("key uri is falsy")):this.decryptkey&&(e.decryptdata.key=this.decryptkey,this.hls.trigger(v.default.KEY_LOADED,{frag:e})):C.logger.warn("Missing decryption data on fragment in onKeyLoading")},i.loadsuccess=function(e,t,r){r=r.frag;r.decryptdata?(this.decryptkey=r.decryptdata.key=new Uint8Array(e.data),r.loader=void 0,delete this.loaders[r.type],this.hls.trigger(v.default.KEY_LOADED,{frag:r})):C.logger.error("after key load, decryptdata unset")},i.loaderror=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:t,response:e})},i.loadtimeout=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:t})},r}(s);var ie="NOT_LOADED",ae="APPENDING",ne="PARTIAL",se="OK",oe=function(r){var e;function t(e){var t=r.call(this,e,v.default.BUFFER_APPENDED,v.default.FRAG_BUFFERED,v.default.FRAG_LOADED)||this;return t.bufferPadding=.2,t.fragments=Object.create(null),t.timeRanges=Object.create(null),t.config=e.config,t}e=r,(i=t).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=t.prototype;return i.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,s.prototype.destroy.call(this),r.prototype.destroy.call(this)},i.getBufferedFrag=function(t,r){var i=this.fragments,e=Object.keys(i).filter(function(e){var e=i[e];return e.body.type===r&&!!e.buffered&&(e=e.body).startPTS<=t&&t<=e.endPTS});return 0===e.length?null:(e=e.pop(),i[e].body)},i.detectEvictedFragments=function(n,s){var o=this;Object.keys(this.fragments).forEach(function(e){var t=o.fragments[e];if(t&&t.buffered){e=t.range[n];if(e)for(var r=e.time,i=0;i<r.length;i++){var a=r[i];if(!o.isTimeBuffered(a.startPTS,a.endPTS,s)){o.removeFragment(t.body);break}}}})},i.detectPartialFragments=function(r){var i=this,e=this.getFragmentKey(r),a=this.fragments[e];a&&(a.buffered=!0,Object.keys(this.timeRanges).forEach(function(e){var t;r.hasElementaryStream(e)&&(t=i.timeRanges[e],a.range[e]=i.getBufferedTimes(r.startPTS,r.endPTS,t))}))},i.getBufferedTimes=function(e,t,r){for(var i,a,n=[],s=!1,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,i<=e&&t<=a){n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))});break}if(e<a&&i<t)n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))}),s=!0;else if(t<=i)break}return{time:n,partial:s}},i.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},i.getPartialFragment=function(t){var r,i,a=this,n=null,s=0;return Object.keys(this.fragments).forEach(function(e){e=a.fragments[e];a.isPartial(e)&&(r=e.body.startPTS-a.bufferPadding,i=e.body.endPTS+a.bufferPadding,r<=t)&&t<=i&&(r=Math.min(t-r,i-t),s<=r)&&(n=e.body,s=r)}),n},i.getState=function(e){var e=this.getFragmentKey(e),e=this.fragments[e],t=ie;return t=void 0!==e?e.buffered?!0===this.isPartial(e)?ne:se:ae:t},i.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)},i.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,i<=e&&t<=a)return!0;if(t<=i)return!1}return!1},i.onFragLoaded=function(e){e=e.frag;Object(k.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.fragments[this.getFragmentKey(e)]={body:e,range:Object.create(null),buffered:!1})},i.onBufferAppended=function(e){var r=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach(function(e){var t=r.timeRanges[e];r.detectEvictedFragments(e,t)})},i.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},i.hasFragment=function(e){e=this.getFragmentKey(e);return void 0!==this.fragments[e]},i.removeFragment=function(e){e=this.getFragmentKey(e);delete this.fragments[e]},i.removeAllFragments=function(){this.fragments=Object.create(null)},t}(s),le={search:function(e,t){for(var r=0,i=e.length-1;r<=i;){var a,n,s=t(n=e[a=(r+i)/2|0]);if(0<s)r=1+a;else{if(!(s<0))return n;i=a-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){for(var i=e.buffered,a=[],n=0;n<i.length;n++)a.push({start:i.start(n),end:i.end(n)});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 a=0;a<e.length;a++){var n,s=i.length;s&&(n=i[s-1].end,e[a].start-n<r)?e[a].end>n&&(i[s-1].end=e[a].end):i.push(e[a])}else i=e;for(var o,l=0,d=t,u=t,c=0;c<i.length;c++){var h=i[c].start,f=i[c].end;if(h<=t+r&&t<f)d=h,l=(u=f)-t;else if(t+r<h){o=h;break}}return{len:l,start:d,end:u,nextStart:o}},e}(),r=t("./node_modules/eventemitter3/index.js"),de=t("./node_modules/webworkify-webpack/index.js"),ue=t("./src/demux/demuxer-inline.js");function ce(){return window.MediaSource||window.WebKitMediaSource}var i=t("./src/utils/get-self-scope.js");var he=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).__proto__=r,i.prototype.trigger=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e,e].concat(r))},i}(r.EventEmitter),fe=Object(i.getSelfScope)(),ge=ce()||{isTypeSupported:function(){return!1}},pe=function(){function e(r,e){function t(e,t){(t=t||{}).frag=a.frag,t.id=a.id,r.trigger(e,t)}var i,a=this,n=(this.hls=r,this.id=e,this.observer=new he),s=r.config,o=(n.on(v.default.FRAG_DECRYPTED,t),n.on(v.default.FRAG_PARSING_INIT_SEGMENT,t),n.on(v.default.FRAG_PARSING_DATA,t),n.on(v.default.FRAG_PARSED,t),n.on(v.default.ERROR,t),n.on(v.default.FRAG_PARSING_METADATA,t),n.on(v.default.FRAG_PARSING_USERDATA,t),n.on(v.default.INIT_PTS_FOUND,t),{mp4:ge.isTypeSupported("video/mp4"),mpeg:ge.isTypeSupported("audio/mpeg"),mp3:ge.isTypeSupported('audio/mp4; codecs="mp3"')}),l=navigator.vendor;if(s.enableWorker&&"undefined"!=typeof Worker){C.logger.log("demuxing in webworker");try{i=this.w=de(/*! ../demux/demuxer-worker.js */"./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),i.addEventListener("message",this.onwmsg),i.onerror=function(e){r.trigger(v.default.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:e.message+" ("+e.filename+":"+e.lineno+")"}})},i.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(s)})}catch(e){C.logger.warn("Error in worker:",e),C.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),i&&fe.URL.revokeObjectURL(i.objectURL),this.demuxer=new ue.default(n,o,s,l),this.w=void 0}}else this.demuxer=new ue.default(n,o,s,l)}var t=e.prototype;return t.destroy=function(){var e=this.w,e=(e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null):(e=this.demuxer)&&(e.destroy(),this.demuxer=null),this.observer);e&&(e.removeAllListeners(),this.observer=null)},t.push=function(e,t,r,i,a,n,s,o){var l=this.w,d=Object(k.isFiniteNumber)(a.startPTS)?a.startPTS:a.start,u=a.decryptdata,c=this.frag,h=!(c&&a.cc===c.cc),f=!(c&&a.level===c.level),c=c&&a.sn===c.sn+1,c=!f&&c;h&&C.logger.log(this.id+":discontinuity detected"),f&&C.logger.log(this.id+":switch detected"),this.frag=a,l?l.postMessage({cmd:"demux",data:e,decryptdata:u,initSegment:t,audioCodec:r,videoCodec:i,timeOffset:d,discontinuity:h,trackSwitch:f,contiguous:c,duration:n,accurateTimeOffset:s,defaultInitPTS:o},e instanceof ArrayBuffer?[e]:[]):(a=this.demuxer)&&a.push(e,u,t,r,i,d,h,f,c,n,s,o)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":fe.URL.revokeObjectURL(this.w.objectURL);break;case v.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 me(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 ve(e,t,r){var i=e[t],e=e[r],a=e.startPTS;Object(k.isFiniteNumber)(a)?t<r?(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!")):(e.duration=i.start-a,e.duration<0&&C.logger.warn("negative duration computed for frag "+e.sn+",level "+e.level+", there should be some duration drift between playlist and fragment!")):t<r?(a=i.cc===e.cc,e.start=i.start+(a&&i.minEndPTS?i.minEndPTS-i.start:i.duration)):e.start=Math.max(i.start-e.duration,0)}function ye(e,t,r,i,a,n){var s,o,l=r,d=i,u=(Object(k.isFiniteNumber)(t.startPTS)&&(u=Math.abs(t.startPTS-r),Object(k.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,l=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),d=Math.min(i,t.endPTS),i=Math.max(i,t.endPTS),a=Math.min(a,t.startDTS),n=Math.max(n,t.endDTS)),r-t.start),l=(t.start=t.startPTS=r,t.maxStartPTS=l,t.endPTS=i,t.minEndPTS=d,t.startDTS=a,t.endDTS=n,t.duration=i-r,t.sn);if(!e||l<e.startSN||l>e.endSN)return 0;for(d=l-e.startSN,(s=e.fragments)[d]=t,o=d;0<o;o--)ve(s,o,o-1);for(o=d;o<s.length-1;o++)ve(s,o,o+1);return e.PTSKnown=!0,u}function Ee(e,r){r.initSegment&&e.initSegment&&(r.initSegment=e.initSegment);var i,a=0;if(Te(e,r,function(e,t){a=e.cc-t.cc,Object(k.isFiniteNumber)(e.startPTS)&&(t.start=t.startPTS=e.startPTS,t.endPTS=e.endPTS,t.duration=e.duration,t.backtracked=e.backtracked,t.dropped=e.dropped,i=t),r.PTSKnown=!0}),r.PTSKnown){if(a){C.logger.log("discontinuity sliding from playlist, take drift into account");for(var t=r.fragments,n=0;n<t.length;n++)t[n].cc+=a}if(i)ye(r,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS);else{var s=e,o=r,l=o.startSN-s.startSN,d=s.fragments,u=o.fragments;if(!(l<0||l>d.length))for(var c=0;c<u.length;c++)u[c].start+=d[l].start}r.PTSKnown=e.PTSKnown}}function Te(e,t,r){if(e&&t)for(var i=Math.max(e.startSN,t.startSN)-t.startSN,a=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,s=i;s<=a;s++){var o=e.fragments[n+s],l=t.fragments[s];if(!o||!l)break;r(o,l,s)}}function Se(e,t,r){var i=1e3*(t.averagetargetduration||t.targetduration),a=i/2;return e&&t.endSN===e.endSN&&(i=a),r&&(i=Math.max(a,i-(window.performance.now()-r))),Math.round(i)}var be={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 _e(e,t){e=e.fragments,t=t.fragments;if(t.length&&e.length){e=function(e,t){for(var r=null,i=0;i<e.length;i+=1){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}(e,t[0].cc);if(e&&e.startPTS)return e;C.logger.log("No frag in previous level to align on")}else C.logger.log("No fragments to align")}function Ae(r,e){e.fragments.forEach(function(e){var t;e&&(t=e.start+r,e.start=e.startPTS=t,e.endPTS=t+e.duration)}),e.PTSKnown=!0}function Re(e,t,r){var i,a;(function(e,t,r){var i=!1;return i=t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)?!0:i})(e=e,i=t,a=r)&&(e=_e(i.details,a))&&(C.logger.log("Adjusting PTS using last level due to CC increase within current level"),Ae(e.start,a)),!r.PTSKnown&&t&&(i=r,e=t.details)&&e.fragments.length&&i.hasProgramDateTime&&e.hasProgramDateTime&&(a=e.fragments[0].programDateTime,a=(i.fragments[0].programDateTime-a)/1e3+e.fragments[0].start,Object(k.isFiniteNumber)(a))&&(C.logger.log("adjusting PTS using programDateTime delta, sliding:"+a.toFixed(3)),Ae(a,i))}function we(e,t,r){if(null!==t&&Array.isArray(e)&&e.length&&Object(k.isFiniteNumber)(t)){var i=e[0].programDateTime;if(!(t<(i||0))){i=e[e.length-1].endProgramDateTime;if(!((i||0)<=t)){r=r||0;for(var a=0;a<e.length;++a){var n=e[a];if(function(e,t,r){t=1e3*Math.min(t,r.duration+(r.deltaPTS||0));return(r.endProgramDateTime||0)-t>e}(t,r,n))return n}}}}return null}function De(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;return e?a=t[e.sn-t[0].sn+1]:0===r&&0===t[0].start&&(a=t[0]),(!a||0!==E(r,i,a))&&le.search(t,E.bind(null,r,i))||a}function E(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);t=Math.min(t,r.duration+(r.deltaPTS||0));return r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0}var Le=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,a=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,a!==e)this.moved=!0,null!==i&&(this.stallReported&&(e=self.performance.now()-i,C.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(e)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0);else if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){e=y.bufferInfo(r,a,0),o=0<e.len,s=e.nextStart||0;if(o||s){if(n){var o=2<e.len,l=!s||2<s-a&&!this.fragmentTracker.getPartialFragment(a);if(o||l)return;this.moved=!1}if(!this.moved&&this.stalled){o=Math.max(s,e.start||0)-a;if(0<o&&o<=2)return void this._trySkipBufferHole(null)}l=self.performance.now();null===i?this.stalled=l:(s=l-i,!n&&250<=s&&this._reportStall(e.len),o=y.bufferInfo(r,a,t.maxBufferHole),this._tryFixBufferStall(o,s))}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media.currentTime,i=i.getPartialFragment(a);if(i&&this._trySkipBufferHole(i))return;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(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s<i.buffered.length;s++){var o=i.buffered.start(s);if(a+t.maxBufferHole>=n&&a<o)return o=Math.max(o+.05,i.currentTime+.1),C.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+o),this.moved=!0,this.stalled=null,i.currentTime=o,e&&r.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+o,frag:e}),o;n=i.buffered.end(s)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=r.currentTime,a=(this.nudgeRetry||0)+1;(this.nudgeRetry=a)<e.nudgeMaxRetry?(a=i+a*e.nudgeOffset,C.logger.warn("Nudging 'currentTime' from "+i+" to "+a),r.currentTime=a,t.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})):(C.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0}))},e}();r=function(a){var e;function t(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return(e=a.call.apply(a,[this,e].concat(r))||this)._boundTick=void 0,e._tickTimer=null,e._tickInterval=null,e._tickCallCount=0,e._boundTick=e.tick.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)),e}e=a,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},r.hasInterval=function(){return!!this._tickInterval},r.hasNextTick=function(){return!!this._tickTimer},r.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},r.clearInterval=function(){return!(!this._tickInterval||(self.clearInterval(this._tickInterval),this._tickInterval=null))},r.clearNextTick=function(){return!(!this._tickTimer||(self.clearTimeout(this._tickTimer),this._tickTimer=null))},r.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},r.doTick=function(){},t}(s);var l="STOPPED",ke="STARTING",T="IDLE",Ce="PAUSED",S="KEY_LOADING",b="FRAG_LOADING",Oe="FRAG_LOADING_WAITING_RETRY",Ie="WAITING_TRACK",u="PARSING",d="PARSED",_="BUFFER_FLUSHING",Pe="ENDED",A="ERROR",xe="WAITING_INIT_PTS",Fe="WAITING_LEVEL",i=function(e){var t;function r(){return e.apply(this,arguments)||this}t=e,(i=r).prototype=Object.create(t.prototype),(i.prototype.constructor=i).__proto__=t;var i=r.prototype;return i.doTick=function(){},i.startLoad=function(){},i.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=l},i._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;return!(t.live||!r||r.backtracked||r.sn!==t.endSN||e.nextStart||(t=i.getState(r))!==ne&&t!==se)},i.onMediaSeeking=function(){var e,t,r=this.config,i=this.media,a=this.mediaBuffer,n=this.state,s=i?i.currentTime:null,a=y.bufferInfo(a||i,s,this.config.maxBufferHole);C.logger.log("media seeking to "+(Object(k.isFiniteNumber)(s)?s.toFixed(3):s)),n===b?(e=this.fragCurrent,0===a.len&&e&&(r=r.maxFragLookUpTolerance,t=e.start-r,r=e.start+e.duration+r,s<t||r<s?(e.loader&&(C.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=T):C.logger.log("seeking outside of buffer but within currently loaded fragment range"))):n===Pe&&(0===a.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=T),i&&(this.lastCurrentTime=s),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=s),this.tick()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},i.onHandlerDestroyed=function(){this.state=l,this.fragmentTracker=null},i.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)},r}(r);function Me(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,Ue=function(i){function e(e,t){var r=i.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHING,v.default.MANIFEST_LOADING,v.default.MANIFEST_PARSED,v.default.LEVEL_LOADED,v.default.LEVELS_UPDATED,v.default.KEY_LOADED,v.default.FRAG_LOADED,v.default.FRAG_LOAD_EMERGENCY_ABORTED,v.default.FRAG_PARSING_INIT_SEGMENT,v.default.FRAG_PARSING_DATA,v.default.FRAG_PARSED,v.default.ERROR,v.default.AUDIO_TRACK_SWITCHING,v.default.AUDIO_TRACK_SWITCHED,v.default.BUFFER_CREATED,v.default.BUFFER_APPENDED,v.default.BUFFER_FLUSHED)||this;return r.fragmentTracker=t,r.config=e.config,r.audioCodecSwap=!1,r._state=l,r.stallReported=!1,r.gapController=null,r.altAudio=!1,r.audioOnly=!1,r.bitrateTest=!1,r}t=i,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,r,a=e.prototype;return a.startLoad=function(e){var t,r,i;this.levels?(t=this.lastCurrentTime,r=this.hls,this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,this.startFragRequested||(-1===(i=r.startLevel)&&(r.config.testBandwidth?this.bitrateTest=!(i=0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1),0<t&&-1===e&&(C.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=T,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()):(this.forceStartLoad=!0,this.state=l)},a.stopLoad=function(){this.forceStartLoad=!1,i.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case _:this.fragLoadError=0;break;case T:this._doTickIdle();break;case Fe:var e=this.levels[this.level];e&&e.details&&(this.state=T);break;case Oe:var e=window.performance.now(),t=this.retryDate;(!t||t<=e||this.media&&this.media.seeking)&&(C.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=T)}this._checkBuffer(),this._checkFragmentChanged()},a._doTickIdle=function(){var e,t,r,i,a=this.hls,n=a.config,s=this.media;void 0!==this.levelLastLoaded&&(s||!this.startFragRequested&&n.startFragPrefetch)&&(this.altAudio&&this.audioOnly?this.demuxer.frag=null:(e=this.loadedmetadata?s.currentTime:this.nextLoadPosition,t=a.nextLoadLevel,(r=this.levels[t])&&(i=(i=r.bitrate)?Math.max(8*n.maxBufferSize/i,n.maxBufferLength):n.maxBufferLength,i=Math.min(i,n.maxMaxBufferLength),n=e<n.maxBufferHole?Math.max(2,n.maxBufferHole):n.maxBufferHole,i<=(n=(s=y.bufferInfo(this.mediaBuffer||s,e,n)).len)||(C.logger.trace("buffer length of "+n.toFixed(3)+" is below max of "+i.toFixed(3)+". checking for more payload ..."),this.level=a.nextLoadLevel=t,!(n=r.details)||n.live&&this.levelLastLoaded!==t?this.state=Fe:this._streamEnded(s,n)?(i={},this.altAudio&&(i.type="video"),this.hls.trigger(v.default.BUFFER_EOS,i),this.state=Pe):this._fetchPayloadOrEos(e,s,n)))))},a._fetchPayloadOrEos=function(e,t,r){var i=this.fragPrevious,a=(this.level,r.fragments),n=a.length;if(0!==n){var s,o=a[0].start,l=a[n-1].start+a[n-1].duration,t=t.end;if(r.initSegment&&!r.initSegment.data)s=r.initSegment;else if(r.live){var d=this.config.initialLiveManifestSize;if(n<d)return void C.logger.warn("Can not start playback of a level, reason: not enough fragments "+n+" < "+d);if(null===(s=this._ensureFragmentAtLivePoint(r,t,o,l,i,a)))return}else t<o&&(s=a[0]);(s=s||this._findFragment(o,i,n,a,t,l,r))&&(s.encrypted?this._loadKey(s,r):this._loadFragment(s,r,e,t))}},a._ensureFragmentAtLivePoint=function(e,t,r,i,a,n){var s,o=this.hls.config,l=this.media,d=1/0;return void 0!==o.liveMaxLatencyDuration?d=o.liveMaxLatencyDuration:Object(k.isFiniteNumber)(o.liveMaxLatencyDurationCount)&&(d=o.liveMaxLatencyDurationCount*e.targetduration),t<Math.max(r-o.maxFragLookUpTolerance,i-d)&&(t=d=this.liveSyncPosition=this.computeLivePosition(r,e),l&&!l.paused&&l.readyState&&l.duration>d&&d>l.currentTime&&(C.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+d.toFixed(3)),l.currentTime=d),this.nextLoadPosition=d),e.PTSKnown&&i<t&&l&&l.readyState?null:(this.startFragRequested&&!e.PTSKnown&&a&&(e.hasProgramDateTime?(C.logger.log("live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),s=we(n,a.endProgramDateTime,o.maxFragLookUpTolerance)):((r=a.sn+1)>=e.startSN&&r<=e.endSN&&(d=n[r-e.startSN],a.cc===d.cc)&&C.logger.log("live playlist, switching playlist, load frag with next SN: "+(s=d).sn),s||(s=le.search(n,function(e){return a.cc-e.cc}))&&C.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn))),s)},a._findFragment=function(e,t,r,i,a,n,s){var o,l=this.hls.config;return(a=a<n?De(t,i,a,a>n-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[r-1])&&(n=a.sn-s.startSN,r=t&&a.level===t.level,o=i[n-1],i=i[1+n],t)&&a.sn===t.sn&&(r&&!a.backtracked?a.sn<s.endSN?(r=t.deltaPTS)&&r>l.maxBufferHole&&t.dropped&&n?(a=o,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")):this.fragmentTracker.getState(a=i)!==se&&C.logger.log("Re-loading fragment with SN: "+a.sn):a=null:a.backtracked&&(i&&i.backtracked?(C.logger.warn("Already backtracked from fragment "+i.sn+", will not backtrack to fragment "+a.sn+". Loading fragment "+i.sn),a=i):(C.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),a.dropped=0,o?(a=o).backtracked=!0:n&&(a=null)))),a},a._loadKey=function(e,t){C.logger.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], level "+this.level),this.state=S,this.hls.trigger(v.default.KEY_LOADING,{frag:e})},a._loadFragment=function(e,t,r,i){var a=this.fragmentTracker.getState(e);"initSegment"!==(this.fragCurrent=e).sn&&(this.startFragRequested=!0),Object(k.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||a===ie||a===ne?(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(v.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new pe(this.hls,"main")),this.state=b):a===ae&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},a.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,n.MAIN)},a.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},a._checkFragmentChanged=function(){var e,t,r=this.media;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)&&(r=e)!==this.fragPlaying&&(this.hls.trigger(v.default.FRAG_CHANGED,{frag:r}),t=r.level,this.fragPlaying&&this.fragPlaying.level===t||this.hls.trigger(v.default.LEVEL_SWITCHED,{level:t}),this.fragPlaying=r)},a.immediateLevelSwitch=function(){C.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,(t=this.media)?(e=t.paused)||t.pause():e=!0,this.previouslyPaused=e);var e,t=this.fragCurrent;t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,0<e.currentTime&&y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},a.nextLevelSwitch=function(){var e,t,r=this.media;r&&r.readyState&&((t=this.getBufferedFrag(r.currentTime))&&1<t.startPTS&&this.flushMainBuffer(0,t.startPTS-1),t=!r.paused&&(t=this.hls.nextLoadLevel,t=this.levels[t],e=this.fragLastKbps)&&this.fragCurrent?this.fragCurrent.duration*t.bitrate/(1e3*e)+1:0,e=this.getBufferedFrag(r.currentTime+t))&&(r=this.followingBufferedFrag(e))&&((t=this.fragCurrent)&&t.loader&&t.loader.abort(),this.fragCurrent=null,t=Math.max(e.endPTS,r.maxStartPTS+Math.min(this.config.maxFragLookUpTolerance,r.duration)),this.flushMainBuffer(t,Number.POSITIVE_INFINITY))},a.flushMainBuffer=function(e,t){this.state=_;e={startOffset:e,endOffset:t};this.altAudio&&(e.type="video"),this.hls.trigger(v.default.BUFFER_FLUSHING,e)},a.onMediaAttached=function(e){var e=this.media=this.mediaBuffer=e.media,t=(this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended),this.config);this.levels&&t.autoStartLoad&&this.hls.startLoad(t.startPosition),this.gapController=new Le(t,e,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var e=this.media,t=(e&&e.ended&&(C.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),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()},a.onMediaSeeked=function(){var e=this.media,e=e?e.currentTime:void 0;Object(k.isFiniteNumber)(e)&&C.logger.log("media seeked to "+e.toFixed(3)),this.tick()},a.onManifestLoading=function(){C.logger.log("trigger BUFFER_RESET"),this.hls.trigger(v.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},a.onManifestParsed=function(e){var t,r=!1,i=!1,e=(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,this.config);(e.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(e.startPosition)},a.onLevelLoaded=function(e){var t,r=e.details,e=e.level,i=this.levels[this.levelLastLoaded],a=this.levels[e],n=r.totalduration,s=0;C.logger.log("level "+e+" loaded ["+r.startSN+","+r.endSN+"],duration:"+n),r.live?(t=a.details)&&0<r.fragments.length?(Ee(t,r),s=r.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,t),r.PTSKnown&&Object(k.isFiniteNumber)(s)?C.logger.log("live playlist sliding:"+s.toFixed(3)):(C.logger.log("live playlist - outdated PTS, unknown sliding"),Re(this.fragPrevious,i,r))):(C.logger.log("live playlist - first load, unknown sliding"),r.PTSKnown=!1,Re(this.fragPrevious,i,r)):r.PTSKnown=!1,a.details=r,this.levelLastLoaded=e,this.hls.trigger(v.default.LEVEL_UPDATED,{details:r,level:e}),!1===this.startFragRequested&&(-1!==this.startPosition&&-1!==this.lastCurrentTime||(t=r.startTimeOffset,Object(k.isFiniteNumber)(t)?(t<0&&(C.logger.log("negative start time offset "+t+", count from end of last fragment"),t=s+n+t),C.logger.log("start time offset found in playlist, adjust startPosition to "+t),this.startPosition=t):r.live?(this.startPosition=this.computeLivePosition(s,r),C.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition),this.nextLoadPosition=this.startPosition),this.state===Fe&&(this.state=T),this.tick()},a.onKeyLoaded=function(){this.state===S&&(this.state=T,this.tick())},a.onFragLoaded=function(e){var t,r,i=this.fragCurrent,a=this.hls,n=this.levels,s=this.media,o=e.frag;this.state===b&&i&&"main"===o.type&&o.level===i.level&&o.sn===i.sn&&(r=e.stats,t=(n=n[i.level]).details,this.bitrateTest=!1,this.stats=r,C.logger.log("Loaded "+i.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i.level),o.bitrateTest&&a.nextLoadLevel?(this.state=T,this.startFragRequested=!1,r.tparsed=r.tbuffered=window.performance.now(),a.trigger(v.default.FRAG_BUFFERED,{stats:r,frag:i,id:"main"}),this.tick()):"initSegment"===o.sn?(this.state=T,r.tparsed=r.tbuffered=window.performance.now(),t.initSegment.data=e.payload,a.trigger(v.default.FRAG_BUFFERED,{stats:r,frag:i,id:"main"}),this.tick()):(C.logger.log("Parsing "+i.sn+" of ["+t.startSN+" ,"+t.endSN+"],level "+i.level+", cc "+i.cc),this.state=u,this.pendingBuffering=!0,this.appended=!1,o.bitrateTest&&(o.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:o})),a=!(s&&s.seeking)&&(t.PTSKnown||!t.live),r=t.initSegment?t.initSegment.data:[],o=this._getAudioCodec(n),(this.demuxer=this.demuxer||new pe(this.hls,"main")).push(e.payload,r,o,n.videoCodec,i,t.totalduration,a))),this.fragLoadError=0},a.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===u){var i,a,n=e.tracks;for(i in this.audioOnly=n.audio&&!n.video,this.altAudio&&!this.audioOnly&&delete n.audio,(a=n.audio)&&(r=this.levels[this.level].audioCodec,t=navigator.userAgent.toLowerCase(),r&&this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),r=-1!==r.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===t.indexOf("firefox")&&(r="mp4a.40.5"),-1!==t.indexOf("android")&&"audio/mpeg"!==a.container&&C.logger.log("Android: force audio codec to "+(r="mp4a.40.2")),a.levelCodec=r,a.id=e.id),(a=n.video)&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=e.id),this.hls.trigger(v.default.BUFFER_CODECS,n),n){a=n[i],C.logger.log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var s=a.initSegment;s&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(v.default.BUFFER_APPENDING,{type:i,data:s,parent:"main",content:"initSegment"}))}this.tick()}},a.onFragParsingData=function(t){var r=this,e=this.fragCurrent,i=t.frag;if(e&&"main"===t.id&&i.sn===e.sn&&i.level===e.level&&("audio"!==t.type||!this.altAudio)&&this.state===u){var i=this.levels[this.level],a=e;if(Object(k.isFiniteNumber)(t.endPTS)||(t.endPTS=t.startPTS+e.duration,t.endDTS=t.startDTS+e.duration),!0===t.hasAudio&&a.addElementaryStream(o.AUDIO),!0===t.hasVideo&&a.addElementaryStream(o.VIDEO),C.logger.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(a.dropped=t.dropped,a.dropped)if(a.backtracked)C.logger.warn("Already backtracked on this fragment, appending with the gap",a.sn);else{e=i.details;if(!e||a.sn!==e.startSN)return C.logger.warn("missing video frame(s), backtracking fragment",a.sn),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=T,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 e=ye(i.details,a,t.startPTS,t.endPTS,t.startDTS,t.endDTS),n=this.hls;n.trigger(v.default.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:e,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(e){e&&e.length&&r.state===u&&(r.appended=!0,r.pendingBuffering=!0,n.trigger(v.default.BUFFER_APPENDING,{type:t.type,data:e,parent:"main",content:"data"}))}),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===u&&(this.stats.tparsed=window.performance.now(),this.state=d,this._checkAppendedParsed())},a.onAudioTrackSwitching=function(e){var t=this.altAudio,r=!!e.url,e=e.id;r||(this.mediaBuffer!==this.media&&(C.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media,(r=this.fragCurrent).loader&&(C.logger.log("switching to main audio track, cancel main fragment load"),r.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=T),r=this.hls,t&&r.trigger(v.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),r.trigger(v.default.AUDIO_TRACK_SWITCHED,{id:e}))},a.onAudioTrackSwitched=function(e){var t,e=e.id,e=!!this.hls.audioTracks[e].url;e&&(t=this.videoBuffer)&&this.mediaBuffer!==t&&(C.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t),this.altAudio=e,this.tick()},a.onBufferCreated=function(e){var t,r,i,a=e.tracks,n=!1;for(i in a){var s=a[i];"main"===s.id?(t=s,"video"===(r=i)&&(this.videoBuffer=a[i].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},a.onBufferAppended=function(e){var t;"main"!==e.parent||(t=this.state)!==u&&t!==d||(this.pendingBuffering=0<e.pending,this._checkAppendedParsed())},a._checkAppendedParsed=function(){var e,t;this.state!==d||this.appended&&this.pendingBuffering||((e=this.fragCurrent)&&(t=this.mediaBuffer||this.media,C.logger.log("main buffered : "+be.toString(t.buffered)),this.fragPrevious=e,(t=this.stats).tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*t.total/(t.tbuffered-t.tfirst)),this.hls.trigger(v.default.FRAG_BUFFERED,{stats:t,frag:e,id:"main"}),this.state=T),(this.loadedmetadata||this.startPosition<=0)&&this.tick())},a.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r,i=!!this.media&&y.isBuffered(this.media,this.media.currentTime)&&y.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:e.fatal||(this.fragLoadError+1<=this.config.fragLoadingMaxRetry?(r=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout),C.logger.warn("mediaController: frag loading failed, retry in "+r+" ms"),this.retryDate=window.performance.now()+r,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=Oe):(C.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=A));break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==A&&(e.fatal?(this.state=A,C.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==Fe||(this.state=T));break;case p.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==u&&this.state!==d||(i?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=T):(C.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},a._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)},a._checkBuffer=function(){var e=this.media;e&&0!==e.readyState&&(e=(this.mediaBuffer||e).buffered,!this.loadedmetadata&&e.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,e))},a.onFragLoadEmergencyAborted=function(){this.state=T,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},a.onBufferFlushed=function(){var e,t=this.mediaBuffer||this.media;t&&(e=this.audioOnly?o.AUDIO:o.VIDEO,this.fragmentTracker.detectEvictedFragments(e,t.buffered)),this.state=T,this.fragPrevious=null},a.onLevelsUpdated=function(e){this.levels=e.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a._seekToStartPos=function(){var e,t=this.media,r=t.currentTime,i=this.startPosition;r!==i&&0<=i&&(t.seeking?C.logger.log("could not seek to "+i+", already seeking at "+r):(0<(e=(t.buffered.length?t.buffered.start(0):0)-i)&&e<this.config.maxBufferHole&&(C.logger.log("adjusting start position by "+e+" to match buffer start"),this.startPosition=i+=e),C.logger.log("seek to target start position "+i+" from current time "+r+". ready state "+t.readyState),t.currentTime=i))},a._getAudioCodec=function(e){e=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),e=e&&(-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),e},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,C.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(v.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e}))},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){e=this.getBufferedFrag(e.currentTime);if(e)return e.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}}])&&Me(t.prototype,a),r&&Me(t,r),e}(i);function Be(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 Ge=function(t){function e(e){e=t.call(this,e,v.default.MANIFEST_LOADED,v.default.LEVEL_LOADED,v.default.AUDIO_TRACK_SWITCHED,v.default.FRAG_LOADED,v.default.ERROR)||this;return e.canload=!1,e.currentLevelIndex=null,e.manualLevelIndex=-1,e.timer=null,Ne=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},a.clearTimer=function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},a.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()},a.stopLoad=function(){this.canload=!1},a.onManifestLoaded=function(e){var t,r=[],i=[],a={},n=null,s=!1,o=!1;if(e.levels.forEach(function(e){var t=e.attrs;e.loadError=0,e.fragmentError=!1,s=s||!!e.videoCodec,o=o||!!e.audioCodec,Ne&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(n=a[e.bitrate])?n.url.push(e.url):(e.url=[e.url],e.urlId=0,a[e.bitrate]=e,r.push(e)),t&&(t.AUDIO&&me(n||e,"audio",t.AUDIO),t.SUBTITLES)&&me(n||e,"text",t.SUBTITLES)}),r=(r=s&&o?r.filter(function(e){return!!e.videoCodec}):r).filter(function(e){var t=e.audioCodec,e=e.videoCodec;return(!t||q(t,"audio"))&&(!e||q(e,"video"))}),e.audioTracks&&(i=e.audioTracks.filter(function(e){return!e.audioCodec||q(e.audioCodec,"audio")})).forEach(function(e,t){e.id=t}),0<r.length){t=r[0].bitrate,r.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=r;for(var l=0;l<r.length;l++)if(r[l].bitrate===t){this._firstLevel=l,C.logger.log("manifest loaded,"+r.length+" level(s) found, first bitrate:"+t);break}var d=o&&!s;this.hls.trigger(v.default.MANIFEST_PARSED,{levels:r,audioTracks:i,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:s,altAudio:!d&&i.some(function(e){return!!e.url})})}else this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},a.setLevelInternal=function(e){var t,r=this._levels,i=this.hls;0<=e&&e<r.length?(this.clearTimer(),this.currentLevelIndex!==e&&(C.logger.log("switching to level "+e),(t=r[this.currentLevelIndex=e]).level=e,i.trigger(v.default.LEVEL_SWITCHING,t)),(r=(t=r[e]).details)&&!r.live||(r=t.urlId,i.trigger(v.default.LEVEL_LOADING,{url:t.url[r],level:e,id:r}))):i.trigger(v.default.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})},a.onError=function(e){if(e.fatal)e.type===p.ErrorTypes.NETWORK_ERROR&&this.clearTimer();else{var t,r=!1,i=!1;switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:t=e.frag.level,i=!0;break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:t=e.context.level,r=!0;break;case p.ErrorDetails.REMUX_ALLOC_ERROR:t=e.level,r=!0}void 0!==t&&this.recoverLevel(e,t,r,i)}},a.recoverLevel=function(e,t,r,i){var a=this,n=this.hls.config,s=e.details,o=this._levels[t];if(o.loadError++,o.fragmentError=i,r){if(!(this.levelRetryCount+1<=n.levelLoadingMaxRetry))return C.logger.error("level controller, cannot recover from "+s+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);n=Math.min(Math.pow(2,this.levelRetryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return a.loadLevel()},n),e.levelRetry=!0,this.levelRetryCount++,C.logger.warn("level controller, "+s+", retry in "+n+" ms, current retry count is "+this.levelRetryCount)}(r||i)&&(1<(e=o.url.length)&&o.loadError<e?(o.urlId=(o.urlId+1)%e,o.details=void 0,C.logger.warn("level controller, "+s+" for level "+t+": switching to redundant URL-id "+o.urlId)):-1===this.manualLevelIndex?(n=0===t?this._levels.length-1:t-1,C.logger.warn("level controller, "+s+": switch to "+n),this.hls.nextAutoLevel=this.currentLevelIndex=n):i&&(C.logger.warn("level controller, "+s+": reload a fragment"),this.currentLevelIndex=null))},a.onFragLoaded=function(e){var e=e.frag;void 0!==e&&"main"===e.type&&void 0!==(e=this._levels[e.level])&&(e.fragmentError=!1,e.loadError=0,this.levelRetryCount=0)},a.onLevelLoaded=function(e){var t=this,r=e.level,i=e.details;r===this.currentLevelIndex&&((r=this._levels[r]).fragmentError||(r.loadError=0,this.levelRetryCount=0),i.live?(r=Se(r.details,i,e.stats.trequest),C.logger.log("live playlist, reload in "+Math.round(r)+" ms"),this.timer=setTimeout(function(){return t.loadLevel()},r)):this.clearTimer())},a.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,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===t){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},a.loadLevel=function(){var e,t,r;C.logger.debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload&&"object"==typeof(r=this._levels[this.currentLevelIndex])&&0<r.url.length&&(e=this.currentLevelIndex,t=r.urlId,r=r.url[t],C.logger.log("Attempt loading level index "+e+" with URL-id "+t),this.hls.trigger(v.default.LEVEL_LOADING,{url:r,level:e,id:t}))},a.removeLevel=function(r,i){var e=this.levels.filter(function(e,t){return t!==r||1<e.url.length&&void 0!==i&&(e.url=e.url.filter(function(e,t){return t!==i}),!(e.urlId=0))}).map(function(e,t){var r=e.details;return r&&r.fragments&&r.fragments.forEach(function(e){e.level=t}),e});this._levels=e,this.hls.trigger(v.default.LEVELS_UPDATED,{levels:e})},r=e,(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(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel: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)}}])&&Be(r.prototype,a),i&&Be(r,i),e}(s),je=t("./src/demux/id3.js");function Ke(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 c(e){if(null!=e&&e.cues)for(;0<e.cues.length;)e.removeCue(e.cues[0])}var He=function(t){var e;function r(e){e=t.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHING,v.default.FRAG_PARSING_METADATA,v.default.LIVE_BACK_BUFFER_REACHED)||this;return e.id3Track=void 0,e.media=void 0,e}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){s.prototype.destroy.call(this)},i.onMediaAttached=function(e){this.media=e.media,this.media},i.onMediaDetaching=function(){c(this.id3Track),this.id3Track=void 0,this.media=void 0},i.getID3Track=function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Ke(r,this.media),r}return this.media.addTextTrack("metadata","id3")},i.onFragParsingMetadata=function(e){for(var t=e.frag,r=e.samples,i=(this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden"),window.WebKitDataCue||window.VTTCue||window.TextTrackCue),a=0;a<r.length;a++){var n=je.default.getID3Frames(r[a].data);if(n){var s=Math.max(r[a].pts,0),o=a<r.length-1?r[a+1].pts:t.endPTS;(o=o||t.start+t.duration)-s<=0&&(o=s+.25);for(var l=0;l<n.length;l++){var d,u=n[l];je.default.isTimeStampFrame(u)||((d=new i(s,o,"")).value=u,this.id3Track.addCue(d))}}}},i.onLiveBackBufferReached=function(e){var e=e.bufferEnd,t=this.id3Track;if(t&&t.cues&&t.cues.length){var r=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 a=Math.floor((i+r)/2);if(t<e[a].endTime)i=a-1;else{if(!(t>e[a].endTime))return e[a];r=a+1}}return e[r].endTime-t<t-e[i].endTime?e[r]:e[i]}(t.cues,e);if(r)for(;t.cues[0]!==r;)t.removeCue(t.cues[0])}},r}(s);var Ve=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(){var e;return this.alpha_?(e=1-Math.pow(this.alpha_,this.totalWeight_),this.estimate_/e):this.estimate_},e}(),Ye=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 Ve(t),this.fast_=new Ve(r),this.cacheMissTotalBits=0,this.cacheMissTotalTime=0,this.cacheHitTotalBits=0,this.cacheHitTotalTime=0,this.totalContentDownloadTime=0}var t=e.prototype;return t.sample=function(e,t,r,i){var t=8*t,e=(e=Math.max(e,this.minDelayMs_))/1e3,a=t/e;null!=i&&(this.totalContentDownloadTime+=i),r?(this.cacheMissTotalBits+=t,this.cacheMissTotalTime+=e,0!=this.cacheMissTotalBits&&(i=this.defaultEstimate_,0==this.cacheHitTotalBits&&0!=this.totalContentDownloadTime?(r=this.totalContentDownloadTime/1e3,i=this.cacheMissTotalBits/r):0!=this.cacheHitTotalBits&&0!=this.cacheHitTotalTime&&(i=this.cacheHitTotalBits/this.cacheHitTotalTime),a+=a*(i/(0!=this.cacheMissTotalTime?this.cacheMissTotalBits/this.cacheMissTotalTime:this.defaultEstimate_)))):(this.cacheHitTotalBits+=t,this.cacheHitTotalTime+=e),this.fast_.sample(e,a),this.slow_.sample(e,a)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.max(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function We(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=window.performance,Xe=function(r){function e(e){var t=r.call(this,e,v.default.FRAG_LOADING,v.default.FRAG_LOADED,v.default.FRAG_BUFFERED,v.default.ERROR)||this;return t.lastLoadedFragLevel=0,t._nextAutoLevel=-1,t.hls=e,t.timer=null,t._bwEstimator=null,t.onCheck=t._abandonRulesCheck.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)),t}t=r,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,i,a=e.prototype;return a.destroy=function(){this.clearTimer(),s.prototype.destroy.call(this)},a.onFragLoading=function(e){var t,r,i,e=e.frag;"main"===e.type&&(this.timer||(this.fragCurrent=e,this.timer=setInterval(this.onCheck,100)),this._bwEstimator||(r=(t=this.hls).config,e=e.level,e=t.levels[e].details.live?(i=r.abrEwmaFastLive,r.abrEwmaSlowLive):(i=r.abrEwmaFastVoD,r.abrEwmaSlowVoD),this._bwEstimator=new Ye(t,e,i,r.abrEwmaDefaultEstimate)))},a._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)C.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;else{var a=i.stats;if(t&&a&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var n=qe.now()-a.trequest,s=Math.abs(t.playbackRate);if(n>500*r.duration/s){var o=e.levels,l=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/n),d=o[r.level];if(d){var d=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,d=a.total||Math.max(a.loaded,Math.round(r.duration*d/8)),u=t.currentTime,d=(d-a.loaded)/l,c=(y.bufferInfo(t,u,e.config.maxBufferHole).end-u)/s;if(c<2*r.duration/s&&c<d){for(var h=e.minAutoLevel,f=r.level-1;h<f;f--){var g=o[f].realBitrate?Math.max(o[f].realBitrate,o[f].bitrate):o[f].bitrate;if(r.duration*g/(6.4*l)<c)break}void 0<d&&(C.logger.warn("loading too slow, abort fragment loading and switch to level "+f+":fragLoadedDelay["+f+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+(void 0).toFixed(1)+"<"+d.toFixed(1)+":"+c.toFixed(1)),e.nextLoadLevel=f,this._bwEstimator.sample(n,a.loaded),i.abort(),this.clearTimer(),e.trigger(v.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:a}))}}}}}}},a.onFragLoaded=function(e){var t,r,i=e.frag;"main"===i.type&&Object(k.isFiniteNumber)(i.sn)&&(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate&&(t=((i=this.hls.levels[i.level]).loaded?i.loaded.bytes:0)+e.stats.loaded,r=(i.loaded?i.loaded.duration:0)+e.frag.duration,i.loaded={bytes:t,duration:r},i.realBitrate=Math.round(8*t/r)),e.frag.bitrateTest)&&((i=e.stats).tparsed=i.tbuffered=i.tload,this.onFragBuffered(e))},a.onFragBuffered=function(e){var t,r=e.stats,e=e.frag;!0===r.aborted||"main"!==e.type||!Object(k.isFiniteNumber)(e.sn)||e.bitrateTest&&r.tload!==r.tbuffered||(t=r.tparsed-r.trequest,C.logger.log("latency/loading/parsing/append/kbps:"+Math.round(r.tfirst-r.trequest)+"/"+Math.round(r.tload-r.tfirst)+"/"+Math.round(r.tparsed-r.tload)+"/"+Math.round(r.tbuffered-r.tparsed)+"/"+Math.round(8*r.loaded/(r.tbuffered-r.trequest))),this._bwEstimator.sample(t,r.loaded,r.isCacheMiss,r.loadtime),r.bwEstimate=this._bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=t/1e3:this.bitrateTestDelay=0)},a.onError=function(e){switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},a.clearTimer=function(){clearInterval(this.timer),this.timer=null},a._findBestLevel=function(e,t,r,i,a,n,s,o,l){for(var d=a;i<=d;d--){var u=l[d];if(u){var u=u.details,c=u?u.totalduration/u.fragments.length:t,u=!!u&&u.live,h=void 0,h=d<=e?s*r:o*r,f=l[d].realBitrate?Math.max(l[d].realBitrate,l[d].bitrate):l[d].bitrate,g=f*c/h;if(C.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+d+"/"+Math.round(h)+"/"+f+"/"+c+"/"+n+"/"+g),f<h&&(!g||u&&!this.bitrateTestDelay||g<n))return d}}return-1},t=e,(a=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;return-1===e||t&&t.canEstimate()?(t=this._nextABRAutoLevel,-1!==e?Math.min(e,t):t):e},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e,t,r,i=this.hls,a=i.maxAutoLevel,n=i.levels,s=i.config,o=i.minAutoLevel,i=i.media,l=this.lastLoadedFragLevel,d=this.fragCurrent?this.fragCurrent.duration:0,u=i?i.currentTime:0,c=i&&0!==i.playbackRate?Math.abs(i.playbackRate):1,h=this._bwEstimator?this._bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,i=(y.bufferInfo(i,u,s.maxBufferHole).end-u)/c,u=this._findBestLevel(l,d,h,o,a,i,s.abrBandWidthFactor,s.abrBandWidthUpFactor,n);return 0<=u?u:(C.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering"),c=d?Math.min(d,s.maxStarvationDelay):s.maxStarvationDelay,e=s.abrBandWidthFactor,t=s.abrBandWidthUpFactor,0==i&&(r=this.bitrateTestDelay)&&(c=(d?Math.min(d,s.maxLoadingDelay):s.maxLoadingDelay)-r,C.logger.trace("bitrate test took "+Math.round(1e3*r)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),e=t=1),u=this._findBestLevel(l,d,h,o,a,i+c,e,t,n),Math.max(u,0))}}])&&We(t.prototype,a),i&&We(t,i),e}(s);var ze=ce(),Je=function(t){var e;function r(e){var s=t.call(this,e,v.default.MEDIA_ATTACHING,v.default.MEDIA_DETACHING,v.default.MANIFEST_PARSED,v.default.BUFFER_RESET,v.default.BUFFER_APPENDING,v.default.BUFFER_CODECS,v.default.BUFFER_EOS,v.default.BUFFER_FLUSHING,v.default.LEVEL_PTS_UPDATED,v.default.LEVEL_UPDATED)||this;return s._msDuration=null,s._levelDuration=null,s._levelTargetDuration=10,s._live=null,s._objectUrl=null,s._needsFlush=!1,s._needsEos=!1,s.config=void 0,s.audioTimestampOffset=void 0,s.bufferCodecEventsExpected=0,s._bufferCodecEventsTotal=0,s.media=null,s.mediaSource=null,s.segments=[],s.parent=void 0,s.appending=!1,s.appended=0,s.appendError=0,s.flushBufferCounter=0,s.tracks={},s.pendingTracks={},s.sourceBuffer={},s.flushRange=[],s._onMediaSourceOpen=function(){C.logger.log("media source opened"),s.hls.trigger(v.default.MEDIA_ATTACHED,{media:s.media});var e=s.mediaSource;e&&e.removeEventListener("sourceopen",s._onMediaSourceOpen),s.checkPendingTracks()},s._onMediaSourceClose=function(){C.logger.log("media source closed")},s._onMediaSourceEnded=function(){C.logger.log("media source ended")},s._onSBUpdateEnd=function(){s.audioTimestampOffset&&s.sourceBuffer.audio&&(t=s.sourceBuffer.audio,C.logger.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+s.audioTimestampOffset),t.timestampOffset=s.audioTimestampOffset,delete s.audioTimestampOffset),s._needsFlush&&s.doFlush(),s._needsEos&&s.checkEos(),s.appending=!1;var e,r=s.parent,t=s.segments.reduce(function(e,t){return t.parent===r?e+1:e},0),i={},a=s.sourceBuffer;for(e in a){var n=a[e];if(!n)throw Error("handling source buffer update end error: source buffer for "+e+" uninitilized and unable to update buffered TimeRanges.");i[e]=n.buffered}s.hls.trigger(v.default.BUFFER_APPENDED,{parent:r,pending:t,timeRanges:i}),s._needsFlush||s.doAppending(),s.updateMediaElementDuration(),0===t&&s.flushLiveBackBuffer()},s._onSBUpdateError=function(e){C.logger.error("sourceBuffer error:",e),s.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},s.config=e.config,s}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){s.prototype.destroy.call(this)},i.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){t=this.sourceBuffer.audio;if(!t)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(.1<Math.abs(t.timestampOffset-e.start)){r=t.updating;try{t.abort()}catch(e){C.logger.warn("can not abort audio buffer: "+e)}r?this.audioTimestampOffset=e.start:(C.logger.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+e.start),t.timestampOffset=e.start)}}},i.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")},i.onMediaAttaching=function(e){var t,e=this.media=e.media;e&&ze&&((t=this.mediaSource=new ze).addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),e.src=window.URL.createObjectURL(t),this._objectUrl=e.src)},i.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(v.default.MEDIA_DETACHED)},i.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())},i.onBufferReset=function(){var e,t=this.sourceBuffer;for(e in t){var r=t[e];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},i.onBufferCodecs=function(t){var r=this;Object.keys(this.sourceBuffer).length||(Object.keys(t).forEach(function(e){r.pendingTracks[e]=t[e]}),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.createSourceBuffers=function(e){var t,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(t in e)if(!r[t]){var a=e[t];if(!a)throw Error("source buffer exists for track "+t+", however track does not");var n=a.levelCodec||a.codec,s=a.container+";codecs="+n;C.logger.log("creating sourceBuffer("+s+")");try{var o=r[t]=i.addSourceBuffer(s);o.addEventListener("updateend",this._onSBUpdateEnd),o.addEventListener("error",this._onSBUpdateError),this.tracks[t]={buffer:o,codec:n,id:a.id,container:a.container,levelCodec:a.levelCodec}}catch(e){C.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:s})}}this.hls.trigger(v.default.BUFFER_CREATED,{tracks:this.tracks})},i.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},i.onBufferEos=function(e){for(var t in this.sourceBuffer){var r;e.type&&e.type!==t||(r=this.sourceBuffer[t])&&!r.ended&&(r.ended=!0,C.logger.log(t+" sourceBuffer now EOS"))}this.checkEos()},i.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){r=e[r];if(r){if(!r.ended)return;if(r.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},i.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()},i.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),a=t-Math.max(e,this._levelTargetDuration),n=i.length-1;0<=n;n--){var s,o=i[n],l=r[o];l&&0<(s=l.buffered).length&&a>s.start(0)&&this.removeBufferRange(o,l,0,a)&&this.hls.trigger(v.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}else C.logger.error("flushLiveBackBuffer called without attaching media")}},i.onLevelUpdated=function(e){e=e.details;0<e.fragments.length&&(this._levelDuration=e.totalduration+e.fragments[0].start,this._levelTargetDuration=e.averagetargetduration||e.targetduration||10,this._live=e.live,this.updateMediaElementDuration())},i.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){r=this.sourceBuffer[r];if(r&&!0===r.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(k.isFiniteNumber)(e))&&(C.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},i.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 a=r[i];a&&(t+=a.buffered.length)}}catch(e){C.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(v.default.BUFFER_FLUSHED)}},i.doAppending=function(){var t=this.config,r=this.hls,i=this.segments,a=this.sourceBuffer;if(Object.keys(a).length)if(!this.media||this.media.error)this.segments=[],C.logger.error("trying to append although a media error occured, flush segment and abort");else if(!this.appending){var n=i.shift();if(n)try{var e=a[n.type];e?e.updating?i.unshift(n):(e.ended=!1,this.parent=n.parent,e.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0):this._onSBUpdateEnd()}catch(e){C.logger.error("error while trying to append buffer:"+e.message),i.unshift(n);a={type:p.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===e.code?(this.segments=[],a.details=p.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,a.details=p.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.appendErrorMaxRetry&&(C.logger.log("fail "+t.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],a.fatal=!0)),r.trigger(v.default.ERROR,a)}}},i.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(Object.keys(i).length){var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),C.logger.log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)C.logger.warn("abort flushing too many retries");else{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}C.logger.log("buffer flushed")}}return!0},i.removeBufferRange=function(e,t,r,i){try{for(var a=0;a<t.buffered.length;a++){var n,s=t.buffered.start(a),o=t.buffered.end(a),l=Math.max(s,r),d=Math.min(o,i);if(.5<Math.min(d,o)-l)return n="null",this.media&&(n=this.media.currentTime.toString()),C.logger.log("sb remove "+e+" ["+l+","+d+"], of ["+s+","+o+"], pos:"+n),t.remove(l,d),!0}}catch(e){C.logger.warn("removeBufferRange failed",e)}return!1},r}(s);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(t){function a(e){e=t.call(this,e,v.default.FPS_DROP_LEVEL_CAPPING,v.default.MEDIA_ATTACHING,v.default.MANIFEST_PARSED,v.default.LEVELS_UPDATED,v.default.BUFFER_CODECS,v.default.MEDIA_DETACHING)||this;return e.autoLevelCapping=Number.POSITIVE_INFINITY,e.firstLevel=null,e.levels=[],e.media=null,e.restrictedLevels=[],e.timer=null,e.clientRect=null,e}e=t,(i=a).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var e,r,i=a.prototype;return i.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this.clientRect=null,this.stopCapping())},i.onFpsDropLevelCapping=function(e){a.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)},i.onMediaAttaching=function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null},i.onManifestParsed=function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},i.onBufferCodecs=function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},i.onLevelsUpdated=function(e){this.levels=e.levels},i.onMediaDetaching=function(){this.stopCapping()},i.detectPlayerSize=function(){var e,t;this.media&&(e=this.levels?this.levels.length:0)&&((t=this.hls).autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},i.getMaxLevel=function(r){var e,i=this;return this.levels?(e=this.levels.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r}),this.clientRect=null,a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)):-1},i.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())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},i.getDimensions=function(){var e,t,r;return this.clientRect||(t={width:0,height:0},(e=this.media)&&(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)),this.clientRect=t)},a.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,a=e.length-1,n=0;n<e.length;n+=1){var s=e[n];if((s.width>=t||s.height>=r)&&(s=s,!(i=e[n+1])||s.width!==i.width||s.height!==i.height)){a=n;break}}return a},e=a,i=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*a.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*a.contentScaleFactor}}])&&Ze(e.prototype,r),i&&Ze(e,i),a}(s);var $e=window.performance,et=function(t){var e;function r(e){return t.call(this,e,v.default.MEDIA_ATTACHING)||this}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},i.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))},i.checkFPS=function(e,t,r){var i,a,n,s,o=$e.now();t&&(this.lastTime&&(s=o-this.lastTime,i=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,s=1e3*i/s,(n=this.hls).trigger(v.default.FPS_DROP,{currentDropped:i,currentDecoded:a,totalDroppedFrames:r}),0<s)&&i>n.config.fpsDroppedMonitoringThreshold*a&&(s=n.currentLevel,C.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0<s)&&(-1===n.autoLevelCapping||n.autoLevelCapping>=s)&&(n.trigger(v.default.FPS_DROP_LEVEL_CAPPING,{level:s-=1,droppedLevel:n.currentLevel}),n.autoLevelCapping=s,n.streamController.nextLevelSwitch()),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},i.checkFPSInterval=function(){var e,t=this.video;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},r}(s),tt=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 t=this.context,r=this.loader=new window.XMLHttpRequest,i=this.stats,i=(i.tfirst=0,i.loaded=0,i.loadstart=0,i.loadend=0,this.xhrSetup);try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}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,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),r.send()},t.readystatechange=function(e){var t,r,e=e.currentTarget,i=e.readyState,a=this.stats,n=this.context,s=this.config;3!=i||a.loadstart&&0!=a.loadstart||(a.loadstart=window.performance.now()),a.aborted||2<=i&&(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(window.performance.now(),a.trequest)),4===i?200<=(i=e.status)&&i<300?(a.tload=Math.max(a.tfirst,window.performance.now()),a.loadend=window.performance.now(),a.loadtime=a.loadend-a.loadstart,r="arraybuffer"===n.responseType?(t=e.response).byteLength:(t=e.responseText).length,a.loaded=a.total=r,r={url:e.responseURL,data:t},this.callbacks.onSuccess(r,a,n,e)):a.retry>=s.maxRetry||400<=i&&i<499?(C.logger.error(i+" while loading "+n.url),this.callbacks.onError({code:i,text:e.statusText},n,e)):(C.logger.warn(i+" 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,s.maxRetryDelay),a.retry++):this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.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,e=(r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total),this.callbacks.onProgress);e&&e(r,this.context,null,t)},e}();function rt(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)}}r=function(t){function e(e){e=t.call(this,e,v.default.MANIFEST_LOADING,v.default.MANIFEST_PARSED,v.default.AUDIO_TRACK_LOADED,v.default.AUDIO_TRACK_SWITCHED,v.default.LEVEL_LOADED,v.default.ERROR)||this;return e._trackId=-1,e._selectDefaultTrack=!0,e.tracks=[],e.trackIdBlacklist=Object.create(null),e.audioGroupId=null,e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},a.onManifestParsed=function(e){e=this.tracks=e.audioTracks||[];this.hls.trigger(v.default.AUDIO_TRACKS_UPDATED,{audioTracks:e}),this._selectAudioGroup(this.hls.nextLoadLevel)},a.onAudioTrackLoaded=function(e){var t;e.id>=this.tracks.length?C.logger.warn("Invalid audio track id:",e.id):(C.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()&&(t=1e3*e.details.targetduration,this.setInterval(t)),!e.details.live&&this.hasInterval()&&this.clearInterval())},a.onAudioTrackSwitched=function(e){e=this.tracks[e.id].groupId;e&&this.audioGroupId!==e&&(this.audioGroupId=e)},a.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},a.onError=function(e){e.type===p.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR)&&(C.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError())},a._setAudioTrack=function(e){var t,r,i;this._trackId===e&&this.tracks[this._trackId].details?C.logger.debug("Same id as current audio-track passed, and track details available -> no-op"):e<0||e>=this.tracks.length?C.logger.warn("Invalid id passed to audio-track controller"):(t=this.tracks[e],C.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e,e=t.url,r=t.type,i=t.id,this.hls.trigger(v.default.AUDIO_TRACK_SWITCHING,{id:i,type:r,url:e}),this._loadTrackDetailsIfNeeded(t))},a.doTick=function(){this._updateTrack(this._trackId)},a._selectAudioGroup=function(e){var e=this.hls.levels[e];e&&e.audioGroupIds&&(e=e.audioGroupIds[e.urlId],this.audioGroupId!==e)&&(this.audioGroupId=e,this._selectInitialAudioTrack())},a._selectInitialAudioTrack=function(){var t,r,e,i=this,a=this.tracks;a.length&&(e=this.tracks[this._trackId],t=null,e&&(t=e.name),this._selectDefaultTrack&&((e=a.filter(function(e){return e.default})).length?a=e:C.logger.warn("No default audio tracks defined")),r=!1,(e=function(){a.forEach(function(e){r||i.audioGroupId&&e.groupId!==i.audioGroupId||t&&t!==e.name||(i._setAudioTrack(e.id),r=!0)})})(),r||(t=null,e()),r||(C.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0})))},a._needsTrackLoading=function(e){var t=e.details,e=e.url;return!(t&&!t.live||!e)},a._loadTrackDetailsIfNeeded=function(e){var t;this._needsTrackLoading(e)&&(t=e.url,e=e.id,C.logger.log("loading audio-track playlist for id: "+e),this.hls.trigger(v.default.AUDIO_TRACK_LOADING,{url:t,id:e}))},a._updateTrack=function(e){e<0||e>=this.tracks.length||(this.clearInterval(),this._trackId=e,C.logger.log("trying to update audio-track "+e),e=this.tracks[e],this._loadTrackDetailsIfNeeded(e))},a._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;for(var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,t=t.groupId,a=(C.logger.warn("Loading failed on audio track id: "+e+", group-id: "+t+', name/language: "'+r+'" / "'+i+'"'),e),n=0;n<this.tracks.length;n++)if(!this.trackIdBlacklist[n]&&this.tracks[n].name===r){a=n;break}a===e?C.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"'):(C.logger.log("Attempting audio-track fallback id:",a,"group-id:",this.tracks[a].groupId),this._setAudioTrack(a))},r=e,(a=[{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}])&&rt(r.prototype,a),i&&rt(r,i),e}(r);function it(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 at,nt,R=window.performance,st=function(i){function e(e,t){var r=i.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHING,v.default.AUDIO_TRACKS_UPDATED,v.default.AUDIO_TRACK_SWITCHING,v.default.AUDIO_TRACK_LOADED,v.default.KEY_LOADED,v.default.FRAG_LOADED,v.default.FRAG_PARSING_INIT_SEGMENT,v.default.FRAG_PARSING_DATA,v.default.FRAG_PARSED,v.default.ERROR,v.default.BUFFER_RESET,v.default.BUFFER_CREATED,v.default.BUFFER_APPENDED,v.default.BUFFER_FLUSHED,v.default.INIT_PTS_FOUND)||this;return r.fragmentTracker=t,r.config=e.config,r.audioCodecSwap=!1,r._state=l,r.initPTS=[],r.waitingFragment=null,r.videoTrackCC=null,r.waitingVideoCC=null,r}t=i,(a=e).prototype=Object.create(t.prototype),(a.prototype.constructor=a).__proto__=t;var t,r,a=e.prototype;return a.onInitPtsFound=function(e){var t=e.id,r=e.frag.cc,e=e.initPTS;"main"===t&&(this.initPTS[r]=e,this.videoTrackCC=r,C.logger.log("InitPTS for cc: "+r+" found from main: "+e),this.state===xe)&&this.tick()},a.startLoad=function(e){var t;this.tracks?(t=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),(this.fragLoadError=0)<t&&-1===e?(C.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=T):(this.lastCurrentTime=this.startPosition||e,this.state=ke),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()):(this.startPosition=e,this.state=l)},a.doTick=function(){var e,t,r=this.hls,i=r.config;switch(this.state){case A:case Ce:case _:break;case ke:this.state=Ie,this.loadedmetadata=!1;break;case T:var a=this.tracks;if(a&&(this.media||!this.startFragRequested&&i.startFragPrefetch)){if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var n=this.mediaBuffer||this.media,s=this.videoBuffer||this.media,o=e<i.maxBufferHole?Math.max(2,i.maxBufferHole):i.maxBufferHole,l=y.bufferInfo(n,e,o),s=y.bufferInfo(s,e,o),o=l.len,d=l.end,u=this.fragPrevious,c=Math.min(i.maxBufferLength,i.maxMaxBufferLength),c=Math.max(c,s.len),s=this.audioSwitch,h=this.trackId;if((o<c||s)&&h<a.length){if(void 0===(o=a[h].details)){this.state=Ie;break}if(!s&&this._streamEnded(l,o))return this.hls.trigger(v.default.BUFFER_EOS,{type:"audio"}),void(this.state=Pe);var c=o.fragments,a=c.length,f=c[0].start,g=c[a-1].start+c[a-1].duration;if(s)if(o.live&&!o.PTSKnown)C.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),d=0;else if(d=e,o.PTSKnown&&e<f){if(!(l.end>f||l.nextStart))return;C.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=f+.05}if(o.initSegment&&!o.initSegment.data)p=o.initSegment;else if(d<=f){var p=c[0];if(null!==this.videoTrackCC&&p.cc!==this.videoTrackCC&&(t=this.videoTrackCC,p=le.search(c,function(e){return e.cc<t?1:e.cc>t?-1:0})),o.live&&p.loadIdx&&p.loadIdx===this.fragLoadIdx)return l=l.nextStart||f,C.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(l+.05)),void(this.media.currentTime=l+.05)}else{var m=i.maxFragLookUpTolerance,f=u?c[u.sn-c[0].sn+1]:void 0,l=d<g?(g-m<d&&(m=0),f&&!E(d,m,f)?f:le.search(c,function(e){return E(d,m,e)})):c[a-1];l&&((p=l).start,u)&&p.level===u.level&&p.sn===u.sn&&(p.sn<o.endSN?(p=c[p.sn+1-o.startSN],this.fragmentTracker.getState(p)!==se&&C.logger.log("SN just loaded, load next one: "+p.sn)):p=null)}p&&(p.encrypted?(C.logger.log("Loading key for "+p.sn+" of ["+o.startSN+" ,"+o.endSN+"],track "+h),this.state=S,r.trigger(v.default.KEY_LOADING,{frag:p})):(this.fragCurrent=p,!s&&this.fragmentTracker.getState(p)!==ie||(C.logger.log("Loading "+p.sn+", cc: "+p.cc+" of ["+o.startSN+" ,"+o.endSN+"],track "+h+", "+(this.loadedmetadata?"currentTime":"nextLoadPosition")+": "+e+", bufferEnd: "+d.toFixed(3)),"initSegment"!==p.sn&&(this.startFragRequested=!0),Object(k.isFiniteNumber)(p.sn)&&(this.nextLoadPosition=p.start+p.duration),r.trigger(v.default.FRAG_LOADING,{frag:p}),this.state=b)))}}break;case Ie:(g=this.tracks[this.trackId])&&g.details&&(this.state=T);break;case Oe:f=R.now(),a=this.retryDate,l=(n=this.media)&&n.seeking;(!a||a<=f||l)&&(C.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=T);break;case xe:u=this.waitingFragment;u?(c=u.frag.cc,void 0!==this.initPTS[c]?(this.waitingFragment=null,this.state=b,this.onFragLoaded(u)):this.videoTrackCC!==this.waitingVideoCC?(C.logger.log("Waiting fragment cc ("+c+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment()):E((s=y.bufferInfo(this.mediaBuffer,this.media.currentTime,i.maxBufferHole)).end,i.maxFragLookUpTolerance,u.frag)<0&&(C.logger.log("Waiting fragment cc ("+c+") @ "+u.frag.start+" cancelled because another fragment at "+s.end+" is needed"),this.clearWaitingFragment())):this.state=T}},a.clearWaitingFragment=function(){var e=this.waitingFragment;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingFragment=null,this.waitingVideoCC=null,this.state=T)},a.onMediaAttached=function(e){e=this.media=this.mediaBuffer=e.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended),e=this.config;this.tracks&&e.autoStartLoad&&this.startLoad(e.startPosition)},a.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()},a.onAudioTracksUpdated=function(e){C.logger.log("audio tracks updated"),this.tracks=e.audioTracks},a.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.clearWaitingFragment(),this.state=Ce,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=T),this.tick()},a.onAudioTrackLoaded=function(e){var t=e.details,e=e.id,r=this.tracks[e],i=t.totalduration,a=0;C.logger.log("track "+e+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),t.live?(e=r.details)&&0<t.fragments.length?(Ee(e,t),a=t.fragments[0].start,t.PTSKnown?C.logger.log("live audio playlist sliding:"+a.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,r.details=t,this.startFragRequested||(-1===this.startPosition&&(i=t.startTimeOffset,Object(k.isFiniteNumber)(i)?(C.logger.log("start time offset found in playlist, adjust startPosition to "+i),this.startPosition=i):t.live?(this.startPosition=this.computeLivePosition(a,t),C.logger.log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0),this.nextLoadPosition=this.startPosition),this.state===Ie&&(this.state=T),this.tick()},a.onKeyLoaded=function(){this.state===S&&(this.state=T,this.tick())},a.onFragLoaded=function(e){var t,r,i,a,n,s,o,l=this.fragCurrent,d=e.frag;this.state===b&&l&&"audio"===d.type&&d.level===l.level&&d.sn===l.sn&&(r=(t=(d=this.tracks[this.trackId]).details).totalduration,i=l.level,a=l.sn,n=l.cc,d=this.config.defaultAudioCodec||d.audioCodec||"mp4a.40.2",s=this.stats=e.stats,"initSegment"===a?(this.state=T,s.tparsed=s.tbuffered=R.now(),t.initSegment.data=e.payload,this.hls.trigger(v.default.FRAG_BUFFERED,{stats:s,frag:l,id:"audio"}),this.tick()):(this.state=u,this.appended=!1,this.demuxer||(this.demuxer=new pe(this.hls,"audio")),s=this.initPTS[n],o=t.initSegment?t.initSegment.data:[],void 0!==s?(this.pendingBuffering=!0,C.logger.log("Demuxing "+a+" of ["+t.startSN+" ,"+t.endSN+"],track "+i),this.demuxer.push(e.payload,o,d,null,l,r,!1,s)):(C.logger.log("Unknown video PTS for cc "+n+", waiting for video PTS before demuxing audio frag "+a+" of ["+t.startSN+" ,"+t.endSN+"],track "+i),this.waitingFragment=e,this.waitingVideoCC=this.videoTrackCC,this.state=xe))),this.fragLoadError=0},a.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===u&&((r=e.tracks).video&&delete r.video,t=r.audio)&&(t.levelCodec=t.codec,t.id=e.id,this.hls.trigger(v.default.BUFFER_CODECS,r),C.logger.log("audio track:audio,container:"+t.container+",codecs[level/parsed]=["+t.levelCodec+"/"+t.codec+"]"),(e=t.initSegment)&&(r={type:"audio",data:e,parent:"audio",content:"initSegment"},this.audioSwitch?this.pendingData=[r]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(v.default.BUFFER_APPENDING,r))),this.tick())},a.onFragParsingData=function(t){var e,r,i,a=this,n=this.fragCurrent,s=t.frag;n&&"audio"===t.id&&"audio"===t.type&&s.sn===n.sn&&s.level===n.level&&this.state===u&&(s=this.trackId,r=this.tracks[s],e=this.hls,Object(k.isFiniteNumber)(t.endPTS)||(t.endPTS=t.startPTS+n.duration,t.endDTS=t.startDTS+n.duration),n.addElementaryStream(o.AUDIO),C.logger.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),ye(r.details,n,t.startPTS,t.endPTS),r=this.media,n=!1,this.audioSwitch&&(r&&r.readyState?(r=r.currentTime,C.logger.log("switching audio track : currentTime:"+r),r>=t.startPTS&&(C.logger.log("switching audio track : flushing all audio"),this.state=_,e.trigger(v.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),this.audioSwitch=!(n=!0),e.trigger(v.default.AUDIO_TRACK_SWITCHED,{id:s}))):(this.audioSwitch=!1,e.trigger(v.default.AUDIO_TRACK_SWITCHED,{id:s}))),(i=this.pendingData)?(this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&i.push({type:t.type,data:e,parent:"audio",content:"data"})}),!n&&i.length&&(i.forEach(function(e){a.state===u&&(a.pendingBuffering=!0,a.hls.trigger(v.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()):(C.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),e.trigger(v.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0})))},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===u&&(this.stats.tparsed=R.now(),this.state=d,this._checkAppendedParsed())},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.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)},a.onBufferAppended=function(e){var t;"audio"!==e.parent||(t=this.state)!==u&&t!==d||(this.pendingBuffering=0<e.pending,this._checkAppendedParsed())},a._checkAppendedParsed=function(){var e,t,r;this.state!==d||this.appended&&this.pendingBuffering||(e=this.fragCurrent,r=this.stats,t=this.hls,e&&(this.fragPrevious=e,r.tbuffered=R.now(),t.trigger(v.default.FRAG_BUFFERED,{stats:r,frag:e,id:"audio"}),(r=this.mediaBuffer||this.media)&&C.logger.log("audio buffered : "+be.toString(r.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,t.trigger(v.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=T),this.tick())},a.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:var r,i=e.frag;i&&"audio"!==i.type||e.fatal||((i=this.fragLoadError)?i++:i=1,i<=(r=this.config).fragLoadingMaxRetry?(this.fragLoadError=i,i=Math.min(Math.pow(2,i-1)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout),C.logger.warn("AudioStreamController: frag loading failed, retry in "+i+" ms"),this.retryDate=R.now()+i,this.state=Oe):(C.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=A));break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==A&&(this.state=e.fatal?A:T,C.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case p.ErrorDetails.BUFFER_FULL_ERROR:"audio"!==e.parent||this.state!==u&&this.state!==d||(r=this.mediaBuffer,i=this.media.currentTime,r&&y.isBuffered(r,i)&&y.isBuffered(r,i+.5)?((r=this.config).maxMaxBufferLength>=r.maxBufferLength&&(r.maxMaxBufferLength/=2,C.logger.warn("AudioStreamController: reduce max buffer length to "+r.maxMaxBufferLength+"s")),this.state=T):(C.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=_,this.hls.trigger(v.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})))}},a.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(C.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),e.forEach(function(e){t.hls.trigger(v.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=d):(this.state=T,this.fragPrevious=null,this.tick())},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,C.logger.log("audio stream:"+t+"->"+e))},get:function(){return this._state}}])&&it(t.prototype,a),r&&it(t,r),e}(i),ot="undefined"!=typeof window&&window.VTTCue?window.VTTCue:(at={"":!0,lr:!0,rl:!0},nt={start:!0,middle:!0,end:!0,left:!0,right:!0},dt.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},dt);function lt(e){return"string"==typeof e&&!!nt[e.toLowerCase()]&&e.toLowerCase()}function w(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)e[r]=i[r]}return e}function dt(e,t,r){var i=this,a={enumerable:!0},n=(i.hasBeenReset=!1,""),s=!1,o=e,l=t,d=r,u=null,c="",h=!0,f="auto",g="start",p=50,m="middle",v=50,y="middle";Object.defineProperty(i,"id",w({},a,{get:function(){return n},set:function(e){n=""+e}})),Object.defineProperty(i,"pauseOnExit",w({},a,{get:function(){return s},set:function(e){s=!!e}})),Object.defineProperty(i,"startTime",w({},a,{get:function(){return o},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");o=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"endTime",w({},a,{get:function(){return l},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");l=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"text",w({},a,{get:function(){return d},set:function(e){d=""+e,this.hasBeenReset=!0}})),Object.defineProperty(i,"region",w({},a,{get:function(){return u},set:function(e){u=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"vertical",w({},a,{get:function(){return c},set:function(e){e="string"==typeof(e=e)&&!!at[e.toLowerCase()]&&e.toLowerCase();if(!1===e)throw new SyntaxError("An invalid or illegal string was specified.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"snapToLines",w({},a,{get:function(){return h},set:function(e){h=!!e,this.hasBeenReset=!0}})),Object.defineProperty(i,"line",w({},a,{get:function(){return f},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"lineAlign",w({},a,{get:function(){return g},set:function(e){e=lt(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"position",w({},a,{get:function(){return p},set:function(e){if(e<0||100<e)throw new Error("Position must be between 0 and 100.");p=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"positionAlign",w({},a,{get:function(){return m},set:function(e){e=lt(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"size",w({},a,{get:function(){return v},set:function(e){if(e<0||100<e)throw new Error("Size must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(i,"align",w({},a,{get:function(){return y},set:function(e){e=lt(e);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),i.displayState=void 0}function ut(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}}function ct(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new ut,this.regionList=[]}function ht(){this.values=Object.create(null)}function ft(e,t,r,i){var a,n,s=i?e.split(i):[e];for(a in s)"string"==typeof s[a]&&2===(n=s[a].split(r)).length&&t(n[0],n[1])}ht.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]*)?%$/)&&0<=(t=parseFloat(t))&&t<=100)&&(this.set(e,t),!0)}};var gt=new ot(0,0,0),pt="middle"===gt.align?"middle":"center";function mt(r,e,n){var t,s,i=r;function a(){var e=(e=(e=r).match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/))?e[3]?t(e[1],e[2],e[3].replace(":",""),e[4]):59<e[1]?t(e[1],e[2],0,e[4]):t(0,e[1],e[2],e[4]):null;function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}if(null===e)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){r=r.replace(/^\s+/,"")}if(o(),e.startTime=a(),o(),"--\x3e"!==r.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);r=r.substr(3),o(),e.endTime=a(),o(),t=r,e=e,s=new ht,ft(t,function(e,t){switch(e){case"region":for(var r=n.length-1;0<=r;r--)if(n[r].id===t){s.set(e,n[r].region);break}break;case"vertical":s.alt(e,t,["rl","lr"]);break;case"line":var i=t.split(","),a=i[0];s.integer(e,a),s.percent(e,a)&&s.set("snapToLines",!1),s.alt(e,a,["auto"]),2===i.length&&s.alt("lineAlign",i[1],["start",pt,"end"]);break;case"position":i=t.split(","),s.percent(e,i[0]),2===i.length&&s.alt("positionAlign",i[1],["start",pt,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",pt,"end","left","right"])}},/:/,/\s/),e.region=s.get("region",null),e.vertical=s.get("vertical",""),"auto"===(t=s.get("line","auto"))&&-1===gt.line&&(t=-1),e.line=t,e.lineAlign=s.get("lineAlign","start"),e.snapToLines=s.get("snapToLines",!0),e.size=s.get("size",100),e.align=s.get("align",pt),"auto"===(t=s.get("position","auto"))&&50===gt.position&&(t="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=t}function vt(e){return e.replace(/<br(?: \/)?>/gi,"\n")}ct.prototype={parse:function(e){var i=this;function t(){for(var e=0,t=vt(t=i.buffer);e<t.length&&"\r"!==t[e]&&"\n"!==t[e];)++e;var r=t.substr(0,e);return"\r"===t[e]&&++e,"\n"===t[e]&&++e,i.buffer=t.substr(e),r}e&&(i.buffer+=i.decoder.decode(e,{stream:!0}));try{if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var r,a=(r=t()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var n=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(n?n=!1:r=t(),i.state){case"HEADER":/:/.test(r)?ft(r,function(e,t){e},/:/):r||(i.state="ID");continue;case"NOTE":r||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){i.state="NOTE";break}if(!r)continue;if(i.cue=new ot(0,0,""),i.state="CUE",-1===r.indexOf("--\x3e")){i.cue.id=r;continue}case"CUE":try{mt(r,i.cue,i.regionList)}catch(e){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var s=-1!==r.indexOf("--\x3e");if(!r||s&&(n=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+="\n"),i.cue.text+=r;continue;case"BADCUE":r||(i.state="ID");continue}}}catch(e){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){try{if(this.buffer+=this.decoder.decode(),!this.cue&&"HEADER"!==this.state||(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state)throw new Error("Malformed WebVTT signature.")}catch(e){throw e}return this.onflush&&this.onflush(),this}};var yt=ct;function Et(e,t,r,i){for(var a,n,s,o,l,d=[],u=window.VTTCue||TextTrackCue,c=0;c<i.rows.length;c++)if(s=!0,o=0,l="",!(a=i.rows[c]).isEmpty()){for(var h=0;h<a.chars.length;h++)a.chars[h].uchar.match(/\s/)&&s?o++:(l+=a.chars[h].uchar,s=!1);(a.cueStartTime=t)===r&&(r+=1e-4),n=new u(t,r,vt(l.trim())),16<=o?o--:o++,navigator.userAgent.match(/Firefox\//)?n.line=c+1:n.line=7<c?c-2:c+1,n.align="left",n.position=Math.max(0,Math.min(100,o/32*100)),d.push(n),e&&e.addCue(n)}return d}function Tt(e){var t=e;return St.hasOwnProperty(e)&&(t=St[e]),String.fromCharCode(t)}function h(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t}var m,St={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},D=100,bt={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_t={17:2,18:4,21:6,22:8,23:10,19:13,20:15},At={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Rt={25:2,26:4,29:6,30:8,31:10,27:13,28:15},wt=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Dt=((P=m=m||{})[P.ERROR=0]="ERROR",P[P.TEXT=1]="TEXT",P[P.WARNING=2]="WARNING",P[P.INFO=2]="INFO",P[P.DEBUG=3]="DEBUG",P[P.DATA=3]="DATA",function(){function e(){this.time=null,this.verboseLevel=m.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&C.logger.log(this.time+" ["+e+"] "+t)},e}()),Lt=function(){function e(e,t,r,i,a){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=a||!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}(),kt=function(){function e(e,t,r,i,a,n){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Lt(t,r,i,a,n)}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}(),Ct=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<D;t++)this.chars.push(new kt);this.logger=e,this.pos=0,this.currPenState=new Lt}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<D;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<D;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<D;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(m.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>D&&(this.logger.log(m.DEBUG,"Too large cursor position "+this.pos),this.pos=D)},t.moveCursor=function(e){var t=this.pos+e;if(1<e)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){144<=e&&this.backSpace();var t=Tt(e);this.pos>=D?this.logger.log(m.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){for(var t=e;t<D;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<D;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}(),Ot=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<15;t++)this.rows.push(new Ct(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<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;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(m.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(m.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<15;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime,s=this.logger.time;if(n&&null!==s&&n<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(a.rows[i+o])}}this.currRow=t;n=this.rows[this.currRow],null!==e.indent&&(s=e.indent,s=Math.max(s-1,0),n.setCursor(e.indent),e.color=n.chars[s].penState.foreground),n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)},t.setBkgData=function(e){this.logger.log(m.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){var e;null===this.nrRollUpRows?this.logger.log(m.DEBUG,"roll_up but nrRollUpRows not set yet"):(this.logger.log(m.TEXT,this.getDisplayText()),e=this.currRow+1-this.nrRollUpRows,(e=this.rows.splice(e,1)[0]).clear(),this.rows.splice(this.currRow,0,e),this.logger.log(m.INFO,"Rolling up"))},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=0;i<15;i++){var a=this.rows[i].getTextString();a&&t.push(e?"Row "+(i+1)+": '"+a+"'":a.trim())}return r=0<t.length?e?"["+t.join(" | ")+"]":t.join("\n"):r},t.getTextAndFormat=function(){return this.rows},e}(),It=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 Ot(r),this.nonDisplayedMemory=new Ot(r),this.lastOutputScreen=new Ot(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(m.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(m.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(m.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(m.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(m.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(m.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(m.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(m.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(m.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(m.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(m.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(m.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(m.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(m.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){var e;this.logger.log(m.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode&&(e=this.displayedMemory,this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(m.TEXT,"DISP: "+this.displayedMemory.getDisplayText())),this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(m.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};t.underline=e%2==1,t.italics=46<=e,t.italics?t.foreground="white":(e=Math.floor(e/2)-16,t.foreground=["white","green","blue","cyan","red","yellow","magenta"][e]),this.logger.log(m.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 L(e,t,r){r.a=e,r.b=t}function Pt(e,t,r){return r.a===e&&r.b===t}function xt(){return{a:null,b:null}}function Ft(e,t,r){return e.substr(r||0,t.length)===t}function Mt(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var Nt=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Dt;this.channels=[null,new It(e,t,i),new It(e+1,r,i)],this.cmdHistory=xt(),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=!1;this.logger.time=e;for(var a=0;a<t.length;a+=2){var n,s=127&t[a],o=127&t[a+1];0==s&&0==o||(this.logger.log(m.DATA,"["+h([t[a],t[a+1]])+"] -> ("+h([s,o])+")"),(r=(r=(r=(r=this.parseCmd(s,o))||this.parseMidrow(s,o))||this.parsePAC(s,o))||this.parseBackgroundAttributes(s,o))||(i=this.parseChars(s,o))&&((n=this.currentChannel)&&0<n?this.channels[n].insertChars(i):this.logger.log(m.WARNING,"No channel found yet. TEXT-MODE?")),r)||i||this.logger.log(m.WARNING,"Couldn't parse cleaned data "+h([s,o])+" orig: "+h([t[a],t[a+1]]))}},t.parseCmd=function(e,t){var r,i,a=this.cmdHistory;return((20===e||28===e||21===e||29===e)&&32<=t&&t<=47||(23===e||31===e)&&33<=t&&t<=35)&&(Pt(e,t,a)?(L(null,null,a),this.logger.log(m.DEBUG,"Repeated command ("+h([e,t])+") is dropped")):(i=this.channels[r=20===e||21===e||23===e?1:2],20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),L(e,t,a),this.currentChannel=r),!0)},t.parseMidrow=function(e,t){var r=0;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currentChannel?(this.logger.log(m.ERROR,"Mismatch channel in midrow parsing"),!1):!!(r=this.channels[r])&&(r.ccMIDROW(t),this.logger.log(m.DEBUG,"MIDROW ("+h([e,t])+")"),!0))},t.parsePAC=function(e,t){var r=this.cmdHistory;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127)&&!((16===e||24===e)&&64<=t&&t<=95))return!1;if(Pt(e,t,r))L(null,null,r);else{var i=e<=23?1:2,a=(64<=t&&t<=95?1==i?bt:At:1==i?_t:Rt)[e],n=this.channels[i];if(!n)return!1;n.setPAC(this.interpretPAC(a,t)),L(e,t,r),this.currentChannel=i}return!0},t.interpretPAC=function(e,t){var r=t,e={color:null,italics:!1,indent:null,underline:!1,row:e},r=95<t?t-96:t-64;return e.underline=1==(1&r),r<=13?e.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(e.italics=!0,e.color="white"):e.indent=4*Math.floor((r-16)/2),e},t.parseChars=function(e,t){var r,i,a=null,n=null;return 17<=(n=25<=e?(r=2,e-8):(r=1,e))&&n<=19?(i=t,this.logger.log(m.INFO,"Special char '"+Tt(i=17===n?t+80:18===n?t+112:t+144)+"' in channel "+r),a=[i]):32<=e&&e<=127&&(a=0===t?[e]:[e,t]),a&&(n=h(a),this.logger.log(m.DEBUG,"Char codes = "+n.join(",")),L(e,t,this.cmdHistory)),a},t.parseBackgroundAttributes=function(e,t){var r,i;return((16===e||24===e)&&32<=t&&t<=47||(23===e||31===e)&&45<=t&&t<=47)&&(i={},16===e||24===e?(r=Math.floor((t-32)/2),i.background=wt[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),this.channels[e<=23?1:2].setBkgData(i),L(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=xt()},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}(),Ut=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}(),Bt={parse:function(e,t,s,o,r,i){var a,e=Object(je.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),n="00:00.000",l=0,d=0,u=0,c=[],h=!0,f=!1,g=new yt;g.oncue=function(e){var t=s[o],r=s.ccOffset;if(t&&t.new)if(void 0!==d)r=s.ccOffset=t.start;else{var i=s,t=u,a=i[o],n=i[a.prevCC];if(!n||!n.new&&a.new)i.ccOffset=i.presentationOffset=a.start,a.new=!1;else{for(;n&&n.new;)i.ccOffset+=a.start-n.start,a.new=!1,n=i[(a=n).prevCC];i.presentationOffset=t}}u&&(r=u-s.presentationOffset),f&&(e.startTime+=r-d,e.endTime+=r-d),e.id=Mt(e.startTime.toString())+Mt(e.endTime.toString())+Mt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),0<e.endTime&&c.push(e)},g.onparsingerror=function(e){a=e},g.onflush=function(){a&&i?i(a):r(c)},e.forEach(function(e){if(h){if(Ft(e,"X-TIMESTAMP-MAP=")){f=!(h=!1),e.substr(16).split(",").forEach(function(e){Ft(e,"LOCAL:")?n=e.substr(6):Ft(e,"MPEGTS:")&&(l=parseInt(e.substr(7)))});try{t+(9e4*s[o].start||0)<0&&(t+=8589934592),l-=t,d=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=9<e.length?parseInt(e.substr(0,e.indexOf(":"))):0;if(Object(k.isFiniteNumber)(t)&&Object(k.isFiniteNumber)(r)&&Object(k.isFiniteNumber)(i)&&Object(k.isFiniteNumber)(a))return(t+=1e3*r)+6e4*i+36e5*a;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e)}(n)/1e3,u=l/9e4}catch(e){f=!1,a=e}return}""===e&&(h=!1)}g.parse(e+"\n")}),g.flush()}};function Gt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function jt(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}var P=function(n){var e;function t(e){var t,r,i,a=n.call(this,e,v.default.MEDIA_ATTACHING,v.default.MEDIA_DETACHING,v.default.FRAG_PARSING_USERDATA,v.default.FRAG_DECRYPTED,v.default.MANIFEST_LOADING,v.default.MANIFEST_LOADED,v.default.FRAG_LOADED,v.default.INIT_PTS_FOUND)||this;return a.media=null,a.config=void 0,a.enabled=!0,a.Cues=void 0,a.textTracks=[],a.tracks=[],a.initPTS=[],a.unparsedVttFrags=[],a.captionsTracks={},a.nonNativeCaptionsTracks={},a.captionsProperties=void 0,a.cea608Parser1=void 0,a.cea608Parser2=void 0,a.lastSn=-1,a.prevCC=-1,a.vttCCs=jt(),a.hls=e,a.config=e.config,a.Cues=e.config.cueHandler,a.captionsProperties={textTrack1:{label:a.config.captionsTextTrack1Label,languageCode:a.config.captionsTextTrack1LanguageCode},textTrack2:{label:a.config.captionsTextTrack2Label,languageCode:a.config.captionsTextTrack2LanguageCode},textTrack3:{label:a.config.captionsTextTrack3Label,languageCode:a.config.captionsTextTrack3LanguageCode},textTrack4:{label:a.config.captionsTextTrack4Label,languageCode:a.config.captionsTextTrack4LanguageCode}},a.config.enableCEA708Captions&&(e=new Ut(Gt(a),"textTrack1"),t=new Ut(Gt(a),"textTrack2"),r=new Ut(Gt(a),"textTrack3"),i=new Ut(Gt(a),"textTrack4"),a.cea608Parser1=new Nt(1,e,t),a.cea608Parser2=new Nt(3,r,i)),a}e=n,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.addCues=function(e,t,r,i,a){for(var n,s,o=!1,l=a.length;l--;){var d=a[l],u=(n=d[0],u=d[1],s=t,Math.min(u,r)-Math.max(n,s));if(0<=u&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],r),o=!0,.5<u/(r-t)))return}o||a.push([t,r]),this.config.renderTextTracksNatively?this.Cues.newCue(this.captionsTracks[e],t,r,i):(i=this.Cues.newCue(null,t,r,i),this.hls.trigger(v.default.CUES_PARSED,{type:"captions",cues:i,track:e}))},r.onInitPtsFound=function(e){var t=this,r=e.frag,i=e.id,e=e.initPTS,a=this.unparsedVttFrags;"main"===i&&(this.initPTS[r.cc]=e),a.length&&(this.unparsedVttFrags=[],a.forEach(function(e){t.onFragLoaded(e)}))},r.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},r.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},r.createNativeTrack=function(e){var t,r,i,a,n;this.captionsTracks[e]||(a=this.captionsProperties,t=this.captionsTracks,r=this.media,i=(a=a[e]).label,a=a.languageCode,(n=this.getExistingTrack(e))?(t[e]=n,c(t[e]),Ke(t[e],r)):(n=this.createTextTrack("captions",i,a))&&(n[e]=!0,t[e]=n))},r.createNonNativeTrack=function(e){var t;this.nonNativeCaptionsTracks[e]||(t=this.captionsProperties[e])&&(t={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media},this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(v.default.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]}))},r.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},r.destroy=function(){n.prototype.destroy.call(this)},r.onMediaAttaching=function(e){this.media=e.media,this._cleanTracks()},r.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(e){c(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}},r.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs=jt(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={}},r._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)c(t[r])}},r.onManifestLoaded=function(e){var o,t,l=this;this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset()),this.config.enableWebVTT&&(t=e.subtitles||[],t=this.tracks&&t&&this.tracks.length===t.length,this.tracks=e.subtitles||[],this.config.renderTextTracksNatively?(o=this.media?this.media.textTracks:[],this.tracks.forEach(function(e,t){var r,i,a;if(t<o.length){for(var n=null,s=0;s<o.length;s++)if(i=o[s],a=e,i&&i.label===a.name&&!i.textTrack1&&!i.textTrack2){n=o[s];break}n&&(r=n)}r=r||l.createTextTrack("subtitles",e.name,e.lang),e.default?r.mode=l.hls.subtitleDisplay?"showing":"hidden":r.mode="disabled",l.textTracks.push(r)})):!t&&this.tracks&&this.tracks.length&&(t=this.tracks.map(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}),this.hls.trigger(v.default.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t}))),this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);t&&(t="textTrack"+t[1],t=l.captionsProperties[t])&&(t.label=e.name,e.lang&&(t.languageCode=e.lang),t.media=e)})},r.onFragLoaded=function(e){var t,r=e.frag,i=e.payload,a=this.cea608Parser1,n=this.cea608Parser2,s=this.initPTS,o=this.lastSn,l=this.unparsedVttFrags;"main"===r.type?(t=r.sn,r.sn!==o+1&&a&&n&&(a.reset(),n.reset()),this.lastSn=t):"subtitle"===r.type&&(i.byteLength?Object(k.isFiniteNumber)(s[r.cc])?null!=(o=r.decryptdata)&&null!=o.key&&"AES-128"===o.method||this._parseVTTs(r,i):(l.push(e),s.length&&this.hls.trigger(v.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r})):this.hls.trigger(v.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r}))},r._parseVTTs=function(r,e){var a=this,n=this.hls,t=this.prevCC,s=this.textTracks,i=this.vttCCs;i[r.cc]||(i[r.cc]={start:r.start,prevCC:t,new:!0},this.prevCC=r.cc),Bt.parse(e,this.initPTS[r.cc],i,r.cc,function(e){if(a.config.renderTextTracksNatively){var i=s[r.level];if("disabled"===i.mode)return void n.trigger(v.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r});e.forEach(function(t){if(!i.cues.getCueById(t.id))try{if(i.addCue(t),!i.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(e){C.logger.debug("Failed occurred on adding cues: "+e);var r=new window.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,i.addCue(r)}})}else{var t=a.tracks[r.level].default?"default":"subtitles"+r.level;n.trigger(v.default.CUES_PARSED,{type:"subtitles",cues:e,track:t})}n.trigger(v.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},function(e){C.logger.log("Failed to parse VTT cue: "+e),n.trigger(v.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r})})},r.onFragDecrypted=function(e){var t=e.frag,r=e.payload;"subtitle"===t.type&&(Object(k.isFiniteNumber)(this.initPTS[t.cc])?this._parseVTTs(t,r):this.unparsedVttFrags.push(e))},r.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 a=e.samples[i].bytes;a&&(a=this.extractCea608Data(a),t.addData(e.samples[i].pts,a[0]),r.addData(e.samples[i].pts,a[1]))}},r.extractCea608Data=function(e){for(var t=31&e[0],r=2,i=[[],[]],a=0;a<t;a++){var n=e[r++],s=127&e[r++],o=127&e[r++],l=3&n;0==s&&0==o||!(0!=(4&n))||0!=l&&1!=l||(i[l].push(s),i[l].push(o))}return i},t}(s);function Kt(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 Ht(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 Vt=function(t){function e(e){e=t.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHING,v.default.MANIFEST_LOADED,v.default.SUBTITLE_TRACK_LOADED)||this;return e.tracks=[],e.trackId=-1,e.media=null,e.stopped=!0,e.subtitleDisplay=!0,e.queuedDefaultTrack=null,e}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.destroy=function(){s.prototype.destroy.call(this)},a.onMediaAttached=function(e){var t=this;this.media=e.media,this.media&&(Object(k.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))},a.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),Object(k.isFiniteNumber)(this.subtitleTrack)&&(this.queuedDefaultTrack=this.subtitleTrack),Ht(this.media.textTracks).forEach(function(e){c(e)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoaded=function(e){var t=this,e=e.subtitles||[];this.tracks=e,this.hls.trigger(v.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),e.forEach(function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)})},a.onSubtitleTrackLoaded=function(e){var t=this,r=e.id,i=e.details,a=this.trackId,n=this.tracks,s=n[a];!(r>=n.length||r!==a||!s||this.stopped)&&(C.logger.log("subtitle track "+r+" loaded"),i.live)?(n=Se(s.details,i,e.stats.trequest),C.logger.log("Reloading live subtitle playlist in "+n+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},n)):this._clearReloadTimer()},a.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},a.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},a._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},a._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,t=t[e];e<0||!t||t.details&&!t.details.live||(C.logger.log("Loading subtitle track "+e),r.trigger(v.default.SUBTITLE_TRACK_LOADING,{url:t.url,id:e}))},a._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;t&&(t=Ht(t.textTracks),-1===e?[].slice.call(t).forEach(function(e){e.mode="disabled"}):(i=t[i])&&(i.mode="disabled"),i=t[e])&&(i.mode=r?"showing":"hidden")},a._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(k.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,C.logger.log("Switching to subtitle track "+e),t.trigger(v.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},a._onTextTracksChanged=function(){if(this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=Ht(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}},r=e,(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))}}])&&Kt(r.prototype,a),i&&Kt(r,i),e}(s),Yt=t("./src/crypt/decrypter.js");var x,Wt=window.performance,t=function(i){var e;function t(e,t){var r=i.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHING,v.default.ERROR,v.default.KEY_LOADED,v.default.FRAG_LOADED,v.default.SUBTITLE_TRACKS_UPDATED,v.default.SUBTITLE_TRACK_SWITCH,v.default.SUBTITLE_TRACK_LOADED,v.default.SUBTITLE_FRAG_PROCESSED,v.default.LEVEL_UPDATED)||this;return r.fragmentTracker=t,r.config=e.config,r.state=l,r.tracks=[],r.tracksBuffered=[],r.currentTrackId=-1,r.decrypter=new Yt.default(e,e.config),r.lastAVStart=0,r._onMediaSeeking=r.onMediaSeeking.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}e=i,(r=t).prototype=Object.create(e.prototype),(r.prototype.constructor=r).__proto__=e;var r=t.prototype;return r.onSubtitleFragProcessed=function(e){var t=e.frag,e=e.success;if(this.fragPrevious=t,this.state=T,e){var r=this.tracksBuffered[this.currentTrackId];if(r){for(var i,a=t.start,n=0;n<r.length;n++)if(a>=r[n].start&&a<=r[n].end){i=r[n];break}e=t.start+t.duration;i?i.end=e:r.push(i={start:a,end:e})}}},r.onMediaAttached=function(e){e=e.media;(this.media=e).addEventListener("seeking",this._onMediaSeeking),this.state=T},r.onMediaDetaching=function(){var t=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]}),this.media=null,this.state=l)},r.onError=function(e){e=e.frag;e&&"subtitle"===e.type&&(this.state=T)},r.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]=[]})},r.onSubtitleTrackSwitch=function(e){this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId?(e=this.tracks[this.currentTrackId])&&e.details&&this.setInterval(500):this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,e=e.details,r=this.currentTrackId,i=this.tracks,a=i[r];if(!(t>=i.length||t!==r)&&a){if(e.live){var i=a.details,t=e,n=this.lastAVStart,s=(void 0===n&&(n=0),-1),o=(Te(i,t,function(e,t,r){t.start=e.start,s=r}),t.fragments);if(s<0)o.forEach(function(e){e.start+=n});else for(var l=s+1;l<o.length;l++)o[l].start=o[l-1].start+o[l-1].duration}a.details=e,this.setInterval(500)}},r.onKeyLoaded=function(){this.state===S&&(this.state=T)},r.onFragLoaded=function(e){var r,t=this.fragCurrent,i=e.frag.decryptdata,a=e.frag,n=this.hls;this.state===b&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&0<e.payload.byteLength&&i&&i.key&&"AES-128"===i.method&&(r=Wt.now(),this.decrypter.decrypt(e.payload,i.key.buffer,i.iv.buffer,function(e){var t=Wt.now();n.trigger(v.default.FRAG_DECRYPTED,{frag:a,payload:e,stats:{tstart:r,tdecrypt:t}})}))},r.onLevelUpdated=function(e){e=e.details.fragments;this.lastAVStart=e.length?e[0].start:0},r.doTick=function(){var e,t,r,i,a,n,s,o,l,d;this.media?this.state===T&&(l=this.config,n=this.currentTrackId,e=this.fragmentTracker,i=this.media,a=this.tracks)&&a[n]&&a[n].details&&(r=l.maxBufferHole,t=l.maxFragLookUpTolerance,l=Math.min(l.maxBufferLength,l.maxMaxBufferLength),r=(i=y.bufferedInfo(this._getBuffered(),i.currentTime,r)).end,i=i.len,o=(n=(a=a[n].details).fragments)[(s=n.length)-1].start+n[s-1].duration,l<i||(l=this.fragPrevious,(d=r<o?(d=l&&a.hasProgramDateTime?we(n,l.endProgramDateTime,t):d)||De(l,n,r,t):n[s-1])&&d.encrypted?(C.logger.log("Loading key for "+d.sn),this.state=S,this.hls.trigger(v.default.KEY_LOADING,{frag:d})):d&&e.getState(d)===ie&&(this.fragCurrent=d,this.state=b,this.hls.trigger(v.default.FRAG_LOADING,{frag:d})))):this.state=T},r.stopLoad=function(){this.lastAVStart=0,i.prototype.stopLoad.call(this)},r._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},r.onMediaSeeking=function(){this.fragPrevious=null},t}(i),i=((i=x=x||{}).WIDEVINE="com.widevine.alpha",i.PLAYREADY="com.microsoft.playready","undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null);function qt(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 Xt=function(t){function e(e){var r=t.call(this,e,v.default.MEDIA_ATTACHED,v.default.MEDIA_DETACHED,v.default.MANIFEST_PARSED)||this;return r._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(t){var e;C.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),r.mediaKeysPromise?r.mediaKeysPromise.then(e=function(e){r._media&&(r._attemptSetMediaKeys(e),r._generateRequestWithPreferredKeySession(t.initDataType,t.initData))}).catch(e):(C.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),r.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0}))},r._config=e.config,r._widevineLicenseUrl=r._config.widevineLicenseUrl,r._licenseXhrSetup=r._config.licenseXhrSetup,r._emeEnabled=r._config.emeEnabled,r._requestMediaKeySystemAccess=r._config.requestMediaKeySystemAccessFunc,r._drmSystemOptions=e.config.drmSystemOptions,r}r=t,(a=e).prototype=Object.create(r.prototype),(a.prototype.constructor=a).__proto__=r;var r,i,a=e.prototype;return a.getLicenseServerUrl=function(e){if(e===x.WIDEVINE)if(this._widevineLicenseUrl)return this._widevineLicenseUrl;throw new Error('no license server URL configured for key-system "'+e+'"')},a._attemptKeySystemAccess=function(t,e,r){var i=this,e=function(e,t,r,i){if(e!==x.WIDEVINE)throw new Error("Unknown key-system: "+e);return e=r,a=i,n={audioCapabilities:[],videoCapabilities:[]},t.forEach(function(e){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:a.audioRobustness||""})}),e.forEach(function(e){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:a.videoRobustness||""})}),[n];var a,n}(t,e,r,this._drmSystemOptions),r=(C.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(t,e));this.mediaKeysPromise=r.then(function(e){return i._onMediaKeySystemAccessObtained(t,e)}),r.catch(function(e){C.logger.error('Failed to obtain key-system "'+t+'" access:',e)})},a._onMediaKeySystemAccessObtained=function(t,e){var r=this,i=(C.logger.log('Access for key-system "'+t+'" obtained'),{mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t}),a=(this._mediaKeysList.push(i),Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(e){return i.mediaKeys=e,C.logger.log('Media-keys created for key-system "'+t+'"'),r._onMediaKeysCreated(),e}));return a.catch(function(e){C.logger.error("Failed to create media-keys:",e)}),a},a._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),t._onNewMediaKeySession(e.mediaKeysSession))})},a._onNewMediaKeySession=function(t){var r=this;C.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",function(e){r._onKeySessionMessage(t,e.message)},!1)},a._onKeySessionMessage=function(t,e){C.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(e){C.logger.log("Received license data (length: "+(e&&e.byteLength)+"), updating key-session"),t.update(e)})},a._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");var t;this._hasSetMediaKeys||((t=this._mediaKeysList[0])&&t.mediaKeys?(C.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0):(C.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0})))},a._generateRequestWithPreferredKeySession=function(e,t){var r,i=this,a=this._mediaKeysList[0];a?a.mediaKeysSessionInitialized?C.logger.warn("Key-Session already initialized but requested again"):(r=a.mediaKeysSession)?t?(C.logger.log('Generating key-session request for "'+e+'" init data type'),a.mediaKeysSessionInitialized=!0,r.generateRequest(e,t).then(function(){C.logger.debug("Key-session generation succeeded")}).catch(function(e){C.logger.error("Error generating key-session request:",e),i.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})):(C.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0})):(C.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0})):(C.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0}))},a._createLicenseXhr=function(t,e,r){var i=new XMLHttpRequest,a=this._licenseXhrSetup;try{if(a)try{a(i,t)}catch(e){i.open("POST",t,!0),a(i,t)}i.readyState||i.open("POST",t,!0)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,t,e,r),i},a._onLicenseRequestReadyStageChange=function(e,t,r,i){if(4===e.readyState)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++,3<this._requestLicenseFailureCount)return void this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});t=3-this._requestLicenseFailureCount+1;C.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(r,i)}},a._generateLicenseRequestChallenge=function(e,t){if(e.mediaKeySystemDomain===x.WIDEVINE)return t;throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},a._requestLicense=function(e,t){C.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(r)try{var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),a=this._createLicenseXhr(i,e,t),n=(C.logger.log("Sending license request to URL: "+i),this._generateLicenseRequestChallenge(r,e));a.send(n)}catch(e){C.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}else C.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(v.default.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0})},a.onMediaAttached=function(e){this._emeEnabled&&(e=e.media,(this._media=e).addEventListener("encrypted",this._onMediaEncrypted))},a.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(){}))},a.onManifestParsed=function(e){var t;this._emeEnabled&&(t=e.levels.map(function(e){return e.audioCodec}),e=e.levels.map(function(e){return e.videoCodec}),this._attemptKeySystemAccess(x.WIDEVINE,t,e))},r=e,(a=[{key:"requestMediaKeySystemAccess",get:function(){if(this._requestMediaKeySystemAccess)return this._requestMediaKeySystemAccess;throw new Error("No requestMediaKeySystemAccess function configured")}}])&&qt(r.prototype,a),i&&qt(r,i),e}(s);function zt(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function Jt(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?zt(Object(a),!0).forEach(function(e){var t,r;t=i,r=a[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):zt(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})}return i}var Zt=Jt(Jt({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:tt,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:Xe,bufferController:Je,capLevelController:Qe,fpsController:et,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:i,testBandwidth:!0},{cueHandler:e,enableCEA708Captions:!0,enableWebVTT:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:t,subtitleTrackController:Vt,timelineController:P,audioStreamController:st,audioTrackController:r,emeController:Xt});function Qt(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function $t(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?Qt(Object(a),!0).forEach(function(e){var t,r;t=i,r=a[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):Qt(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})}return i}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function er(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 tr(e,t,r){t&&er(e.prototype,t),r&&er(e,r)}var rr=function(f){var e;function g(e){void 0===e&&(e={}),(t=f.call(this)||this).config=void 0,t._autoLevelCapping=void 0,t.abrController=void 0,t.capLevelController=void 0,t.levelController=void 0,t.streamController=void 0,t.networkControllers=void 0,t.audioTrackController=void 0,t.subtitleTrackController=void 0,t.emeController=void 0,t.coreComponents=void 0,t.media=null,t.url=null;var t,r=g.DefaultConfig;if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");t.config=$t($t({},r),e);r=F(t).config;if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(void 0===r.liveSyncDuration||r.liveMaxLatencyDuration<=r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(C.enableLogs)(r.debug),t._autoLevelCapping=-1;var e=t.abrController=new r.abrController(F(t)),i=new r.bufferController(F(t)),a=t.capLevelController=new r.capLevelController(F(t)),n=new r.fpsController(F(t)),s=new ee(F(t)),o=new te(F(t)),l=new re(F(t)),d=new He(F(t)),u=t.levelController=new Ge(F(t)),c=new oe(F(t)),u=[u,t.streamController=new Ue(F(t),c)],h=r.audioStreamController,s=(h&&u.push(new h(F(t),c)),t.networkControllers=u,[s,o,l,e,i,a,n,d,c]);return(h=r.audioTrackController)&&(o=new h(F(t)),t.audioTrackController=o,s.push(o)),(h=r.subtitleTrackController)&&(l=new h(F(t)),t.subtitleTrackController=l,u.push(l)),(h=r.emeController)&&(e=new h(F(t)),t.emeController=e,s.push(e)),(h=r.subtitleStreamController)&&u.push(new h(F(t),c)),(h=r.timelineController)&&s.push(new h(F(t))),t.coreComponents=s,t}e=f,(t=g).prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e,g.isSupported=function(){return!!(t=ce())&&(e=self.SourceBuffer||self.WebKitSourceBuffer,t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove,!!t)&&!!e;var e,t},tr(g,null,[{key:"version",get:function(){return"0.14.12"}},{key:"Events",get:function(){return v.default}},{key:"ErrorTypes",get:function(){return p.ErrorTypes}},{key:"ErrorDetails",get:function(){return p.ErrorDetails}},{key:"DefaultConfig",get:function(){return g.defaultConfig||Zt},set:function(e){g.defaultConfig=e}}]);var t=g.prototype;return t.destroy=function(){C.logger.log("destroy"),this.trigger(v.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},t.attachMedia=function(e){C.logger.log("attachMedia"),this.media=e,this.trigger(v.default.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){C.logger.log("detachMedia"),this.trigger(v.default.MEDIA_DETACHING),this.media=null},t.loadSource=function(e){e=a.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),C.logger.log("loadSource:"+e),this.url=e,this.trigger(v.default.MANIFEST_LOADING,{url:e})},t.startLoad=function(t){void 0===t&&(t=-1),C.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.stopLoad=function(){C.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},t.swapAudioCodec=function(){C.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){C.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e,t){this.levelController.removeLevel(e,t=void 0===t?0:t)},tr(g,[{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){e=!!e;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{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(t<(e[i].realBitrate?Math.max(e[i].realBitrate,e[i].bitrate):e[i].bitrate))return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,e=-1===t&&e&&e.length?e.length-1:t;return e}},{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)}}]),g}(he);rr.defaultConfig=void 0},"./src/polyfills/number.js":
|
|
73
|
-
/*!*********************************!*\
|
|
74
|
-
!*** ./src/polyfills/number.js ***!
|
|
75
|
-
\*********************************/
|
|
76
|
-
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",function(){return i}),r.d(t,"MAX_SAFE_INTEGER",function(){return a});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},a=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/utils/get-self-scope.js":
|
|
77
|
-
/*!*************************************!*\
|
|
78
|
-
!*** ./src/utils/get-self-scope.js ***!
|
|
79
|
-
\*************************************/
|
|
80
|
-
/*! exports provided: getSelfScope */function(e,t,r){"use strict";function i(){return"undefined"==typeof window?self:window}r.r(t),r.d(t,"getSelfScope",function(){return i})},"./src/utils/logger.js":
|
|
81
|
-
/*!*****************************!*\
|
|
82
|
-
!*** ./src/utils/logger.js ***!
|
|
83
|
-
\*****************************/
|
|
84
|
-
/*! exports provided: enableLogs, logger */function(e,t,r){"use strict";r.r(t),r.d(t,"enableLogs",function(){return l}),r.d(t,"logger",function(){return d});t=r(/*! ./get-self-scope */"./src/utils/get-self-scope.js");function i(){}var a={trace:i,debug:i,log:i,warn:i,info:i,error:i},n=a;var o=Object(t.getSelfScope)();function s(n){var s=o.console[n];return s?function(){for(var e,t,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];i[0]&&(i[0]=(e=n,t=i[0],t="["+e+"] > "+t)),s.apply(o.console,i)}:i}var l=function(e){if(o.console&&!0===e||"object"==typeof e){!function(t){for(var e=arguments.length,r=new Array(1<e?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach(function(e){n[e]=t[e]?t[e].bind(t):s(e)})}(e,"debug","log","info","warn","error");try{n.log()}catch(e){n=a}}else n=a},d=n}},i={},a.m=r,a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/dist/",a(a.s="./src/hls.ts").default;function a(e){var t;return(i[e]||(t=i[e]={i:e,l:!1,exports:{}},r[e].call(t.exports,t,t.exports,a),t.l=!0,t)).exports}var r,i},e.exports=t())},49538:function(e,t,r){r=[r(11373),r(56888)],t=function(a,r){function e(e,t,r,i){this._hls=new a(Object.assign(e||{},{debug:!1,enableWorker:!0,liveBackBufferLength:900,maxMaxBufferLength:60,testBandwidth:!0,capLevelOnFPSDrop:!0,abrEwmaSlowVoD:3.5,abrBandWidthFactor:1.5,abrBandWidthUpFactor:1.5,maxStarvationDelay:6,abrController:c,renderTextTracksNatively:!1,subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0},{loader:u(a.DefaultConfig.loader,r)})),this.init(t||{}),this.debug=i||!1,this.bandwidthConsumed=0,function(e){var l=this._hls,d=this;l.on(a.Events.MEDIA_ATTACHED,function(){d.addStats({time:performance.now()-d.getStartTime(),type:"Media attached"}),d.logStatus("Media element attached")}),l.on(a.Events.MEDIA_DETACHED,function(){d.addStats({time:performance.now()-d.getStartTime(),type:"Media detached"}),d.logStatus("Media element detached")}),l.on(a.Events.FRAG_PARSING_INIT_SEGMENT,function(e,t){var r="@"+t.id+" segment initialized";d.logStatus("Media Fragments Initialized",t,r),d.addStats({time:performance.now()-d.getStartTime(),type:r})}),l.on(a.Events.FRAG_PARSING_METADATA,function(e,t){d.addStats({time:performance.now()-d.getStartTime(),type:"Fragment Parsing MetaData"}),d.logStatus("Fragment Parsing Metadata",t)}),l.on(a.Events.LEVEL_SWITCHING,function(e,t){var r=[].concat(l.level);r.sort(function(e,t){return e.height>t.height?1:t.height>e.height?-1:0}),d.addStats({time:performance.now()-d.getStartTime(),type:"Media Level Switching",currentLevel:l.currentLevel,bitrate:r[l.currentLevel]}),d.logStatus("Media Level Switching",r,l.currentLevel)}),l.on(a.Events.MANIFEST_PARSED,function(e,t){for(var r=[],i=0;i<t.levels.length;i++)r.push(t.levels[i]);r.sort(function(e,t){return e.height>t.height?1:t.height>e.height?-1:0});for(var a=r[r.length-1].height,n=r[r.length-1].bitrate,s=-1,o=0;o<t.levels.length;o++)if(t.levels[o].enabled=!0,t.levels[o].level||(t.levels[o].level=o),t.levels[o].height==a&&t.levels[o].bitrate==n){s=t.levels[o].level;break}-1!=s&&(l.abrEwmaDefaultEstimate=2.5*n,l.startLevel=s,l.autoLevelCapping=s,l.startLoad(),l.streamController.nextLevelSwitch()),d.addStats({type:"MANIFEST_PARSED data",time:performance.now()-d.getStartTime(),data:t}),d.logStatus("Manifest is Loaded and Parsed",t)}),l.on(a.Events.AUDIO_TRACKS_UPDATED,function(e,t){d.addStats({type:"Audio Tracks Updated",time:performance.now()-d.getStartTime()}),d.logStatus("No of audio tracks found: "+t.audioTracks.length)}),l.on(a.Events.AUDIO_TRACK_SWITCHING,function(e,t){d.addStats({type:"Audio Tracks Switching",time:performance.now()-d.getStartTime()}),d.logStatus("Audio track switching...",t)}),l.on(a.Events.AUDIO_TRACK_SWITCHED,function(e,t){d.addStats({type:"Audio Tracks switched",time:performance.now()-d.getStartTime()}),d.logStatus("Audio track switched")}),l.on(a.Events.LEVEL_SWITCHED,function(e,t){try{var r=[].concat(l.level);r.sort(function(e,t){return e.height>t.height?1:t.height>e.height?-1:0}),d.addStats({time:performance.now()-d.getStartTime(),type:"Media Level Switched",currentLevel:l.currentLevel,bitrate:r[l.currentLevel].bitrate}),d.logStatus("Video representation switched",r)}catch(e){}}),l.on(a.Events.FRAG_CHANGED,function(e,t){try{t&&t.frag&&t.frag.loaded&&(d.bandwidthConsumed+=Number(t.frag.loaded))}catch(e){}d.addStats({time:performance.now()-d.getStartTime(),type:"Fragments changed"}),d.logStatus("Video FRAG_CHANGED")}),l.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,function(e,t){d.addStats({time:performance.now()-d.getStartTime(),type:"FRAG_LOAD_EMERGENCY_ABORTED"}),d.logStatus("Video FRAG_LOAD_EMERGENCY_ABORTED")}),l.on(a.Events.FRAG_DECRYPTED,function(e,t){d.addStats({time:performance.now()-d.getStartTime(),type:"FRAG_DECRYPTED"}),d.logStatus("Video FRAG_DECRYPTED")}),l.on(a.Events.BUFFER_CREATED,function(e,t){d.logStatus("Video Buffer Created",t),d.addStats({time:performance.now()-d.getStartTime(),tracks:t?t.tracks:{},type:"Buffer Created"})}),l.on(a.Events.BUFFER_APPENDING,function(e,t){d.addStats({time:performance.now()-d.getStartTime(),type:"Buffer Appending"}),d.logStatus("Video Buffer Appeding")}),l.on(a.Events.FPS_DROP,function(e,t){d.logStatus("Video FPS_DROP"),d.addStats({time:performance.now()-d.getStartTime(),type:"frame Per Second drop",name:t.currentDropped+"/"+t.currentDecoded})})}.call(this,t),function(){var r=this._hls,i=this;r.on(a.Events.ERROR,function(e,t){switch(i.addStats({time:performance.now()-i.getStartTime(),data:t}),t.details){case a.ErrorDetails.MANIFEST_LOAD_ERROR:break;case a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:i.logError("Timeout while loading manifest");break;case a.ErrorDetails.MANIFEST_PARSING_ERROR:i.logError("Error while parsing manifest:"+t.reason);break;case a.ErrorDetails.LEVEL_EMPTY_ERROR:i.logError("Loaded level contains no fragments "+t.level+" "+t.url);break;case a.ErrorDetails.LEVEL_LOAD_ERROR:i.logError("Error while loading level playlist "+t.context.level+" "+t.url);break;case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:i.logError("Timeout while loading level playlist "+t.context.level+" "+t.url);break;case a.ErrorDetails.LEVEL_SWITCH_ERROR:i.logError("Error while trying to switch to level "+t.level);break;case a.ErrorDetails.FRAG_LOAD_ERROR:i.logError("Error while loading fragment "+t.frag.url);break;case a.ErrorDetails.FRAG_LOAD_TIMEOUT:i.logError("Timeout while loading fragment "+t.frag.url);break;case a.ErrorDetails.FRAG_LOOP_LOADING_ERROR:i.logError("Fragment-loop loading error");break;case a.ErrorDetails.FRAG_DECRYPT_ERROR:i.logError("Decrypting error:"+t.reason);break;case a.ErrorDetails.FRAG_PARSING_ERROR:i.logError("Parsing error:"+t.reason);break;case a.ErrorDetails.KEY_LOAD_ERROR:i.logError("Error while loading key "+t.frag.decryptdata.uri);break;case a.ErrorDetails.KEY_LOAD_TIMEOUT:i.logError("Timeout while loading key "+t.frag.decryptdata.uri);break;case a.ErrorDetails.BUFFER_APPEND_ERROR:i.logError("Buffer append error");break;case a.ErrorDetails.BUFFER_ADD_CODEC_ERROR:i.logError("Buffer add codec error for "+t.mimeType+":"+t.err.message);break;case a.ErrorDetails.BUFFER_APPENDING_ERROR:i.logError("Buffer appending error");break;case a.ErrorDetails.BUFFER_STALLED_ERROR:i.logError("Buffer stalled error")}if(t.fatal)switch(t.type){case a.ErrorTypes.MEDIA_ERROR:this.recover_media_error&&r.swapAudioCodec(),r.recoverMediaError(),this.recover_media_error=!0;break;case a.ErrorTypes.NETWORK_ERROR:i.logError("A network error occurred"),r.startLoad();break;default:i.logError("An unrecoverable error occurred")}})}.call(this),this.stats={stats_id:HippoVideo.generateUniqueId(),startTime:performance.now(),records:[],errors:[]}}function n(e){return(n="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 s(e,t){if(e=e,!(null!=(t=t)&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?t[Symbol.hasInstance](e):e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(i){var a=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 e,t,r=d(i);return e=a?(e=d(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments),r=this,!(t=e)||"object"!==n(t)&&"function"!=typeof t?l(r):t}}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}e.prototype={init:function(e){e.onMediaAttached&&this._hls.on(a.Events.MEDIA_ATTACHED,e.onMediaAttached),e.onManifestParser&&this._hls.on(a.Events.MANIFEST_PARSED,e.onManifestParser)},destroy:function(){this._hls.destroy()},attachPlayerMetrics:function({statsJsonSeed:e}){const t=this;t._hls.on(a.Events.MEDIA_ATTACHED,function(){t.hlsPlayerMetrics=new r.default({hlsInstance:t._hls,statsJsonSeed:e}),t.hlsPlayerMetrics.init()})},getMedia:function(){return this._hls.media},getLevels:function(){for(var e=[],t=0;t<this._hls.levels.length;t++)e.push(this._hls.levels[t]);return e},attachMedia:function(e){this._hls.attachMedia(e)},loadSource:function(e){this._hls.loadSource(e)},setRepresentation:function(e){if(null==e)r=-1;else{var t=this.getLevels();t.sort(function(e,t){return e.height>t.height?1:t.height>e.height?-1:0});for(var r=-1,i=0;i<this._hls.levels.length;i++)if(this._hls.levels[i].height==t[e].height&&this._hls.levels[i].bitrate==t[e].bitrate){r=i;break}}try{this._hls.currentLevel<r?this._hls.currentLevel=r:this._hls.nextLevel=r}catch(e){this._hls.nextLevel=r}this._hls.emit(a.Events.LEVEL_SWITCHING)},logStatus:function(){},logError:function(){this.debug&&console.error(console,arguments)},addStats:function(e,t){this.logStatus(e,t),(t?this.stats.errors:this.stats.records).push(e)},getStartTime:function(){return this.stats.startTime},getBandwidthConsumed:function(){return this.bandwidthConsumed}},e.isSupported=function(){return a.isSupported()};var u=function(e,a){var t=n;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e);var r=o(n);function n(e){s(this,n);var i,a=(i=r.call(this,e)).load.bind(l(i));return i.load=function(e,t,r){e.url.includes("?")?e.url=e.url+"&"+i.getSignature():e.url=e.url+"?"+i.getSignature(),a(e,t,r)},i}return n.prototype.getSignature=function(){return i=null,(t=a)&&(i="",r=0,Object.keys(t).forEach(function(e){0!=r&&(i+="&"),i+=e+"="+t[e],++r})),i;var t,r,i},n},c=a.DefaultConfig.abrController;return c.prototype._findBestLevel=function(e,t,r,i,a,n,s,o,l){for(var d=a;i<=d;d--){var u=l[d];if(u){var u=u.details,c=u?u.totalduration/u.fragments.length:t,u=!!u&&u.live,h=void 0,h=d<=e?s*r:o*r,f=l[d].realBitrate?Math.max(l[d].realBitrate,l[d].bitrate):l[d].bitrate,c=f*c/h;if(f<=h&&(!c||u&&!this.bitrateTestDelay||c<n))return d}}return-1},e}.apply(t,r);void 0!==t&&(e.exports=t)},56888:function(e,t,r){"use strict";r.r(t);r(47941),r(82526),r(57327),r(41539),r(38880),r(54747),r(49337);var i=r(4942),a=r(15671),n=r(43144),s=(r(9653),r(56977),r(92222),r(11373)),o=r.n(s),l=r(85468);function d(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach(function(e){(0,i.Z)(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}t.default=function(){function r(e){var t=e.hlsInstance,e=e.statsJsonSeed;(0,a.Z)(this,r),this.hls=t,this.media=t.media,this.statsJsonSeed=e}return(0,n.Z)(r,[{key:"init",value:function(){this.initLogger(),this.HLSLogger&&this.setupMetrics()}},{key:"initLogger",value:function(){var e,t;window.HippoVideo&&(t=(e=window.HippoVideo.Class).Level,this.generateStatConstants.call(this),this.HLSLogger=e.Logger.getLogger("[HLSAdapter]"),this.HLSLoggerLevel=t.INFO)}},{key:"generateStatConstants",value:function(){var e=(null==(e=window.HippoVideo)||null==(e=e.UserProfile)?void 0:e.tenantId)||null,t=(null==(t=window.HippoVideo)||null==(t=t.UserProfile)?void 0:t.userId)||null,r=null==(r=window.HippoVideo)?void 0:r.generateUniqueId(),i=!(null==(i=window.HippoVideo)||!i.isDelivery),a=null==(a=navigator.connection)?void 0:a.rtt,n=Intl.DateTimeFormat().resolvedOptions().timeZone;this.nonIndexedDataString="hlsPlayerMetrics;",i&&(this.nonIndexedDataString+="hlsPlayerMetrics-isDelivery;"),this.statsJsonSeed.mfInVideosPresent&&(this.nonIndexedDataString+="hlsPlayerMetrics-isPersonalised;"),n&&(this.nonIndexedDataString+="hlsPlayerMetrics-timeZone--".concat(n,";")),this.statsConstants=u(u({},this.statsJsonSeed),{},{tenant_id:e,user_id:t,session_id:r,isDelivery:i,rtt:a,timeZone:n})}},{key:"setupMetrics",value:function(){var r=this;r.timeChart={done:!0},r.media.addEventListener("play",function(){r.timeChart.playClickedAt=Number(performance.now().toFixed(2)),r.timeChart.done=!1}),r.hls.on(o().Events.FRAG_LOADED,function(e,t){r.timeChart.firstFragLoadedAt||(r.timeChart.firstFragLoadedAt=Number(performance.now().toFixed(2)),r.timeChart.done=!1);try{r.timeChart.bandwidthConsumed||(r.timeChart.bandwidthConsumed=0),t&&t.frag&&t.frag.loaded&&(r.timeChart.bandwidthConsumed+=Number(t.frag.loaded))}catch(e){}}),r.hls.on(o().Events.LEVEL_SWITCHED,function(){r.timeChart.levelSwitchedCount||(r.timeChart.levelSwitchedCount=0),r.timeChart.levelSwitchedCount++}),r.media.addEventListener("ended",function(){r.timeChart.mediaEndedAt||(r.timeChart.mediaEndedAt=Number(performance.now().toFixed(2)),r.timeChart.done=!1)}),r.media.addEventListener("waiting",function(){r.timeChart.mediaWaitingAtArr||(r.timeChart.mediaWaitingAtArr=[]),r.timeChart.mediaWaitingAtArr.push(Number(performance.now().toFixed(2)))}),r.media.addEventListener("playing",function(){var e,t;r.timeChart.mediaTimeLagArr||(r.timeChart.mediaTimeLagArr=[]),r.timeChart.mediaWaitingAtArr&&r.timeChart.mediaWaitingAtArr.length>r.timeChart.mediaTimeLagArr.length&&(e=(e=r.timeChart.mediaWaitingAtArr)[e.length-1],t=Number(performance.now().toFixed(2)),r.timeChart.mediaTimeLagArr.push(t-e),r.timeChart.mediaTimeLag=t-e),r.timeChart.done=!1}),r.media.addEventListener("seeked",function(){r.timeChart.mediaSeekedAt=Number(performance.now().toFixed(2)),r.timeChart.done=!1}),r.media.onerror=function(){r.timeChart.videoErroredMsg="Error ".concat(r.media.error.code,"; details: ").concat(r.media.error.message),r.timeChart.done=!1},window.addEventListener("beforeunload",function(){r.timeChart.windowUnloadAt=Number(performance.now().toFixed(2)),r.timeChart.done=!1,r.timeChartEval.call(r)}),setInterval(function(){r.timeChartEval()},2e3)}},{key:"timeChartEval",value:function(){var e,t,r=this;r.timeChart.done||(r.timeChart.playClickedAt&&(r.timeChart.firstFragLoadedAt&&(r.logg({metric_name:"time-to-first-frame",metric_value:Math.max(0,r.timeChart.firstFragLoadedAt-r.timeChart.playClickedAt)}),r.timeChart.videoStarted=!0,delete r.timeChart.playClickedAt),r.timeChart.videoPlayIntented=!0),(r.timeChart.mediaEndedAt||r.timeChart.windowUnloadAt)&&(r.timeChart.levelSwitchedCount&&(r.logg({metric_name:"number-of-variant-changes",metric_value:r.timeChart.levelSwitchedCount}),delete r.timeChart.levelSwitchedCount),r.timeChart.mediaWaitingAtArr&&(r.logg({metric_name:"video-stalled-count",metric_value:r.timeChart.mediaWaitingAtArr.length}),delete r.timeChart.mediaWaitingAtArr),r.timeChart.bandwidthConsumed&&(r.logg({metric_name:"video-bandwidth-used",metric_value:r.timeChart.bandwidthConsumed}),delete r.timeChart.bandwidthConsumed),r.timeChart.videoPlayIntented&&!r.timeChart.videoStarted&&r.timeChart.windowUnloadAt&&r.logg({metric_name:"video-adandon-before-start",metric_value:r.timeChart.windowUnloadAt}),!r.timeChart.videoPlayIntented&&r.timeChart.windowUnloadAt&&r.logg({metric_name:"page-adandon-before-clicking-play",metric_value:r.timeChart.windowUnloadAt}),(t=(0,l.jy)("delivery-loaded"))&&null!=(e=r.statsConstants)&&e.isDelivery&&(r.logg({metric_name:"hv-delivery-loaded",metric_value:t}),(0,l.Xb)("delivery-loaded")),delete r.timeChart.mediaEndedAt,delete r.timeChart.windowUnloadAt),r.timeChart.mediaTimeLag&&(r.logg({metric_name:"video-stalled-time-to-resume",metric_value:r.timeChart.mediaTimeLag}),r.timeChart.mediaSeekedAt&&(r.logg({metric_name:"video-stalledBySeek-time-to-resume",metric_value:r.timeChart.mediaTimeLag}),delete r.timeChart.mediaSeekedAt),delete r.timeChart.mediaTimeLag),r.timeChart.videoErroredMsg&&(r.logg({metric_name:"video-errored",metric_value:r.timeChart.videoErroredMsg}),delete r.timeChart.videoErroredMsg),r.timeChart.done=!0)}},{key:"logg",value:function(e){var t=this.hls.currentLevel;this.HLSLogger.log(this.HLSLoggerLevel,this.nonIndexedDataString,u(u(u({},this.statsConstants),e),{},{resolutionPlayed:t}))}}]),r}()}}]);
|