filesbox/web/dist/design/designstatic/chatroom/video/flv.min1.js
2024-07-26 14:10:54 +08:00

3 lines
169 KiB
JavaScript

(function(fe){if(typeof exports=="object"&&typeof module!="undefined")module.exports=fe();else if(typeof define=="function"&&define.amd)define([],fe);else{var R;R=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,R.flvjs=fe()}})(function(){var fe;return function R(P,T,k){function C(n,e){if(!T[n]){if(!P[n]){var t=typeof require=="function"&&require;if(!e&&t)return t(n,!0);if(I)return I(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var s=T[n]={exports:{}};P[n][0].call(s.exports,function(d){var y=P[n][1][d];return C(y||d)},s,s.exports,R,P,T,k)}return T[n].exports}for(var I=typeof require=="function"&&require,a=0;a<k.length;a++)C(k[a]);return C}({1:[function(R,P,T){(function(k,C){(function(I,a){typeof T=="object"&&P!==void 0?P.exports=a():typeof fe=="function"&&fe.amd?fe(a):I.ES6Promise=a()})(this,function(){"use strict";function I(O){var D=typeof O;return O!==null&&(D==="object"||D==="function")}function a(O){return typeof O=="function"}function n(O){Q=O}function e(O){Z=O}function t(){return H!==void 0?function(){H(s)}:r()}function r(){var O=setTimeout;return function(){return O(s,1)}}function s(){for(var O=0;O<V;O+=2)(0,ne[O])(ne[O+1]),ne[O]=void 0,ne[O+1]=void 0;V=0}function d(O,D){var x=this,N=new this.constructor(l);N[le]===void 0&&M(N);var j=x._state;if(j){var q=arguments[j-1];Z(function(){return v(j,N,q,x._result)})}else S(x,N,O,D);return N}function y(O){var D=this;if(O&&typeof O=="object"&&O.constructor===D)return O;var x=new D(l);return E(x,O),x}function l(){}function c(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function f(O){try{return O.then}catch(D){return oe.error=D,oe}}function i(O,D,x,N){try{O.call(D,x,N)}catch(j){return j}}function m(O,D,x){Z(function(N){var j=!1,q=i(x,D,function(J){j||(j=!0,D!==J?E(N,J):b(N,J))},function(J){j||(j=!0,L(N,J))},"Settle: "+(N._label||" unknown promise"));!j&&q&&(j=!0,L(N,q))},O)}function o(O,D){D._state===he?b(O,D._result):D._state===ae?L(O,D._result):S(D,void 0,function(x){return E(O,x)},function(x){return L(O,x)})}function u(O,D,x){D.constructor===O.constructor&&x===d&&D.constructor.resolve===y?o(O,D):x===oe?(L(O,oe.error),oe.error=null):x===void 0?b(O,D):a(x)?m(O,D,x):b(O,D)}function E(O,D){O===D?L(O,c()):I(D)?u(O,D,f(D)):b(O,D)}function g(O){O._onerror&&O._onerror(O._result),_(O)}function b(O,D){O._state===se&&(O._result=D,O._state=he,O._subscribers.length!==0&&Z(_,O))}function L(O,D){O._state===se&&(O._state=ae,O._result=D,Z(g,O))}function S(O,D,x,N){var j=O._subscribers,q=j.length;O._onerror=null,j[q]=D,j[q+he]=x,j[q+ae]=N,q===0&&O._state&&Z(_,O)}function _(O){var D=O._subscribers,x=O._state;if(D.length!==0){for(var N=void 0,j=void 0,q=O._result,J=0;J<D.length;J+=3)N=D[J],j=D[J+x],N?v(x,N,j,q):j(q);O._subscribers.length=0}}function h(O,D){try{return O(D)}catch(x){return oe.error=x,oe}}function v(O,D,x,N){var j=a(x),q=void 0,J=void 0,_e=void 0,pe=void 0;if(j){if(q=h(x,N),q===oe?(pe=!0,J=q.error,q.error=null):_e=!0,D===q)return void L(D,p())}else q=N,_e=!0;D._state!==se||(j&&_e?E(D,q):pe?L(D,J):O===he?b(D,q):O===ae&&L(D,q))}function A(O,D){try{D(function(x){E(O,x)},function(x){L(O,x)})}catch(x){L(O,x)}}function w(){return ce++}function M(O){O[le]=ce++,O._state=void 0,O._result=void 0,O._subscribers=[]}function B(){return new Error("Array Methods must be provided an Array")}function G(O){return new me(this,O).promise}function U(O){var D=this;return new D(Y(O)?function(x,N){for(var j=O.length,q=0;q<j;q++)D.resolve(O[q]).then(x,N)}:function(x,N){return N(new TypeError("You must pass an array to race."))})}function K(O){var D=this,x=new D(l);return L(x,O),x}function z(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function W(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function F(){var O=void 0;if(C!==void 0)O=C;else if(typeof self!="undefined")O=self;else try{O=Function("return this")()}catch(N){throw new Error("polyfill failed because global object is unavailable in this environment")}var D=O.Promise;if(D){var x=null;try{x=Object.prototype.toString.call(D.resolve())}catch(N){}if(x==="[object Promise]"&&!D.cast)return}O.Promise=ie}var X=void 0;X=Array.isArray?Array.isArray:function(O){return Object.prototype.toString.call(O)==="[object Array]"};var Y=X,V=0,H=void 0,Q=void 0,Z=function(O,D){ne[V]=O,ne[V+1]=D,(V+=2)===2&&(Q?Q(s):$())},ue=typeof window!="undefined"?window:void 0,re=ue||{},ee=re.MutationObserver||re.WebKitMutationObserver,te=typeof self=="undefined"&&k!==void 0&&{}.toString.call(k)==="[object process]",de=typeof Uint8ClampedArray!="undefined"&&typeof importScripts!="undefined"&&typeof MessageChannel!="undefined",ne=new Array(1e3),$=void 0;$=te?function(){return function(){return k.nextTick(s)}}():ee?function(){var O=0,D=new ee(s),x=document.createTextNode("");return D.observe(x,{characterData:!0}),function(){x.data=O=++O%2}}():de?function(){var O=new MessageChannel;return O.port1.onmessage=s,function(){return O.port2.postMessage(0)}}():ue===void 0&&typeof R=="function"?function(){try{var O=Function("return this")().require("vertx");return H=O.runOnLoop||O.runOnContext,t()}catch(D){return r()}}():r();var le=Math.random().toString(36).substring(2),se=void 0,he=1,ae=2,oe={error:null},ce=0,me=function(){function O(D,x){this._instanceConstructor=D,this.promise=new D(l),this.promise[le]||M(this.promise),Y(x)?(this.length=x.length,this._remaining=x.length,this._result=new Array(this.length),this.length===0?b(this.promise,this._result):(this.length=this.length||0,this._enumerate(x),this._remaining===0&&b(this.promise,this._result))):L(this.promise,B())}return O.prototype._enumerate=function(D){for(var x=0;this._state===se&&x<D.length;x++)this._eachEntry(D[x],x)},O.prototype._eachEntry=function(D,x){var N=this._instanceConstructor,j=N.resolve;if(j===y){var q=f(D);if(q===d&&D._state!==se)this._settledAt(D._state,x,D._result);else if(typeof q!="function")this._remaining--,this._result[x]=D;else if(N===ie){var J=new N(l);u(J,D,q),this._willSettleAt(J,x)}else this._willSettleAt(new N(function(_e){return _e(D)}),x)}else this._willSettleAt(j(D),x)},O.prototype._settledAt=function(D,x,N){var j=this.promise;j._state===se&&(this._remaining--,D===ae?L(j,N):this._result[x]=N),this._remaining===0&&b(j,this._result)},O.prototype._willSettleAt=function(D,x){var N=this;S(D,void 0,function(j){return N._settledAt(he,x,j)},function(j){return N._settledAt(ae,x,j)})},O}(),ie=function(){function O(D){this[le]=w(),this._result=this._state=void 0,this._subscribers=[],l!==D&&(typeof D!="function"&&z(),this instanceof O?A(this,D):W())}return O.prototype.catch=function(D){return this.then(null,D)},O.prototype.finally=function(D){var x=this,N=x.constructor;return a(D)?x.then(function(j){return N.resolve(D()).then(function(){return j})},function(j){return N.resolve(D()).then(function(){throw j})}):x.then(D,D)},O}();return ie.prototype.then=d,ie.all=G,ie.race=U,ie.resolve=y,ie.reject=K,ie._setScheduler=n,ie._setAsap=e,ie._asap=Z,ie.polyfill=F,ie.Promise=ie,ie})}).call(this,R("_process"),typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{_process:3}],2:[function(R,P,T){function k(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function C(e){return typeof e=="function"}function I(e){return typeof e=="number"}function a(e){return typeof e=="object"&&e!==null}function n(e){return e===void 0}P.exports=k,k.EventEmitter=k,k.prototype._events=void 0,k.prototype._maxListeners=void 0,k.defaultMaxListeners=10,k.prototype.setMaxListeners=function(e){if(!I(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},k.prototype.emit=function(e){var t,r,s,d,y,l;if(this._events||(this._events={}),e==="error"&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(r=this._events[e],n(r))return!1;if(C(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:d=Array.prototype.slice.call(arguments,1),r.apply(this,d)}else if(a(r))for(d=Array.prototype.slice.call(arguments,1),l=r.slice(),s=l.length,y=0;y<s;y++)l[y].apply(this,d);return!0},k.prototype.addListener=function(e,t){var r;if(!C(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,C(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(r=n(this._maxListeners)?k.defaultMaxListeners:this._maxListeners)&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),typeof console.trace=="function"&&console.trace()),this},k.prototype.on=k.prototype.addListener,k.prototype.once=function(e,t){function r(){this.removeListener(e,r),s||(s=!0,t.apply(this,arguments))}if(!C(t))throw TypeError("listener must be a function");var s=!1;return r.listener=t,this.on(e,r),this},k.prototype.removeListener=function(e,t){var r,s,d,y;if(!C(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],d=r.length,s=-1,r===t||C(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(r)){for(y=d;y-- >0;)if(r[y]===t||r[y].listener&&r[y].listener===t){s=y;break}if(s<0)return this;r.length===1?(r.length=0,delete this._events[e]):r.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},k.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[e]&&delete this._events[e],this;if(arguments.length===0){for(t in this._events)t!=="removeListener"&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],C(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},k.prototype.listeners=function(e){return this._events&&this._events[e]?C(this._events[e])?[this._events[e]]:this._events[e].slice():[]},k.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(C(t))return 1;if(t)return t.length}return 0},k.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(R,P,T){function k(){throw new Error("setTimeout has not been defined")}function C(){throw new Error("clearTimeout has not been defined")}function I(i){if(s===setTimeout)return setTimeout(i,0);if((s===k||!s)&&setTimeout)return s=setTimeout,setTimeout(i,0);try{return s(i,0)}catch(m){try{return s.call(null,i,0)}catch(o){return s.call(this,i,0)}}}function a(i){if(d===clearTimeout)return clearTimeout(i);if((d===C||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(i);try{return d(i)}catch(m){try{return d.call(null,i)}catch(o){return d.call(this,i)}}}function n(){p&&l&&(p=!1,l.length?c=l.concat(c):f=-1,c.length&&e())}function e(){if(!p){var i=I(n);p=!0;for(var m=c.length;m;){for(l=c,c=[];++f<m;)l&&l[f].run();f=-1,m=c.length}l=null,p=!1,a(i)}}function t(i,m){this.fun=i,this.array=m}function r(){}var s,d,y=P.exports={};(function(){try{s=typeof setTimeout=="function"?setTimeout:k}catch(i){s=k}try{d=typeof clearTimeout=="function"?clearTimeout:C}catch(i){d=C}})();var l,c=[],p=!1,f=-1;y.nextTick=function(i){var m=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)m[o-1]=arguments[o];c.push(new t(i,m)),c.length!==1||p||I(e)},t.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={},y.on=r,y.addListener=r,y.once=r,y.off=r,y.removeListener=r,y.removeAllListeners=r,y.emit=r,y.prependListener=r,y.prependOnceListener=r,y.listeners=function(i){return[]},y.binding=function(i){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(i){throw new Error("process.chdir is not supported")},y.umask=function(){return 0}},{}],4:[function(R,P,T){var k=arguments[3],C=arguments[4],I=arguments[5],a=JSON.stringify;P.exports=function(n,e){function t(L){m[L]=!0;for(var S in C[L][1]){var _=C[L][1][S];m[_]||t(_)}}for(var r,s=Object.keys(I),d=0,y=s.length;d<y;d++){var l=s[d],c=I[l].exports;if(c===n||c&&c.default===n){r=l;break}}if(!r){r=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var p={},d=0,y=s.length;d<y;d++){var l=s[d];p[l]=l}C[r]=["function(require,module,exports){"+n+"(self); }",p]}var f=Math.floor(Math.pow(16,8)*Math.random()).toString(16),i={};i[r]=r,C[f]=["function(require,module,exports){var f = require("+a(r)+");(f.default ? f.default : f)(self);}",i];var m={};t(f);var o="("+k+")({"+Object.keys(m).map(function(L){return a(L)+":["+C[L][0]+","+a(C[L][1])+"]"}).join(",")+"},{},["+a(f)+"])",u=window.URL||window.webkitURL||window.mozURL||window.msURL,E=new Blob([o],{type:"text/javascript"});if(e&&e.bare)return E;var g=u.createObjectURL(E),b=new Worker(g);return b.objectURL=g,b}},{}],5:[function(R,P,T){"use strict";function k(){return Object.assign({},C)}Object.defineProperty(T,"__esModule",{value:!0}),T.createDefaultConfig=k;var C=T.defaultConfig={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!1,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0}},{}],6:[function(R,P,T){"use strict";function k(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function t(r,s){for(var d=0;d<s.length;d++){var y=s[d];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(r,y.key,y)}}return function(r,s,d){return s&&t(r.prototype,s),d&&t(r,d),r}}(),I=R("../io/io-controller.js"),a=function(t){return t&&t.__esModule?t:{default:t}}(I),n=R("../config.js"),e=function(){function t(){k(this,t)}return C(t,null,[{key:"supportMSEH264Playback",value:function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"supportNetworkStreamIO",value:function(){var r=new a.default({},(0,n.createDefaultConfig)()),s=r.loaderType;return r.destroy(),s=="fetch-stream-loader"||s=="xhr-moz-chunked-loader"}},{key:"getNetworkLoaderTypeName",value:function(){var r=new a.default({},(0,n.createDefaultConfig)()),s=r.loaderType;return r.destroy(),s}},{key:"supportNativeMediaPlayback",value:function(r){t.videoElement==null&&(t.videoElement=window.document.createElement("video"));var s=t.videoElement.canPlayType(r);return s==="probably"||s=="maybe"}},{key:"getFeatureList",value:function(){var r={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return r.mseFlvPlayback=t.supportMSEH264Playback(),r.networkStreamIO=t.supportNetworkStreamIO(),r.networkLoaderName=t.getNetworkLoaderTypeName(),r.mseLiveFlvPlayback=r.mseFlvPlayback&&r.networkStreamIO,r.nativeMP4H264Playback=t.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),r.nativeWebmVP8Playback=t.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),r.nativeWebmVP9Playback=t.supportNativeMediaPlayback('video/webm; codecs="vp9"'),r}}]),t}();T.default=e},{"../config.js":5,"../io/io-controller.js":23}],7:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(){k(this,a),this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return C(a,[{key:"isComplete",value:function(){var n=this.hasAudio===!1||this.hasAudio===!0&&this.audioCodec!=null&&this.audioSampleRate!=null&&this.audioChannelCount!=null,e=this.hasVideo===!1||this.hasVideo===!0&&this.videoCodec!=null&&this.width!=null&&this.height!=null&&this.fps!=null&&this.profile!=null&&this.level!=null&&this.refFrames!=null&&this.chromaFormat!=null&&this.sarNum!=null&&this.sarDen!=null;return this.mimeType!=null&&this.duration!=null&&this.metadata!=null&&this.hasKeyframesIndex!=null&&n&&e}},{key:"isSeekable",value:function(){return this.hasKeyframesIndex===!0}},{key:"getNearestKeyframe",value:function(n){if(this.keyframesIndex==null)return null;var e=this.keyframesIndex,t=this._search(e.times,n);return{index:t,milliseconds:e.times[t],fileposition:e.filepositions[t]}}},{key:"_search",value:function(n,e){var t=0,r=n.length-1,s=0,d=0,y=r;for(e<n[0]&&(t=0,d=y+1);d<=y;){if((s=d+Math.floor((y-d)/2))===r||e>=n[s]&&e<n[s+1]){t=s;break}n[s]<e?d=s+1:y=s-1}return t}}]),a}();T.default=I},{}],8:[function(R,P,T){"use strict";function k(I,a){if(!(I instanceof a))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function I(a,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(a,t.key,t)}}return function(a,n,e){return n&&I(a.prototype,n),e&&I(a,e),a}}();T.SampleInfo=function I(a,n,e,t,r){k(this,I),this.dts=a,this.pts=n,this.duration=e,this.originalDts=t,this.isSyncPoint=r,this.fileposition=null},T.MediaSegmentInfo=function(){function I(){k(this,I),this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return C(I,[{key:"appendSyncPoint",value:function(a){a.isSyncPoint=!0,this.syncPoints.push(a)}}]),I}(),T.IDRSampleList=function(){function I(){k(this,I),this._list=[]}return C(I,[{key:"clear",value:function(){this._list=[]}},{key:"appendArray",value:function(a){var n=this._list;a.length!==0&&(n.length>0&&a[0].originalDts<n[n.length-1].originalDts&&this.clear(),Array.prototype.push.apply(n,a))}},{key:"getLastSyncPointBeforeDts",value:function(a){if(this._list.length==0)return null;var n=this._list,e=0,t=n.length-1,r=0,s=0,d=t;for(a<n[0].dts&&(e=0,s=d+1);s<=d;){if((r=s+Math.floor((d-s)/2))===t||a>=n[r].dts&&a<n[r+1].dts){e=r;break}n[r].dts<a?s=r+1:d=r-1}return this._list[e]}}]),I}(),T.MediaSegmentInfoList=function(){function I(a){k(this,I),this._type=a,this._list=[],this._lastAppendLocation=-1}return C(I,[{key:"isEmpty",value:function(){return this._list.length===0}},{key:"clear",value:function(){this._list=[],this._lastAppendLocation=-1}},{key:"_searchNearestSegmentBefore",value:function(a){var n=this._list;if(n.length===0)return-2;var e=n.length-1,t=0,r=0,s=e,d=0;if(a<n[0].originalBeginDts)return d=-1;for(;r<=s;){if((t=r+Math.floor((s-r)/2))===e||a>n[t].lastSample.originalDts&&a<n[t+1].originalBeginDts){d=t;break}n[t].originalBeginDts<a?r=t+1:s=t-1}return d}},{key:"_searchNearestSegmentAfter",value:function(a){return this._searchNearestSegmentBefore(a)+1}},{key:"append",value:function(a){var n=this._list,e=a,t=this._lastAppendLocation,r=0;t!==-1&&t<n.length&&e.originalBeginDts>=n[t].lastSample.originalDts&&(t===n.length-1||t<n.length-1&&e.originalBeginDts<n[t+1].originalBeginDts)?r=t+1:n.length>0&&(r=this._searchNearestSegmentBefore(e.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,e)}},{key:"getLastSegmentBefore",value:function(a){var n=this._searchNearestSegmentBefore(a);return n>=0?this._list[n]:null}},{key:"getLastSampleBefore",value:function(a){var n=this.getLastSegmentBefore(a);return n!=null?n.lastSample:null}},{key:"getLastSyncPointBefore",value:function(a){for(var n=this._searchNearestSegmentBefore(a),e=this._list[n].syncPoints;e.length===0&&n>0;)n--,e=this._list[n].syncPoints;return e.length>0?e[e.length-1]:null}},{key:"type",get:function(){return this._type}},{key:"length",get:function(){return this._list.length}}]),I}()},{}],9:[function(R,P,T){"use strict";function k(f){return f&&f.__esModule?f:{default:f}}function C(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function f(i,m){for(var o=0;o<m.length;o++){var u=m[o];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(i,u.key,u)}}return function(i,m,o){return m&&f(i.prototype,m),o&&f(i,o),i}}(),a=R("events"),n=k(a),e=R("../utils/logger.js"),t=k(e),r=R("../utils/browser.js"),s=k(r),d=R("./mse-events.js"),y=k(d),l=R("./media-segment-info.js"),c=R("../utils/exception.js"),p=function(){function f(i){C(this,f),this.TAG="MSEController",this._config=i,this._emitter=new n.default,this._config.isLive&&this._config.autoCleanupSourceBuffer==null&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new l.IDRSampleList}return I(f,[{key:"destroy",value:function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(i,m){this._emitter.addListener(i,m)}},{key:"off",value:function(i,m){this._emitter.removeListener(i,m)}},{key:"attachMediaElement",value:function(i){if(this._mediaSource)throw new c.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var m=this._mediaSource=new window.MediaSource;m.addEventListener("sourceopen",this.e.onSourceOpen),m.addEventListener("sourceended",this.e.onSourceEnded),m.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=i,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),i.src=this._mediaSourceObjectURL}},{key:"detachMediaElement",value:function(){if(this._mediaSource){var i=this._mediaSource;for(var m in this._sourceBuffers){var o=this._pendingSegments[m];o.splice(0,o.length),this._pendingSegments[m]=null,this._pendingRemoveRanges[m]=null,this._lastInitSegments[m]=null;var u=this._sourceBuffers[m];if(u){if(i.readyState!=="closed"){try{i.removeSourceBuffer(u)}catch(E){t.default.e(this.TAG,E.message)}u.removeEventListener("error",this.e.onSourceBufferError),u.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[m]=null,this._sourceBuffers[m]=null}}if(i.readyState==="open")try{i.endOfStream()}catch(E){t.default.e(this.TAG,E.message)}i.removeEventListener("sourceopen",this.e.onSourceOpen),i.removeEventListener("sourceended",this.e.onSourceEnded),i.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}},{key:"appendInitSegment",value:function(i,m){if(!this._mediaSource||this._mediaSource.readyState!=="open")return this._pendingSourceBufferInit.push(i),void this._pendingSegments[i.type].push(i);var o=i,u=""+o.container;o.codec&&o.codec.length>0&&(u+=";codecs="+o.codec);var E=!1;if(t.default.v(this.TAG,"Received Initialization Segment, mimeType: "+u),this._lastInitSegments[o.type]=o,u!==this._mimeTypes[o.type]){if(this._mimeTypes[o.type])t.default.v(this.TAG,"Notice: "+o.type+" mimeType changed, origin: "+this._mimeTypes[o.type]+", target: "+u);else{E=!0;try{var g=this._sourceBuffers[o.type]=this._mediaSource.addSourceBuffer(u);g.addEventListener("error",this.e.onSourceBufferError),g.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(b){return t.default.e(this.TAG,b.message),void this._emitter.emit(y.default.ERROR,{code:b.code,msg:b.message})}}this._mimeTypes[o.type]=u}m||this._pendingSegments[o.type].push(o),E||this._sourceBuffers[o.type]&&!this._sourceBuffers[o.type].updating&&this._doAppendSegments(),s.default.safari&&o.container==="audio/mpeg"&&o.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=o.mediaDuration/1e3,this._updateMediaSourceDuration())}},{key:"appendMediaSegment",value:function(i){var m=i;this._pendingSegments[m.type].push(m),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var o=this._sourceBuffers[m.type];!o||o.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}},{key:"seek",value:function(i){for(var m in this._sourceBuffers)if(this._sourceBuffers[m]){var o=this._sourceBuffers[m];if(this._mediaSource.readyState==="open")try{o.abort()}catch(S){t.default.e(this.TAG,S.message)}this._idrList.clear();var u=this._pendingSegments[m];if(u.splice(0,u.length),this._mediaSource.readyState!=="closed"){for(var E=0;E<o.buffered.length;E++){var g=o.buffered.start(E),b=o.buffered.end(E);this._pendingRemoveRanges[m].push({start:g,end:b})}if(o.updating||this._doRemoveRanges(),s.default.safari){var L=this._lastInitSegments[m];L&&(this._pendingSegments[m].push(L),o.updating||this._doAppendSegments())}}}}},{key:"endOfStream",value:function(){var i=this._mediaSource,m=this._sourceBuffers;if(!i||i.readyState!=="open")return void(i&&i.readyState==="closed"&&this._hasPendingSegments()&&(this._hasPendingEos=!0));m.video&&m.video.updating||m.audio&&m.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,i.endOfStream())}},{key:"getNearestKeyframe",value:function(i){return this._idrList.getLastSyncPointBeforeDts(i)}},{key:"_needCleanupSourceBuffer",value:function(){if(!this._config.autoCleanupSourceBuffer)return!1;var i=this._mediaElement.currentTime;for(var m in this._sourceBuffers){var o=this._sourceBuffers[m];if(o){var u=o.buffered;if(u.length>=1&&i-u.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var i=this._mediaElement.currentTime;for(var m in this._sourceBuffers){var o=this._sourceBuffers[m];if(o){for(var u=o.buffered,E=!1,g=0;g<u.length;g++){var b=u.start(g),L=u.end(g);if(b<=i&&i<L+3){if(i-b>=this._config.autoCleanupMaxBackwardDuration){E=!0;var S=i-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[m].push({start:b,end:S})}}else L<i&&(E=!0,this._pendingRemoveRanges[m].push({start:b,end:L}))}E&&!o.updating&&this._doRemoveRanges()}}}},{key:"_updateMediaSourceDuration",value:function(){var i=this._sourceBuffers;if(this._mediaElement.readyState!==0&&this._mediaSource.readyState==="open"&&!(i.video&&i.video.updating||i.audio&&i.audio.updating)){var m=this._mediaSource.duration,o=this._pendingMediaDuration;o>0&&(isNaN(m)||o>m)&&(t.default.v(this.TAG,"Update MediaSource duration from "+m+" to "+o),this._mediaSource.duration=o),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}},{key:"_doRemoveRanges",value:function(){for(var i in this._pendingRemoveRanges)if(this._sourceBuffers[i]&&!this._sourceBuffers[i].updating)for(var m=this._sourceBuffers[i],o=this._pendingRemoveRanges[i];o.length&&!m.updating;){var u=o.shift();m.remove(u.start,u.end)}}},{key:"_doAppendSegments",value:function(){var i=this._pendingSegments;for(var m in i)if(this._sourceBuffers[m]&&!this._sourceBuffers[m].updating&&i[m].length>0){var o=i[m].shift();if(o.timestampOffset){var u=this._sourceBuffers[m].timestampOffset,E=o.timestampOffset/1e3,g=Math.abs(u-E);g>.1&&(t.default.v(this.TAG,"Update MPEG audio timestampOffset from "+u+" to "+E),this._sourceBuffers[m].timestampOffset=E),delete o.timestampOffset}if(!o.data||o.data.byteLength===0)continue;try{this._sourceBuffers[m].appendBuffer(o.data),this._isBufferFull=!1,m==="video"&&o.hasOwnProperty("info")&&this._idrList.appendArray(o.info.syncPoints)}catch(b){this._pendingSegments[m].unshift(o),b.code===22?(this._isBufferFull||this._emitter.emit(y.default.BUFFER_FULL),this._isBufferFull=!0):(t.default.e(this.TAG,b.message),this._emitter.emit(y.default.ERROR,{code:b.code,msg:b.message}))}}}},{key:"_onSourceOpen",value:function(){if(t.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var i=this._pendingSourceBufferInit;i.length;){var m=i.shift();this.appendInitSegment(m,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(y.default.SOURCE_OPEN)}},{key:"_onSourceEnded",value:function(){t.default.v(this.TAG,"MediaSource onSourceEnded")}},{key:"_onSourceClose",value:function(){t.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}},{key:"_hasPendingSegments",value:function(){var i=this._pendingSegments;return i.video.length>0||i.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var i=this._pendingRemoveRanges;return i.video.length>0||i.audio.length>0}},{key:"_onSourceBufferUpdateEnd",value:function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(y.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(i){t.default.e(this.TAG,"SourceBuffer Error: "+i)}}]),f}();T.default=p},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./media-segment-info.js":8,"./mse-events.js":10,events:2}],10:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};T.default=k},{}],11:[function(R,P,T){"use strict";function k(u){return u&&u.__esModule?u:{default:u}}function C(u,E){if(!(u instanceof E))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function u(E,g){for(var b=0;b<g.length;b++){var L=g[b];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(E,L.key,L)}}return function(E,g,b){return g&&u(E.prototype,g),b&&u(E,b),E}}(),a=R("events"),n=k(a),e=R("../utils/logger.js"),t=k(e),r=R("../utils/logging-control.js"),s=k(r),d=R("./transmuxing-controller.js"),y=k(d),l=R("./transmuxing-events.js"),c=k(l),p=R("./transmuxing-worker.js"),f=k(p),i=R("./media-info.js"),m=k(i),o=function(){function u(E,g){if(C(this,u),this.TAG="Transmuxer",this._emitter=new n.default,g.enableWorker&&typeof Worker!="undefined")try{var b=R("webworkify");this._worker=b(f.default),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[E,g]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},s.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:s.default.getConfig()})}catch(S){t.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new y.default(E,g)}else this._controller=new y.default(E,g);if(this._controller){var L=this._controller;L.on(c.default.IO_ERROR,this._onIOError.bind(this)),L.on(c.default.DEMUX_ERROR,this._onDemuxError.bind(this)),L.on(c.default.INIT_SEGMENT,this._onInitSegment.bind(this)),L.on(c.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),L.on(c.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),L.on(c.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),L.on(c.default.MEDIA_INFO,this._onMediaInfo.bind(this)),L.on(c.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),L.on(c.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),L.on(c.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),L.on(c.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return I(u,[{key:"destroy",value:function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),s.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(E,g){this._emitter.addListener(E,g)}},{key:"off",value:function(E,g){this._emitter.removeListener(E,g)}},{key:"hasWorker",value:function(){return this._worker!=null}},{key:"open",value:function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}},{key:"close",value:function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}},{key:"seek",value:function(E){this._worker?this._worker.postMessage({cmd:"seek",param:E}):this._controller.seek(E)}},{key:"pause",value:function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}},{key:"resume",value:function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}},{key:"_onInitSegment",value:function(E,g){var b=this;Promise.resolve().then(function(){b._emitter.emit(c.default.INIT_SEGMENT,E,g)})}},{key:"_onMediaSegment",value:function(E,g){var b=this;Promise.resolve().then(function(){b._emitter.emit(c.default.MEDIA_SEGMENT,E,g)})}},{key:"_onLoadingComplete",value:function(){var E=this;Promise.resolve().then(function(){E._emitter.emit(c.default.LOADING_COMPLETE)})}},{key:"_onRecoveredEarlyEof",value:function(){var E=this;Promise.resolve().then(function(){E._emitter.emit(c.default.RECOVERED_EARLY_EOF)})}},{key:"_onMediaInfo",value:function(E){var g=this;Promise.resolve().then(function(){g._emitter.emit(c.default.MEDIA_INFO,E)})}},{key:"_onMetaDataArrived",value:function(E){var g=this;Promise.resolve().then(function(){g._emitter.emit(c.default.METADATA_ARRIVED,E)})}},{key:"_onScriptDataArrived",value:function(E){var g=this;Promise.resolve().then(function(){g._emitter.emit(c.default.SCRIPTDATA_ARRIVED,E)})}},{key:"_onStatisticsInfo",value:function(E){var g=this;Promise.resolve().then(function(){g._emitter.emit(c.default.STATISTICS_INFO,E)})}},{key:"_onIOError",value:function(E,g){var b=this;Promise.resolve().then(function(){b._emitter.emit(c.default.IO_ERROR,E,g)})}},{key:"_onDemuxError",value:function(E,g){var b=this;Promise.resolve().then(function(){b._emitter.emit(c.default.DEMUX_ERROR,E,g)})}},{key:"_onRecommendSeekpoint",value:function(E){var g=this;Promise.resolve().then(function(){g._emitter.emit(c.default.RECOMMEND_SEEKPOINT,E)})}},{key:"_onLoggingConfigChanged",value:function(E){this._worker&&this._worker.postMessage({cmd:"logging_config",param:E})}},{key:"_onWorkerMessage",value:function(E){var g=E.data,b=g.data;if(g.msg==="destroyed"||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(g.msg){case c.default.INIT_SEGMENT:case c.default.MEDIA_SEGMENT:this._emitter.emit(g.msg,b.type,b.data);break;case c.default.LOADING_COMPLETE:case c.default.RECOVERED_EARLY_EOF:this._emitter.emit(g.msg);break;case c.default.MEDIA_INFO:Object.setPrototypeOf(b,m.default.prototype),this._emitter.emit(g.msg,b);break;case c.default.METADATA_ARRIVED:case c.default.SCRIPTDATA_ARRIVED:case c.default.STATISTICS_INFO:this._emitter.emit(g.msg,b);break;case c.default.IO_ERROR:case c.default.DEMUX_ERROR:this._emitter.emit(g.msg,b.type,b.info);break;case c.default.RECOMMEND_SEEKPOINT:this._emitter.emit(g.msg,b);break;case"logcat_callback":t.default.emitter.emit("log",b.type,b.logcat)}}}]),u}();T.default=o},{"../utils/logger.js":41,"../utils/logging-control.js":42,"./media-info.js":7,"./transmuxing-controller.js":12,"./transmuxing-events.js":13,"./transmuxing-worker.js":14,events:2,webworkify:4}],12:[function(R,P,T){"use strict";function k(L){return L&&L.__esModule?L:{default:L}}function C(L,S){if(!(L instanceof S))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function L(S,_){for(var h=0;h<_.length;h++){var v=_[h];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(S,v.key,v)}}return function(S,_,h){return _&&L(S.prototype,_),h&&L(S,h),S}}(),a=R("events"),n=k(a),e=R("../utils/logger.js"),t=k(e),r=R("../utils/browser.js"),s=k(r),d=R("./media-info.js"),y=k(d),l=R("../demux/flv-demuxer.js"),c=k(l),p=R("../remux/mp4-remuxer.js"),f=k(p),i=R("../demux/demux-errors.js"),m=k(i),o=R("../io/io-controller.js"),u=k(o),E=R("./transmuxing-events.js"),g=k(E),b=(R("../io/loader.js"),function(){function L(S,_){C(this,L),this.TAG="TransmuxingController",this._emitter=new n.default,this._config=_,S.segments||(S.segments=[{duration:S.duration,filesize:S.filesize,url:S.url}]),typeof S.cors!="boolean"&&(S.cors=!0),typeof S.withCredentials!="boolean"&&(S.withCredentials=!1),this._mediaDataSource=S,this._currentSegmentIndex=0;var h=0;this._mediaDataSource.segments.forEach(function(v){v.timestampBase=h,h+=v.duration,v.cors=S.cors,v.withCredentials=S.withCredentials,_.referrerPolicy&&(v.referrerPolicy=_.referrerPolicy)}),isNaN(h)||this._mediaDataSource.duration===h||(this._mediaDataSource.duration=h),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return I(L,[{key:"destroy",value:function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(S,_){this._emitter.addListener(S,_)}},{key:"off",value:function(S,_){this._emitter.removeListener(S,_)}},{key:"start",value:function(){this._loadSegment(0),this._enableStatisticsReporter()}},{key:"_loadSegment",value:function(S,_){this._currentSegmentIndex=S;var h=this._mediaDataSource.segments[S],v=this._ioctl=new u.default(h,this._config,S);v.onError=this._onIOException.bind(this),v.onSeeked=this._onIOSeeked.bind(this),v.onComplete=this._onIOComplete.bind(this),v.onRedirect=this._onIORedirect.bind(this),v.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),_?this._demuxer.bindDataSource(this._ioctl):v.onDataArrival=this._onInitChunkArrival.bind(this),v.open(_)}},{key:"stop",value:function(){this._internalAbort(),this._disableStatisticsReporter()}},{key:"_internalAbort",value:function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}},{key:"pause",value:function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}},{key:"resume",value:function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}},{key:"seek",value:function(S){if(this._mediaInfo!=null&&this._mediaInfo.isSeekable()){var _=this._searchSegmentIndexContains(S);if(_===this._currentSegmentIndex){var h=this._mediaInfo.segments[_];if(h==null)this._pendingSeekTime=S;else{var v=h.getNearestKeyframe(S);this._remuxer.seek(v.milliseconds),this._ioctl.seek(v.fileposition),this._pendingResolveSeekPoint=v.milliseconds}}else{var A=this._mediaInfo.segments[_];if(A==null)this._pendingSeekTime=S,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(_);else{var w=A.getNearestKeyframe(S);this._internalAbort(),this._remuxer.seek(S),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[_].timestampBase,this._loadSegment(_,w.fileposition),this._pendingResolveSeekPoint=w.milliseconds,this._reportSegmentMediaInfo(_)}}this._enableStatisticsReporter()}}},{key:"_searchSegmentIndexContains",value:function(S){for(var _=this._mediaDataSource.segments,h=_.length-1,v=0;v<_.length;v++)if(S<_[v].timestampBase){h=v-1;break}return h}},{key:"_onInitChunkArrival",value:function(S,_){var h=this,v=null,A=0;if(_>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,A=this._demuxer.parseChunks(S,_);else if((v=c.default.probe(S)).match){this._demuxer=new c.default(v,this._config),this._remuxer||(this._remuxer=new f.default(this._config));var w=this._mediaDataSource;w.duration==null||isNaN(w.duration)||(this._demuxer.overridedDuration=w.duration),typeof w.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=w.hasAudio),typeof w.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=w.hasVideo),this._demuxer.timestampBase=w.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),A=this._demuxer.parseChunks(S,_)}else v=null,t.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){h._internalAbort()}),this._emitter.emit(g.default.DEMUX_ERROR,m.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),A=0;return A}},{key:"_onMediaInfo",value:function(S){var _=this;this._mediaInfo==null&&(this._mediaInfo=Object.assign({},S),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,y.default.prototype));var h=Object.assign({},S);Object.setPrototypeOf(h,y.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=h,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(function(){var v=_._pendingSeekTime;_._pendingSeekTime=null,_.seek(v)})}},{key:"_onMetaDataArrived",value:function(S){this._emitter.emit(g.default.METADATA_ARRIVED,S)}},{key:"_onScriptDataArrived",value:function(S){this._emitter.emit(g.default.SCRIPTDATA_ARRIVED,S)}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(S){var _=S,h=_+1;h<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(h)):(this._remuxer.flushStashedSamples(),this._emitter.emit(g.default.LOADING_COMPLETE),this._disableStatisticsReporter())}},{key:"_onIORedirect",value:function(S){var _=this._ioctl.extraData;this._mediaDataSource.segments[_].redirectedURL=S}},{key:"_onIORecoveredEarlyEof",value:function(){this._emitter.emit(g.default.RECOVERED_EARLY_EOF)}},{key:"_onIOException",value:function(S,_){t.default.e(this.TAG,"IOException: type = "+S+", code = "+_.code+", msg = "+_.msg),this._emitter.emit(g.default.IO_ERROR,S,_),this._disableStatisticsReporter()}},{key:"_onDemuxException",value:function(S,_){t.default.e(this.TAG,"DemuxException: type = "+S+", info = "+_),this._emitter.emit(g.default.DEMUX_ERROR,S,_)}},{key:"_onRemuxerInitSegmentArrival",value:function(S,_){this._emitter.emit(g.default.INIT_SEGMENT,S,_)}},{key:"_onRemuxerMediaSegmentArrival",value:function(S,_){if(this._pendingSeekTime==null&&(this._emitter.emit(g.default.MEDIA_SEGMENT,S,_),this._pendingResolveSeekPoint!=null&&S==="video")){var h=_.info.syncPoints,v=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,s.default.safari&&h.length>0&&h[0].originalDts===v&&(v=h[0].pts),this._emitter.emit(g.default.RECOMMEND_SEEKPOINT,v)}}},{key:"_enableStatisticsReporter",value:function(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}},{key:"_disableStatisticsReporter",value:function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"_reportSegmentMediaInfo",value:function(S){var _=this._mediaInfo.segments[S],h=Object.assign({},_);h.duration=this._mediaInfo.duration,h.segmentCount=this._mediaInfo.segmentCount,delete h.segments,delete h.keyframesIndex,this._emitter.emit(g.default.MEDIA_INFO,h)}},{key:"_reportStatisticsInfo",value:function(){var S={};S.url=this._ioctl.currentURL,S.hasRedirect=this._ioctl.hasRedirect,S.hasRedirect&&(S.redirectedURL=this._ioctl.currentRedirectedURL),S.speed=this._ioctl.currentSpeed,S.loaderType=this._ioctl.loaderType,S.currentSegmentIndex=this._currentSegmentIndex,S.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(g.default.STATISTICS_INFO,S)}}]),L}());T.default=b},{"../demux/demux-errors.js":16,"../demux/flv-demuxer.js":18,"../io/io-controller.js":23,"../io/loader.js":24,"../remux/mp4-remuxer.js":38,"../utils/browser.js":39,"../utils/logger.js":41,"./media-info.js":7,"./transmuxing-events.js":13,events:2}],13:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};T.default=k},{}],14:[function(R,P,T){"use strict";function k(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(T,"__esModule",{value:!0});var C=R("../utils/logger.js"),I=(k(C),R("../utils/logging-control.js")),a=k(I),n=R("../utils/polyfill.js"),e=k(n),t=R("./transmuxing-controller.js"),r=k(t),s=R("./transmuxing-events.js"),d=k(s),y=function(l){function c(v,A){var w={msg:d.default.INIT_SEGMENT,data:{type:v,data:A}};l.postMessage(w,[A.data])}function p(v,A){var w={msg:d.default.MEDIA_SEGMENT,data:{type:v,data:A}};l.postMessage(w,[A.data])}function f(){var v={msg:d.default.LOADING_COMPLETE};l.postMessage(v)}function i(){var v={msg:d.default.RECOVERED_EARLY_EOF};l.postMessage(v)}function m(v){var A={msg:d.default.MEDIA_INFO,data:v};l.postMessage(A)}function o(v){var A={msg:d.default.METADATA_ARRIVED,data:v};l.postMessage(A)}function u(v){var A={msg:d.default.SCRIPTDATA_ARRIVED,data:v};l.postMessage(A)}function E(v){var A={msg:d.default.STATISTICS_INFO,data:v};l.postMessage(A)}function g(v,A){l.postMessage({msg:d.default.IO_ERROR,data:{type:v,info:A}})}function b(v,A){l.postMessage({msg:d.default.DEMUX_ERROR,data:{type:v,info:A}})}function L(v){l.postMessage({msg:d.default.RECOMMEND_SEEKPOINT,data:v})}function S(v,A){l.postMessage({msg:"logcat_callback",data:{type:v,logcat:A}})}var _=null,h=S.bind(this);e.default.install(),l.addEventListener("message",function(v){switch(v.data.cmd){case"init":_=new r.default(v.data.param[0],v.data.param[1]),_.on(d.default.IO_ERROR,g.bind(this)),_.on(d.default.DEMUX_ERROR,b.bind(this)),_.on(d.default.INIT_SEGMENT,c.bind(this)),_.on(d.default.MEDIA_SEGMENT,p.bind(this)),_.on(d.default.LOADING_COMPLETE,f.bind(this)),_.on(d.default.RECOVERED_EARLY_EOF,i.bind(this)),_.on(d.default.MEDIA_INFO,m.bind(this)),_.on(d.default.METADATA_ARRIVED,o.bind(this)),_.on(d.default.SCRIPTDATA_ARRIVED,u.bind(this)),_.on(d.default.STATISTICS_INFO,E.bind(this)),_.on(d.default.RECOMMEND_SEEKPOINT,L.bind(this));break;case"destroy":_&&(_.destroy(),_=null),l.postMessage({msg:"destroyed"});break;case"start":_.start();break;case"stop":_.stop();break;case"seek":_.seek(v.data.param);break;case"pause":_.pause();break;case"resume":_.resume();break;case"logging_config":var A=v.data.param;a.default.applyConfig(A),A.enableCallback===!0?a.default.addLogListener(h):a.default.removeLogListener(h)}})};T.default=y},{"../utils/logger.js":41,"../utils/logging-control.js":42,"../utils/polyfill.js":43,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(R,P,T){"use strict";function k(y){return y&&y.__esModule?y:{default:y}}function C(y,l){if(!(y instanceof l))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function y(l,c){for(var p=0;p<c.length;p++){var f=c[p];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(l,f.key,f)}}return function(l,c,p){return c&&y(l.prototype,c),p&&y(l,p),l}}(),a=R("../utils/logger.js"),n=k(a),e=R("../utils/utf8-conv.js"),t=k(e),r=R("../utils/exception.js"),s=function(){var y=new ArrayBuffer(2);return new DataView(y).setInt16(0,256,!0),new Int16Array(y)[0]===256}(),d=function(){function y(){C(this,y)}return I(y,null,[{key:"parseScriptData",value:function(l,c,p){var f={};try{var i=y.parseValue(l,c,p),m=y.parseValue(l,c+i.size,p-i.size);f[i.data]=m.data}catch(o){n.default.e("AMF",o.toString())}return f}},{key:"parseObject",value:function(l,c,p){if(p<3)throw new r.IllegalStateException("Data not enough when parse ScriptDataObject");var f=y.parseString(l,c,p),i=y.parseValue(l,c+f.size,p-f.size),m=i.objectEnd;return{data:{name:f.data,value:i.data},size:f.size+i.size,objectEnd:m}}},{key:"parseVariable",value:function(l,c,p){return y.parseObject(l,c,p)}},{key:"parseString",value:function(l,c,p){if(p<2)throw new r.IllegalStateException("Data not enough when parse String");var f=new DataView(l,c,p),i=f.getUint16(0,!s),m=void 0;return m=i>0?(0,t.default)(new Uint8Array(l,c+2,i)):"",{data:m,size:2+i}}},{key:"parseLongString",value:function(l,c,p){if(p<4)throw new r.IllegalStateException("Data not enough when parse LongString");var f=new DataView(l,c,p),i=f.getUint32(0,!s),m=void 0;return m=i>0?(0,t.default)(new Uint8Array(l,c+4,i)):"",{data:m,size:4+i}}},{key:"parseDate",value:function(l,c,p){if(p<10)throw new r.IllegalStateException("Data size invalid when parse Date");var f=new DataView(l,c,p),i=f.getFloat64(0,!s);return i+=60*f.getInt16(8,!s)*1e3,{data:new Date(i),size:10}}},{key:"parseValue",value:function(l,c,p){if(p<1)throw new r.IllegalStateException("Data not enough when parse Value");var f=new DataView(l,c,p),i=1,m=f.getUint8(0),o=void 0,u=!1;try{switch(m){case 0:o=f.getFloat64(1,!s),i+=8;break;case 1:o=!!f.getUint8(1),i+=1;break;case 2:var E=y.parseString(l,c+1,p-1);o=E.data,i+=E.size;break;case 3:o={};var g=0;for((16777215&f.getUint32(p-4,!s))==9&&(g=3);i<p-4;){var b=y.parseObject(l,c+i,p-i-g);if(b.objectEnd)break;o[b.data.name]=b.data.value,i+=b.size}i<=p-3&&(16777215&f.getUint32(i-1,!s))==9&&(i+=3);break;case 8:o={},i+=4;var L=0;for((16777215&f.getUint32(p-4,!s))==9&&(L=3);i<p-8;){var S=y.parseVariable(l,c+i,p-i-L);if(S.objectEnd)break;o[S.data.name]=S.data.value,i+=S.size}i<=p-3&&(16777215&f.getUint32(i-1,!s))==9&&(i+=3);break;case 9:o=void 0,i=1,u=!0;break;case 10:o=[];var _=f.getUint32(1,!s);i+=4;for(var h=0;h<_;h++){var v=y.parseValue(l,c+i,p-i);o.push(v.data),i+=v.size}break;case 11:var A=y.parseDate(l,c+1,p-1);o=A.data,i+=A.size;break;case 12:var w=y.parseString(l,c+1,p-1);o=w.data,i+=w.size;break;default:i=p,n.default.w("AMF","Unsupported AMF value type "+m)}}catch(M){n.default.e("AMF",M.toString())}return{data:o,size:i,objectEnd:u}}}]),y}();T.default=d},{"../utils/exception.js":40,"../utils/logger.js":41,"../utils/utf8-conv.js":44}],16:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};T.default=k},{}],17:[function(R,P,T){"use strict";function k(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function n(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),I=R("../utils/exception.js"),a=function(){function n(e){k(this,n),this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}return C(n,[{key:"destroy",value:function(){this._buffer=null}},{key:"_fillCurrentWord",value:function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new I.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}},{key:"readBits",value:function(e){if(e>32)throw new I.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var r=this._current_word_bits_left?this._current_word:0;r>>>=32-this._current_word_bits_left;var s=e-this._current_word_bits_left;this._fillCurrentWord();var d=Math.min(s,this._current_word_bits_left),y=this._current_word>>>32-d;return this._current_word<<=d,this._current_word_bits_left-=d,r=r<<d|y}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readByte",value:function(){return this.readBits(8)}},{key:"_skipLeadingZero",value:function(){var e=void 0;for(e=0;e<this._current_word_bits_left;e++)if((this._current_word&2147483648>>>e)!=0)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}]),n}();T.default=a},{"../utils/exception.js":40}],18:[function(R,P,T){"use strict";function k(o){return o&&o.__esModule?o:{default:o}}function C(o,u){if(!(o instanceof u))throw new TypeError("Cannot call a class as a function")}function I(o,u){return o[u]<<24|o[u+1]<<16|o[u+2]<<8|o[u+3]}Object.defineProperty(T,"__esModule",{value:!0});var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},n=function(){function o(u,E){for(var g=0;g<E.length;g++){var b=E[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(u,b.key,b)}}return function(u,E,g){return E&&o(u.prototype,E),g&&o(u,g),u}}(),e=R("../utils/logger.js"),t=k(e),r=R("./amf-parser.js"),s=k(r),d=R("./sps-parser.js"),y=k(d),l=R("./demux-errors.js"),c=k(l),p=R("../core/media-info.js"),f=k(p),i=R("../utils/exception.js"),m=function(){function o(u,E){C(this,o),this.TAG="FLVDemuxer",this._config=E,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=u.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=u.hasAudioTrack,this._hasVideo=u.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new f.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var g=new ArrayBuffer(2);return new DataView(g).setInt16(0,256,!0),new Int16Array(g)[0]===256}()}return n(o,[{key:"destroy",value:function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}},{key:"bindDataSource",value:function(u){return u.onDataArrival=this.parseChunks.bind(this),this}},{key:"resetMediaInfo",value:function(){this._mediaInfo=new f.default}},{key:"_isInitialMetadataDispatched",value:function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}},{key:"parseChunks",value:function(u,E){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new i.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var g=0,b=this._littleEndian;if(E===0){if(!(u.byteLength>13))return 0;g=o.probe(u).dataOffset}for(this._firstParse&&(this._firstParse=!1,E+g!==this._dataOffset&&t.default.w(this.TAG,"First time parsing but chunk byteStart invalid!"),new DataView(u,g).getUint32(0,!b)!==0&&t.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),g+=4);g<u.byteLength;){this._dispatch=!0;var L=new DataView(u,g);if(g+11+4>u.byteLength)break;var S=L.getUint8(0),_=16777215&L.getUint32(0,!b);if(g+11+_+4>u.byteLength)break;if(S===8||S===9||S===18){var h=L.getUint8(4),v=L.getUint8(5),A=L.getUint8(6),w=L.getUint8(7),M=A|v<<8|h<<16|w<<24;(16777215&L.getUint32(7,!b))!=0&&t.default.w(this.TAG,"Meet tag which has StreamID != 0!");var B=g+11;switch(S){case 8:this._parseAudioData(u,B,_,M);break;case 9:this._parseVideoData(u,B,_,M,E+g);break;case 18:this._parseScriptData(u,B,_)}var G=L.getUint32(11+_,!b);G!==11+_&&t.default.w(this.TAG,"Invalid PrevTagSize "+G),g+=11+_+4}else t.default.w(this.TAG,"Unsupported tag type "+S+", skipped"),g+=11+_+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),g}},{key:"_parseScriptData",value:function(u,E,g){var b=s.default.parseScriptData(u,E,g);if(b.hasOwnProperty("onMetaData")){if(b.onMetaData==null||a(b.onMetaData)!=="object")return void t.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&t.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=b;var L=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},L)),typeof L.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=L.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof L.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=L.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof L.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=L.audiodatarate),typeof L.videodatarate=="number"&&(this._mediaInfo.videoDataRate=L.videodatarate),typeof L.width=="number"&&(this._mediaInfo.width=L.width),typeof L.height=="number"&&(this._mediaInfo.height=L.height),typeof L.duration=="number"){if(!this._durationOverrided){var S=Math.floor(L.duration*this._timescale);this._duration=S,this._mediaInfo.duration=S}}else this._mediaInfo.duration=0;if(typeof L.framerate=="number"){var _=Math.floor(1e3*L.framerate);if(_>0){var h=_/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=h,this._referenceFrameRate.fps_num=_,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=h}}if(a(L.keyframes)==="object"){this._mediaInfo.hasKeyframesIndex=!0;var v=L.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(v),L.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=L,t.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(b).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},b))}},{key:"_parseKeyframesIndex",value:function(u){for(var E=[],g=[],b=1;b<u.times.length;b++){var L=this._timestampBase+Math.floor(1e3*u.times[b]);E.push(L),g.push(u.filepositions[b])}return{times:E,filepositions:g}}},{key:"_parseAudioData",value:function(u,E,g,b){if(g<=1)return void t.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(this._hasAudioFlagOverrided!==!0||this._hasAudio!==!1){var L=(this._littleEndian,new DataView(u,E,g)),S=L.getUint8(0),_=S>>>4;if(_!==2&&_!==10)return void this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+_);var h=0,v=(12&S)>>>2;if(!(v>=0&&v<=4))return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+v);h=this._flvSoundRateTable[v];var A=1&S,w=this._audioMetadata,M=this._audioTrack;if(w||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),w=this._audioMetadata={},w.type="audio",w.id=M.id,w.timescale=this._timescale,w.duration=this._duration,w.audioSampleRate=h,w.channelCount=A===0?1:2),_===10){var B=this._parseAACAudioData(u,E+1,g-1);if(B==null)return;if(B.packetType===0){w.config&&t.default.w(this.TAG,"Found another AudioSpecificConfig!");var G=B.data;w.audioSampleRate=G.samplingRate,w.channelCount=G.channelCount,w.codec=G.codec,w.originalCodec=G.originalCodec,w.config=G.config,w.refSampleDuration=1024/w.audioSampleRate*w.timescale,t.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",w);var U=this._mediaInfo;U.audioCodec=w.originalCodec,U.audioSampleRate=w.audioSampleRate,U.audioChannelCount=w.channelCount,U.hasVideo?U.videoCodec!=null&&(U.mimeType='video/x-flv; codecs="'+U.videoCodec+","+U.audioCodec+'"'):U.mimeType='video/x-flv; codecs="'+U.audioCodec+'"',U.isComplete()&&this._onMediaInfo(U)}else if(B.packetType===1){var K=this._timestampBase+b,z={unit:B.data,length:B.data.byteLength,dts:K,pts:K};M.samples.push(z),M.length+=B.data.length}else t.default.e(this.TAG,"Flv: Unsupported AAC data type "+B.packetType)}else if(_===2){if(!w.codec){var W=this._parseMP3AudioData(u,E+1,g-1,!0);if(W==null)return;w.audioSampleRate=W.samplingRate,w.channelCount=W.channelCount,w.codec=W.codec,w.originalCodec=W.originalCodec,w.refSampleDuration=1152/w.audioSampleRate*w.timescale,t.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",w);var F=this._mediaInfo;F.audioCodec=w.codec,F.audioSampleRate=w.audioSampleRate,F.audioChannelCount=w.channelCount,F.audioDataRate=W.bitRate,F.hasVideo?F.videoCodec!=null&&(F.mimeType='video/x-flv; codecs="'+F.videoCodec+","+F.audioCodec+'"'):F.mimeType='video/x-flv; codecs="'+F.audioCodec+'"',F.isComplete()&&this._onMediaInfo(F)}var X=this._parseMP3AudioData(u,E+1,g-1,!1);if(X==null)return;var Y=this._timestampBase+b,V={unit:X,length:X.byteLength,dts:Y,pts:Y};M.samples.push(V),M.length+=X.length}}}},{key:"_parseAACAudioData",value:function(u,E,g){if(g<=1)return void t.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");var b={},L=new Uint8Array(u,E,g);return b.packetType=L[0],L[0]===0?b.data=this._parseAACAudioSpecificConfig(u,E+1,g-1):b.data=L.subarray(1),b}},{key:"_parseAACAudioSpecificConfig",value:function(u,E,g){var b=new Uint8Array(u,E,g),L=null,S=0,_=0,h=0,v=null;if(S=_=b[0]>>>3,(h=(7&b[0])<<1|b[1]>>>7)<0||h>=this._mpegSamplingRates.length)return void this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");var A=this._mpegSamplingRates[h],w=(120&b[1])>>>3;if(w<0||w>=8)return void this._onError(c.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");S===5&&(v=(7&b[1])<<1|b[2]>>>7,b[2]);var M=self.navigator.userAgent.toLowerCase();return M.indexOf("firefox")!==-1?h>=6?(S=5,L=new Array(4),v=h-3):(S=2,L=new Array(2),v=h):M.indexOf("android")!==-1?(S=2,L=new Array(2),v=h):(S=5,v=h,L=new Array(4),h>=6?v=h-3:w===1&&(S=2,L=new Array(2),v=h)),L[0]=S<<3,L[0]|=(15&h)>>>1,L[1]=(15&h)<<7,L[1]|=(15&w)<<3,S===5&&(L[1]|=(15&v)>>>1,L[2]=(1&v)<<7,L[2]|=8,L[3]=0),{config:L,samplingRate:A,channelCount:w,codec:"mp4a.40."+S,originalCodec:"mp4a.40."+_}}},{key:"_parseMP3AudioData",value:function(u,E,g,b){if(g<4)return void t.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");var L=(this._littleEndian,new Uint8Array(u,E,g)),S=null;if(b){if(L[0]!==255)return;var _=L[1]>>>3&3,h=(6&L[1])>>1,v=(240&L[2])>>>4,A=(12&L[2])>>>2,w=L[3]>>>6&3,M=w!==3?2:1,B=0,G=0;switch(_){case 0:B=this._mpegAudioV25SampleRateTable[A];break;case 2:B=this._mpegAudioV20SampleRateTable[A];break;case 3:B=this._mpegAudioV10SampleRateTable[A]}switch(h){case 1:v<this._mpegAudioL3BitRateTable.length&&(G=this._mpegAudioL3BitRateTable[v]);break;case 2:v<this._mpegAudioL2BitRateTable.length&&(G=this._mpegAudioL2BitRateTable[v]);break;case 3:v<this._mpegAudioL1BitRateTable.length&&(G=this._mpegAudioL1BitRateTable[v])}S={bitRate:G,samplingRate:B,channelCount:M,codec:"mp3",originalCodec:"mp3"}}else S=L;return S}},{key:"_parseVideoData",value:function(u,E,g,b,L){if(g<=1)return void t.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(this._hasVideoFlagOverrided!==!0||this._hasVideo!==!1){var S=new Uint8Array(u,E,g)[0],_=(240&S)>>>4,h=15&S;if(h!==7)return void this._onError(c.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+h);this._parseAVCVideoPacket(u,E+1,g-1,b,L,_)}}},{key:"_parseAVCVideoPacket",value:function(u,E,g,b,L,S){if(g<4)return void t.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");var _=this._littleEndian,h=new DataView(u,E,g),v=h.getUint8(0),A=16777215&h.getUint32(0,!_),w=A<<8>>8;if(v===0)this._parseAVCDecoderConfigurationRecord(u,E+4,g-4);else if(v===1)this._parseAVCVideoData(u,E+4,g-4,b,L,S,w);else if(v!==2)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid video packet type "+v)}},{key:"_parseAVCDecoderConfigurationRecord",value:function(u,E,g){if(g<7)return void t.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");var b=this._videoMetadata,L=this._videoTrack,S=this._littleEndian,_=new DataView(u,E,g);b?b.avcc!==void 0&&t.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),b=this._videoMetadata={},b.type="video",b.id=L.id,b.timescale=this._timescale,b.duration=this._duration);var h=_.getUint8(0),v=_.getUint8(1);if(_.getUint8(2),_.getUint8(3),h!==1||v===0)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&_.getUint8(4)),this._naluLengthSize!==3&&this._naluLengthSize!==4)return void this._onError(c.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));var A=31&_.getUint8(5);if(A===0)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");A>1&&t.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+A);for(var w=6,M=0;M<A;M++){var B=_.getUint16(w,!S);if(w+=2,B!==0){var G=new Uint8Array(u,E+w,B);w+=B;var U=y.default.parseSPS(G);if(M===0){b.codecWidth=U.codec_size.width,b.codecHeight=U.codec_size.height,b.presentWidth=U.present_size.width,b.presentHeight=U.present_size.height,b.profile=U.profile_string,b.level=U.level_string,b.bitDepth=U.bit_depth,b.chromaFormat=U.chroma_format,b.sarRatio=U.sar_ratio,b.frameRate=U.frame_rate,U.frame_rate.fixed!==!1&&U.frame_rate.fps_num!==0&&U.frame_rate.fps_den!==0||(b.frameRate=this._referenceFrameRate);var K=b.frameRate.fps_den,z=b.frameRate.fps_num;b.refSampleDuration=b.timescale*(K/z);for(var W=G.subarray(1,4),F="avc1.",X=0;X<3;X++){var Y=W[X].toString(16);Y.length<2&&(Y="0"+Y),F+=Y}b.codec=F;var V=this._mediaInfo;V.width=b.codecWidth,V.height=b.codecHeight,V.fps=b.frameRate.fps,V.profile=b.profile,V.level=b.level,V.refFrames=U.ref_frames,V.chromaFormat=U.chroma_format_string,V.sarNum=b.sarRatio.width,V.sarDen=b.sarRatio.height,V.videoCodec=F,V.hasAudio?V.audioCodec!=null&&(V.mimeType='video/x-flv; codecs="'+V.videoCodec+","+V.audioCodec+'"'):V.mimeType='video/x-flv; codecs="'+V.videoCodec+'"',V.isComplete()&&this._onMediaInfo(V)}}}var H=_.getUint8(w);if(H===0)return void this._onError(c.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");H>1&&t.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+H),w++;for(var Q=0;Q<H;Q++){var Z=_.getUint16(w,!S);w+=2,Z!==0&&(w+=Z)}b.avcc=new Uint8Array(g),b.avcc.set(new Uint8Array(u,E,g),0),t.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",b)}},{key:"_parseAVCVideoData",value:function(u,E,g,b,L,S,_){for(var h=this._littleEndian,v=new DataView(u,E,g),A=[],w=0,M=0,B=this._naluLengthSize,G=this._timestampBase+b,U=S===1;M<g;){if(M+4>=g){t.default.w(this.TAG,"Malformed Nalu near timestamp "+G+", offset = "+M+", dataSize = "+g);break}var K=v.getUint32(M,!h);if(B===3&&(K>>>=8),K>g-B)return void t.default.w(this.TAG,"Malformed Nalus near timestamp "+G+", NaluSize > DataSize!");var z=31&v.getUint8(M+B);z===5&&(U=!0);var W=new Uint8Array(u,E+M,B+K),F={type:z,data:W};A.push(F),w+=W.byteLength,M+=B+K}if(A.length){var X=this._videoTrack,Y={units:A,length:w,isKeyframe:U,dts:G,cts:_,pts:G+_};U&&(Y.fileposition=L),X.samples.push(Y),X.length+=w}}},{key:"onTrackMetadata",get:function(){return this._onTrackMetadata},set:function(u){this._onTrackMetadata=u}},{key:"onMediaInfo",get:function(){return this._onMediaInfo},set:function(u){this._onMediaInfo=u}},{key:"onMetaDataArrived",get:function(){return this._onMetaDataArrived},set:function(u){this._onMetaDataArrived=u}},{key:"onScriptDataArrived",get:function(){return this._onScriptDataArrived},set:function(u){this._onScriptDataArrived=u}},{key:"onError",get:function(){return this._onError},set:function(u){this._onError=u}},{key:"onDataAvailable",get:function(){return this._onDataAvailable},set:function(u){this._onDataAvailable=u}},{key:"timestampBase",get:function(){return this._timestampBase},set:function(u){this._timestampBase=u}},{key:"overridedDuration",get:function(){return this._duration},set:function(u){this._durationOverrided=!0,this._duration=u,this._mediaInfo.duration=u}},{key:"overridedHasAudio",set:function(u){this._hasAudioFlagOverrided=!0,this._hasAudio=u,this._mediaInfo.hasAudio=u}},{key:"overridedHasVideo",set:function(u){this._hasVideoFlagOverrided=!0,this._hasVideo=u,this._mediaInfo.hasVideo=u}}],[{key:"probe",value:function(u){var E=new Uint8Array(u),g={match:!1};if(E[0]!==70||E[1]!==76||E[2]!==86||E[3]!==1)return g;var b=(4&E[4])>>>2!=0,L=(1&E[4])!=0,S=I(E,5);return S<9?g:{match:!0,consumed:S,dataOffset:S,hasAudioTrack:b,hasVideoTrack:L}}}]),o}();T.default=m},{"../core/media-info.js":7,"../utils/exception.js":40,"../utils/logger.js":41,"./amf-parser.js":15,"./demux-errors.js":16,"./sps-parser.js":19}],19:[function(R,P,T){"use strict";function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function e(t,r){for(var s=0;s<r.length;s++){var d=r[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(t,d.key,d)}}return function(t,r,s){return r&&e(t.prototype,r),s&&e(t,s),t}}(),I=R("./exp-golomb.js"),a=function(e){return e&&e.__esModule?e:{default:e}}(I),n=function(){function e(){k(this,e)}return C(e,null,[{key:"_ebsp2rbsp",value:function(t){for(var r=t,s=r.byteLength,d=new Uint8Array(s),y=0,l=0;l<s;l++)l>=2&&r[l]===3&&r[l-1]===0&&r[l-2]===0||(d[y]=r[l],y++);return new Uint8Array(d.buffer,0,y)}},{key:"parseSPS",value:function(t){var r=e._ebsp2rbsp(t),s=new a.default(r);s.readByte();var d=s.readByte();s.readByte();var y=s.readByte();s.readUEG();var l=e.getProfileString(d),c=e.getLevelString(y),p=1,f=420,i=[0,420,422,444],m=8;if((d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128||d===138||d===144)&&(p=s.readUEG(),p===3&&s.readBits(1),p<=3&&(f=i[p]),m=s.readUEG()+8,s.readUEG(),s.readBits(1),s.readBool()))for(var o=p!==3?8:12,u=0;u<o;u++)s.readBool()&&(u<6?e._skipScalingList(s,16):e._skipScalingList(s,64));s.readUEG();var E=s.readUEG();if(E===0)s.readUEG();else if(E===1){s.readBits(1),s.readSEG(),s.readSEG();for(var g=s.readUEG(),b=0;b<g;b++)s.readSEG()}var L=s.readUEG();s.readBits(1);var S=s.readUEG(),_=s.readUEG(),h=s.readBits(1);h===0&&s.readBits(1),s.readBits(1);var v=0,A=0,w=0,M=0;s.readBool()&&(v=s.readUEG(),A=s.readUEG(),w=s.readUEG(),M=s.readUEG());var B=1,G=1,U=0,K=!0,z=0,W=0;if(s.readBool()){if(s.readBool()){var F=s.readByte(),X=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Y=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];F>0&&F<16?(B=X[F-1],G=Y[F-1]):F===255&&(B=s.readByte()<<8|s.readByte(),G=s.readByte()<<8|s.readByte())}if(s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()){var V=s.readBits(32),H=s.readBits(32);K=s.readBool(),z=H,W=2*V,U=z/W}}var Q=1;B===1&&G===1||(Q=B/G);var Z=0,ue=0;if(p===0)Z=1,ue=2-h;else{var re=p===3?1:2,ee=p===1?2:1;Z=re,ue=ee*(2-h)}var te=16*(S+1),de=16*(_+1)*(2-h);te-=(v+A)*Z,de-=(w+M)*ue;var ne=Math.ceil(te*Q);return s.destroy(),s=null,{profile_string:l,level_string:c,bit_depth:m,ref_frames:L,chroma_format:f,chroma_format_string:e.getChromaFormatString(f),frame_rate:{fixed:K,fps:U,fps_den:W,fps_num:z},sar_ratio:{width:B,height:G},codec_size:{width:te,height:de},present_size:{width:ne,height:de}}}},{key:"_skipScalingList",value:function(t,r){for(var s=8,d=8,y=0,l=0;l<r;l++)d!==0&&(y=t.readSEG(),d=(s+y+256)%256),s=d===0?s:d}},{key:"getProfileString",value:function(t){switch(t){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}},{key:"getLevelString",value:function(t){return(t/10).toFixed(1)}},{key:"getChromaFormatString",value:function(t){switch(t){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}]),e}();T.default=n},{"./exp-golomb.js":17}],20:[function(R,P,T){"use strict";function k(b){return b&&b.__esModule?b:{default:b}}function C(b,L){var S=b;if(S==null||(S===void 0?"undefined":n(S))!=="object")throw new E.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!S.hasOwnProperty("type"))throw new E.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(S.type){case"flv":return new l.default(S,L);default:return new p.default(S,L)}}function I(){return s.default.supportMSEH264Playback()}function a(){return s.default.getFeatureList()}Object.defineProperty(T,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},e=R("./utils/polyfill.js"),t=k(e),r=R("./core/features.js"),s=k(r),d=R("./io/loader.js"),y=R("flv-player.js"),l=k(y),c=R("./player/native-player.js"),p=k(c),f=R("./player/player-events.js"),i=k(f),m=R("./player/player-errors.js"),o=R("./utils/logging-control.js"),u=k(o),E=R("./utils/exception.js");t.default.install();var g={};g.createPlayer=C,g.isSupported=I,g.getFeatureList=a,g.BaseLoader=d.BaseLoader,g.LoaderStatus=d.LoaderStatus,g.LoaderErrors=d.LoaderErrors,g.Events=i.default,g.ErrorTypes=m.ErrorTypes,g.ErrorDetails=m.ErrorDetails,g.FlvPlayer=l.default,g.NativePlayer=p.default,g.LoggingControl=u.default,Object.defineProperty(g,"version",{enumerable:!0,get:function(){return"1.5.0"}}),T.default=g},{"./core/features.js":6,"./io/loader.js":24,"flv-player.js":32,"./player/native-player.js":33,"./player/player-errors.js":34,"./player/player-events.js":35,"./utils/exception.js":40,"./utils/logging-control.js":42,"./utils/polyfill.js":43}],21:[function(R,P,T){"use strict";P.exports=R("./flv.js").default},{"./flv.js":20}],22:[function(R,P,T){"use strict";function k(p){return p&&p.__esModule?p:{default:p}}function C(p,f){if(!(p instanceof f))throw new TypeError("Cannot call a class as a function")}function I(p,f){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||typeof f!="object"&&typeof f!="function"?p:f}function a(p,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);p.prototype=Object.create(f&&f.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(p,f):p.__proto__=f)}Object.defineProperty(T,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},e=function p(f,i,m){f===null&&(f=Function.prototype);var o=Object.getOwnPropertyDescriptor(f,i);if(o===void 0){var u=Object.getPrototypeOf(f);return u===null?void 0:p(u,i,m)}if("value"in o)return o.value;var E=o.get;if(E!==void 0)return E.call(m)},t=function(){function p(f,i){for(var m=0;m<i.length;m++){var o=i[m];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(f,o.key,o)}}return function(f,i,m){return i&&p(f.prototype,i),m&&p(f,m),f}}(),r=R("../utils/logger.js"),s=(k(r),R("../utils/browser.js")),d=k(s),y=R("./loader.js"),l=R("../utils/exception.js"),c=function(p){function f(i,m){C(this,f);var o=I(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,"fetch-stream-loader"));return o.TAG="FetchStreamLoader",o._seekHandler=i,o._config=m,o._needStash=!0,o._requestAbort=!1,o._contentLength=null,o._receivedLength=0,o}return a(f,p),t(f,null,[{key:"isSupported",value:function(){try{var i=d.default.msedge&&d.default.version.minor>=15048,m=!d.default.msedge||i;return self.fetch&&self.ReadableStream&&m}catch(o){return!1}}}]),t(f,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),e(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"destroy",this).call(this)}},{key:"open",value:function(i,m){var o=this;this._dataSource=i,this._range=m;var u=i.url;this._config.reuseRedirectedURL&&i.redirectedURL!=null&&(u=i.redirectedURL);var E=this._seekHandler.getConfig(u,m),g=new self.Headers;if(n(E.headers)==="object"){var b=E.headers;for(var L in b)b.hasOwnProperty(L)&&g.append(L,b[L])}var S={method:"GET",headers:g,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(n(this._config.headers)==="object")for(var _ in this._config.headers)g.append(_,this._config.headers[_]);i.cors===!1&&(S.mode="same-origin"),i.withCredentials&&(S.credentials="include"),i.referrerPolicy&&(S.referrerPolicy=i.referrerPolicy),this._status=y.LoaderStatus.kConnecting,self.fetch(E.url,S).then(function(h){if(o._requestAbort)return o._requestAbort=!1,void(o._status=y.LoaderStatus.kIdle);if(h.ok&&h.status>=200&&h.status<=299){if(h.url!==E.url&&o._onURLRedirect){var v=o._seekHandler.removeURLParameters(h.url);o._onURLRedirect(v)}var A=h.headers.get("Content-Length");return A!=null&&(o._contentLength=parseInt(A),o._contentLength!==0&&o._onContentLengthKnown&&o._onContentLengthKnown(o._contentLength)),o._pump.call(o,h.body.getReader())}if(o._status=y.LoaderStatus.kError,!o._onError)throw new l.RuntimeException("FetchStreamLoader: Http code invalid, "+h.status+" "+h.statusText);o._onError(y.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:h.status,msg:h.statusText})}).catch(function(h){if(o._status=y.LoaderStatus.kError,!o._onError)throw h;o._onError(y.LoaderErrors.EXCEPTION,{code:-1,msg:h.message})})}},{key:"abort",value:function(){this._requestAbort=!0}},{key:"_pump",value:function(i){var m=this;return i.read().then(function(o){if(o.done)if(m._contentLength!==null&&m._receivedLength<m._contentLength){m._status=y.LoaderStatus.kError;var u=y.LoaderErrors.EARLY_EOF,E={code:-1,msg:"Fetch stream meet Early-EOF"};if(!m._onError)throw new l.RuntimeException(E.msg);m._onError(u,E)}else m._status=y.LoaderStatus.kComplete,m._onComplete&&m._onComplete(m._range.from,m._range.from+m._receivedLength-1);else{if(m._requestAbort===!0)return m._requestAbort=!1,m._status=y.LoaderStatus.kComplete,i.cancel();m._status=y.LoaderStatus.kBuffering;var g=o.value.buffer,b=m._range.from+m._receivedLength;m._receivedLength+=g.byteLength,m._onDataArrival&&m._onDataArrival(g,b,m._receivedLength),m._pump(i)}}).catch(function(o){if(o.code!==11||!d.default.msedge){m._status=y.LoaderStatus.kError;var u=0,E=null;if(o.code!==19&&o.message!=="network error"||!(m._contentLength===null||m._contentLength!==null&&m._receivedLength<m._contentLength)?(u=y.LoaderErrors.EXCEPTION,E={code:o.code,msg:o.message}):(u=y.LoaderErrors.EARLY_EOF,E={code:o.code,msg:"Fetch stream meet Early-EOF"}),!m._onError)throw new l.RuntimeException(E.msg);m._onError(u,E)}})}}]),f}(y.BaseLoader);T.default=c},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],23:[function(R,P,T){"use strict";function k(S){return S&&S.__esModule?S:{default:S}}function C(S,_){if(!(S instanceof _))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function S(_,h){for(var v=0;v<h.length;v++){var A=h[v];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}return function(_,h,v){return h&&S(_.prototype,h),v&&S(_,v),_}}(),a=R("../utils/logger.js"),n=k(a),e=R("./speed-sampler.js"),t=k(e),r=R("./loader.js"),s=R("./fetch-stream-loader.js"),d=k(s),y=R("./xhr-moz-chunked-loader.js"),l=k(y),c=R("./xhr-msstream-loader.js"),p=(k(c),R("./xhr-range-loader.js")),f=k(p),i=R("./websocket-loader.js"),m=k(i),o=R("./range-seek-handler.js"),u=k(o),E=R("./param-seek-handler.js"),g=k(E),b=R("../utils/exception.js"),L=function(){function S(_,h,v){C(this,S),this.TAG="IOController",this._config=h,this._extraData=v,this._stashInitialSize=393216,h.stashInitialSize!=null&&h.stashInitialSize>0&&(this._stashInitialSize=h.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,h.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=_,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(_.url),this._refTotalLength=_.filesize?_.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new t.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return I(S,[{key:"destroy",value:function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}},{key:"isWorking",value:function(){return this._loader&&this._loader.isWorking()&&!this._paused}},{key:"isPaused",value:function(){return this._paused}},{key:"_selectSeekHandler",value:function(){var _=this._config;if(_.seekType==="range")this._seekHandler=new u.default(this._config.rangeLoadZeroStart);else if(_.seekType==="param"){var h=_.seekParamStart||"bstart",v=_.seekParamEnd||"bend";this._seekHandler=new g.default(h,v)}else{if(_.seekType!=="custom")throw new b.InvalidArgumentException("Invalid seekType in config: "+_.seekType);if(typeof _.customSeekHandler!="function")throw new b.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new _.customSeekHandler}}},{key:"_selectLoader",value:function(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=m.default;else if(d.default.isSupported())this._loaderClass=d.default;else if(l.default.isSupported())this._loaderClass=l.default;else{if(!f.default.isSupported())throw new b.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=f.default}}},{key:"_createLoader",value:function(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}},{key:"open",value:function(_){this._currentRange={from:0,to:-1},_&&(this._currentRange.from=_),this._speedSampler.reset(),_||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}},{key:"abort",value:function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}},{key:"pause",value:function(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}},{key:"resume",value:function(){if(this._paused){this._paused=!1;var _=this._resumeFrom;this._resumeFrom=0,this._internalSeek(_,!0)}}},{key:"seek",value:function(_){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(_,!0)}},{key:"_internalSeek",value:function(_,h){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(h),this._loader.destroy(),this._loader=null;var v={from:_,to:-1};this._currentRange={from:v.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,v),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(_){if(!_||typeof _!="string"||_.length===0)throw new b.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=_}},{key:"_expandBuffer",value:function(_){for(var h=this._stashSize;h+1048576<_;)h*=2;if((h+=1048576)!==this._bufferSize){var v=new ArrayBuffer(h);if(this._stashUsed>0){var A=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(v,0,h).set(A,0)}this._stashBuffer=v,this._bufferSize=h}}},{key:"_normalizeSpeed",value:function(_){var h=this._speedNormalizeList,v=h.length-1,A=0,w=0,M=v;if(_<h[0])return h[0];for(;w<=M;){if((A=w+Math.floor((M-w)/2))===v||_>=h[A]&&_<h[A+1])return h[A];h[A]<_?w=A+1:M=A-1}}},{key:"_adjustStashSize",value:function(_){var h=0;(h=this._config.isLive||_<512?_:_>=512&&_<=1024?Math.floor(1.5*_):2*_)>8192&&(h=8192);var v=1024*h+1048576;this._bufferSize<v&&this._expandBuffer(v),this._stashSize=1024*h}},{key:"_dispatchChunks",value:function(_,h){return this._currentRange.to=h+_.byteLength-1,this._onDataArrival(_,h)}},{key:"_onURLRedirect",value:function(_){this._redirectedURL=_,this._onRedirect&&this._onRedirect(_)}},{key:"_onContentLengthKnown",value:function(_){_&&this._fullRequestFlag&&(this._totalLength=_,this._fullRequestFlag=!1)}},{key:"_onLoaderChunkArrival",value:function(_,h,v){if(!this._onDataArrival)throw new b.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(_.byteLength);var A=this._speedSampler.lastSecondKBps;if(A!==0){var w=this._normalizeSpeed(A);this._speedNormalized!==w&&(this._speedNormalized=w,this._adjustStashSize(w))}if(this._enableStash)if(this._stashUsed===0&&this._stashByteStart===0&&(this._stashByteStart=h),this._stashUsed+_.byteLength<=this._stashSize){var M=new Uint8Array(this._stashBuffer,0,this._stashSize);M.set(new Uint8Array(_),this._stashUsed),this._stashUsed+=_.byteLength}else{var B=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var G=this._stashBuffer.slice(0,this._stashUsed),U=this._dispatchChunks(G,this._stashByteStart);if(U<G.byteLength){if(U>0){var K=new Uint8Array(G,U);B.set(K,0),this._stashUsed=K.byteLength,this._stashByteStart+=U}}else this._stashUsed=0,this._stashByteStart+=U;this._stashUsed+_.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+_.byteLength),B=new Uint8Array(this._stashBuffer,0,this._bufferSize)),B.set(new Uint8Array(_),this._stashUsed),this._stashUsed+=_.byteLength}else{var z=this._dispatchChunks(_,h);if(z<_.byteLength){var W=_.byteLength-z;W>this._bufferSize&&(this._expandBuffer(W),B=new Uint8Array(this._stashBuffer,0,this._bufferSize)),B.set(new Uint8Array(_,z),0),this._stashUsed+=W,this._stashByteStart=h+z}}}else if(this._stashUsed===0){var F=this._dispatchChunks(_,h);if(F<_.byteLength){var X=_.byteLength-F;X>this._bufferSize&&this._expandBuffer(X);var Y=new Uint8Array(this._stashBuffer,0,this._bufferSize);Y.set(new Uint8Array(_,F),0),this._stashUsed+=X,this._stashByteStart=h+F}}else{this._stashUsed+_.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+_.byteLength);var V=new Uint8Array(this._stashBuffer,0,this._bufferSize);V.set(new Uint8Array(_),this._stashUsed),this._stashUsed+=_.byteLength;var H=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(H<this._stashUsed&&H>0){var Q=new Uint8Array(this._stashBuffer,H);V.set(Q,0)}this._stashUsed-=H,this._stashByteStart+=H}}}},{key:"_flushStashBuffer",value:function(_){if(this._stashUsed>0){var h=this._stashBuffer.slice(0,this._stashUsed),v=this._dispatchChunks(h,this._stashByteStart),A=h.byteLength-v;if(v<h.byteLength){if(!_){if(v>0){var w=new Uint8Array(this._stashBuffer,0,this._bufferSize),M=new Uint8Array(h,v);w.set(M,0),this._stashUsed=M.byteLength,this._stashByteStart+=v}return 0}n.default.w(this.TAG,A+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,A}return 0}},{key:"_onLoaderComplete",value:function(_,h){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}},{key:"_onLoaderError",value:function(_,h){switch(n.default.e(this.TAG,"Loader error, code = "+h.code+", msg = "+h.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,_=r.LoaderErrors.UNRECOVERABLE_EARLY_EOF),_){case r.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var v=this._currentRange.to+1;return void(v<this._totalLength&&(n.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(v,!1)))}_=r.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break;case r.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case r.LoaderErrors.CONNECTING_TIMEOUT:case r.LoaderErrors.HTTP_STATUS_CODE_INVALID:case r.LoaderErrors.EXCEPTION:}if(!this._onError)throw new b.RuntimeException("IOException: "+h.msg);this._onError(_,h)}},{key:"status",get:function(){return this._loader.status}},{key:"extraData",get:function(){return this._extraData},set:function(_){this._extraData=_}},{key:"onDataArrival",get:function(){return this._onDataArrival},set:function(_){this._onDataArrival=_}},{key:"onSeeked",get:function(){return this._onSeeked},set:function(_){this._onSeeked=_}},{key:"onError",get:function(){return this._onError},set:function(_){this._onError=_}},{key:"onComplete",get:function(){return this._onComplete},set:function(_){this._onComplete=_}},{key:"onRedirect",get:function(){return this._onRedirect},set:function(_){this._onRedirect=_}},{key:"onRecoveredEarlyEof",get:function(){return this._onRecoveredEarlyEof},set:function(_){this._onRecoveredEarlyEof=_}},{key:"currentURL",get:function(){return this._dataSource.url}},{key:"hasRedirect",get:function(){return this._redirectedURL!=null||this._dataSource.redirectedURL!=null}},{key:"currentRedirectedURL",get:function(){return this._redirectedURL||this._dataSource.redirectedURL}},{key:"currentSpeed",get:function(){return this._loaderClass===f.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}},{key:"loaderType",get:function(){return this._loader.type}}]),S}();T.default=L},{"../utils/exception.js":40,"../utils/logger.js":41,"./fetch-stream-loader.js":22,"./loader.js":24,"./param-seek-handler.js":25,"./range-seek-handler.js":26,"./speed-sampler.js":27,"./websocket-loader.js":28,"./xhr-moz-chunked-loader.js":29,"./xhr-msstream-loader.js":30,"./xhr-range-loader.js":31}],24:[function(R,P,T){"use strict";function k(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0}),T.BaseLoader=T.LoaderErrors=T.LoaderStatus=void 0;var C=function(){function n(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),I=R("../utils/exception.js"),a=T.LoaderStatus={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4};T.LoaderErrors={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},T.BaseLoader=function(){function n(e){k(this,n),this._type=e||"undefined",this._status=a.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return C(n,[{key:"destroy",value:function(){this._status=a.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}},{key:"isWorking",value:function(){return this._status===a.kConnecting||this._status===a.kBuffering}},{key:"open",value:function(e,t){throw new I.NotImplementedException("Unimplemented abstract function!")}},{key:"abort",value:function(){throw new I.NotImplementedException("Unimplemented abstract function!")}},{key:"type",get:function(){return this._type}},{key:"status",get:function(){return this._status}},{key:"needStashBuffer",get:function(){return this._needStash}},{key:"onContentLengthKnown",get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e}},{key:"onURLRedirect",get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e}},{key:"onDataArrival",get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e}},{key:"onError",get:function(){return this._onError},set:function(e){this._onError=e}},{key:"onComplete",get:function(){return this._onComplete},set:function(e){this._onComplete=e}}]),n}()},{"../utils/exception.js":40}],25:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(n,e){k(this,a),this._startName=n,this._endName=e}return C(a,[{key:"getConfig",value:function(n,e){var t=n;if(e.from!==0||e.to!==-1){var r=!0;t.indexOf("?")===-1&&(t+="?",r=!1),r&&(t+="&"),t+=this._startName+"="+e.from.toString(),e.to!==-1&&(t+="&"+this._endName+"="+e.to.toString())}return{url:t,headers:{}}}},{key:"removeURLParameters",value:function(n){var e=n.split("?")[0],t=void 0,r=n.indexOf("?");r!==-1&&(t=n.substring(r+1));var s="";if(t!=null&&t.length>0)for(var d=t.split("&"),y=0;y<d.length;y++){var l=d[y].split("="),c=y>0;l[0]!==this._startName&&l[0]!==this._endName&&(c&&(s+="&"),s+=d[y])}return s.length===0?e:e+"?"+s}}]),a}();T.default=I},{}],26:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(n){k(this,a),this._zeroStart=n||!1}return C(a,[{key:"getConfig",value:function(n,e){var t={};if(e.from!==0||e.to!==-1){var r=void 0;r=e.to!==-1?"bytes="+e.from.toString()+"-"+e.to.toString():"bytes="+e.from.toString()+"-",t.Range=r}else this._zeroStart&&(t.Range="bytes=0-");return{url:n,headers:t}}},{key:"removeURLParameters",value:function(n){return n}}]),a}();T.default=I},{}],27:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(){k(this,a),this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return C(a,[{key:"reset",value:function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}},{key:"addBytes",value:function(n){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=n,this._totalBytes+=n):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=n,this._totalBytes+=n):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=n,this._totalBytes+=n,this._lastCheckpoint=this._now())}},{key:"currentKBps",get:function(){this.addBytes(0);var n=(this._now()-this._lastCheckpoint)/1e3;return n==0&&(n=1),this._intervalBytes/n/1024}},{key:"lastSecondKBps",get:function(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var n=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/n/1024}}]),a}();T.default=I},{}],28:[function(R,P,T){"use strict";function k(d,y){if(!(d instanceof y))throw new TypeError("Cannot call a class as a function")}function C(d,y){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!y||typeof y!="object"&&typeof y!="function"?d:y}function I(d,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);d.prototype=Object.create(y&&y.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(d,y):d.__proto__=y)}Object.defineProperty(T,"__esModule",{value:!0});var a=function d(y,l,c){y===null&&(y=Function.prototype);var p=Object.getOwnPropertyDescriptor(y,l);if(p===void 0){var f=Object.getPrototypeOf(y);return f===null?void 0:d(f,l,c)}if("value"in p)return p.value;var i=p.get;if(i!==void 0)return i.call(c)},n=function(){function d(y,l){for(var c=0;c<l.length;c++){var p=l[c];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(y,p.key,p)}}return function(y,l,c){return l&&d(y.prototype,l),c&&d(y,c),y}}(),e=R("../utils/logger.js"),t=(function(d){d&&d.__esModule}(e),R("./loader.js")),r=R("../utils/exception.js"),s=function(d){function y(){k(this,y);var l=C(this,(y.__proto__||Object.getPrototypeOf(y)).call(this,"websocket-loader"));return l.TAG="WebSocketLoader",l._needStash=!0,l._ws=null,l._requestAbort=!1,l._receivedLength=0,l}return I(y,d),n(y,null,[{key:"isSupported",value:function(){try{return self.WebSocket!==void 0}catch(l){return!1}}}]),n(y,[{key:"destroy",value:function(){this._ws&&this.abort(),a(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"destroy",this).call(this)}},{key:"open",value:function(l){try{var c=this._ws=new self.WebSocket(l.url);c.binaryType="arraybuffer",c.onopen=this._onWebSocketOpen.bind(this),c.onclose=this._onWebSocketClose.bind(this),c.onmessage=this._onWebSocketMessage.bind(this),c.onerror=this._onWebSocketError.bind(this),this._status=t.LoaderStatus.kConnecting}catch(f){this._status=t.LoaderStatus.kError;var p={code:f.code,msg:f.message};if(!this._onError)throw new r.RuntimeException(p.msg);this._onError(t.LoaderErrors.EXCEPTION,p)}}},{key:"abort",value:function(){var l=this._ws;!l||l.readyState!==0&&l.readyState!==1||(this._requestAbort=!0,l.close()),this._ws=null,this._status=t.LoaderStatus.kComplete}},{key:"_onWebSocketOpen",value:function(l){this._status=t.LoaderStatus.kBuffering}},{key:"_onWebSocketClose",value:function(l){if(this._requestAbort===!0)return void(this._requestAbort=!1);this._status=t.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)}},{key:"_onWebSocketMessage",value:function(l){var c=this;if(l.data instanceof ArrayBuffer)this._dispatchArrayBuffer(l.data);else if(l.data instanceof Blob){var p=new FileReader;p.onload=function(){c._dispatchArrayBuffer(p.result)},p.readAsArrayBuffer(l.data)}else{this._status=t.LoaderStatus.kError;var f={code:-1,msg:"Unsupported WebSocket message type: "+l.data.constructor.name};if(!this._onError)throw new r.RuntimeException(f.msg);this._onError(t.LoaderErrors.EXCEPTION,f)}}},{key:"_dispatchArrayBuffer",value:function(l){var c=l,p=this._receivedLength;this._receivedLength+=c.byteLength,this._onDataArrival&&this._onDataArrival(c,p,this._receivedLength)}},{key:"_onWebSocketError",value:function(l){this._status=t.LoaderStatus.kError;var c={code:l.code,msg:l.message};if(!this._onError)throw new r.RuntimeException(c.msg);this._onError(t.LoaderErrors.EXCEPTION,c)}}]),y}(t.BaseLoader);T.default=s},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],29:[function(R,P,T){"use strict";function k(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}function C(l,c){if(!l)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||typeof c!="object"&&typeof c!="function"?l:c}function I(l,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof c);l.prototype=Object.create(c&&c.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),c&&(Object.setPrototypeOf?Object.setPrototypeOf(l,c):l.__proto__=c)}Object.defineProperty(T,"__esModule",{value:!0});var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},n=function l(c,p,f){c===null&&(c=Function.prototype);var i=Object.getOwnPropertyDescriptor(c,p);if(i===void 0){var m=Object.getPrototypeOf(c);return m===null?void 0:l(m,p,f)}if("value"in i)return i.value;var o=i.get;if(o!==void 0)return o.call(f)},e=function(){function l(c,p){for(var f=0;f<p.length;f++){var i=p[f];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(c,i.key,i)}}return function(c,p,f){return p&&l(c.prototype,p),f&&l(c,f),c}}(),t=R("../utils/logger.js"),r=function(l){return l&&l.__esModule?l:{default:l}}(t),s=R("./loader.js"),d=R("../utils/exception.js"),y=function(l){function c(p,f){k(this,c);var i=C(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,"xhr-moz-chunked-loader"));return i.TAG="MozChunkedLoader",i._seekHandler=p,i._config=f,i._needStash=!0,i._xhr=null,i._requestAbort=!1,i._contentLength=null,i._receivedLength=0,i}return I(c,l),e(c,null,[{key:"isSupported",value:function(){try{var p=new XMLHttpRequest;return p.open("GET","https://example.com",!0),p.responseType="moz-chunked-arraybuffer",p.responseType==="moz-chunked-arraybuffer"}catch(f){return r.default.w("MozChunkedLoader",f.message),!1}}}]),e(c,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),n(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"destroy",this).call(this)}},{key:"open",value:function(p,f){this._dataSource=p,this._range=f;var i=p.url;this._config.reuseRedirectedURL&&p.redirectedURL!=null&&(i=p.redirectedURL);var m=this._seekHandler.getConfig(i,f);this._requestURL=m.url;var o=this._xhr=new XMLHttpRequest;if(o.open("GET",m.url,!0),o.responseType="moz-chunked-arraybuffer",o.onreadystatechange=this._onReadyStateChange.bind(this),o.onprogress=this._onProgress.bind(this),o.onloadend=this._onLoadEnd.bind(this),o.onerror=this._onXhrError.bind(this),p.withCredentials&&(o.withCredentials=!0),a(m.headers)==="object"){var u=m.headers;for(var E in u)u.hasOwnProperty(E)&&o.setRequestHeader(E,u[E])}if(a(this._config.headers)==="object"){var g=this._config.headers;for(var b in g)g.hasOwnProperty(b)&&o.setRequestHeader(b,g[b])}this._status=s.LoaderStatus.kConnecting,o.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=s.LoaderStatus.kComplete}},{key:"_onReadyStateChange",value:function(p){var f=p.target;if(f.readyState===2){if(f.responseURL!=null&&f.responseURL!==this._requestURL&&this._onURLRedirect){var i=this._seekHandler.removeURLParameters(f.responseURL);this._onURLRedirect(i)}if(f.status!==0&&(f.status<200||f.status>299)){if(this._status=s.LoaderStatus.kError,!this._onError)throw new d.RuntimeException("MozChunkedLoader: Http code invalid, "+f.status+" "+f.statusText);this._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText})}else this._status=s.LoaderStatus.kBuffering}}},{key:"_onProgress",value:function(p){if(this._status!==s.LoaderStatus.kError){this._contentLength===null&&p.total!==null&&p.total!==0&&(this._contentLength=p.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var f=p.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,i,this._receivedLength)}}},{key:"_onLoadEnd",value:function(p){if(this._requestAbort===!0)return void(this._requestAbort=!1);this._status!==s.LoaderStatus.kError&&(this._status=s.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},{key:"_onXhrError",value:function(p){this._status=s.LoaderStatus.kError;var f=0,i=null;if(this._contentLength&&p.loaded<this._contentLength?(f=s.LoaderErrors.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(f=s.LoaderErrors.EXCEPTION,i={code:-1,msg:p.constructor.name+" "+p.type}),!this._onError)throw new d.RuntimeException(i.msg);this._onError(f,i)}}]),c}(s.BaseLoader);T.default=y},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],30:[function(R,P,T){"use strict";function k(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}function C(l,c){if(!l)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||typeof c!="object"&&typeof c!="function"?l:c}function I(l,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof c);l.prototype=Object.create(c&&c.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),c&&(Object.setPrototypeOf?Object.setPrototypeOf(l,c):l.__proto__=c)}Object.defineProperty(T,"__esModule",{value:!0});var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},n=function l(c,p,f){c===null&&(c=Function.prototype);var i=Object.getOwnPropertyDescriptor(c,p);if(i===void 0){var m=Object.getPrototypeOf(c);return m===null?void 0:l(m,p,f)}if("value"in i)return i.value;var o=i.get;if(o!==void 0)return o.call(f)},e=function(){function l(c,p){for(var f=0;f<p.length;f++){var i=p[f];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(c,i.key,i)}}return function(c,p,f){return p&&l(c.prototype,p),f&&l(c,f),c}}(),t=R("../utils/logger.js"),r=function(l){return l&&l.__esModule?l:{default:l}}(t),s=R("./loader.js"),d=R("../utils/exception.js"),y=function(l){function c(p,f){k(this,c);var i=C(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,"xhr-msstream-loader"));return i.TAG="MSStreamLoader",i._seekHandler=p,i._config=f,i._needStash=!0,i._xhr=null,i._reader=null,i._totalRange=null,i._currentRange=null,i._currentRequestURL=null,i._currentRedirectedURL=null,i._contentLength=null,i._receivedLength=0,i._bufferLimit=16777216,i._lastTimeBufferSize=0,i._isReconnecting=!1,i}return I(c,l),e(c,null,[{key:"isSupported",value:function(){try{if(self.MSStream===void 0||self.MSStreamReader===void 0)return!1;var p=new XMLHttpRequest;return p.open("GET","https://example.com",!0),p.responseType="ms-stream",p.responseType==="ms-stream"}catch(f){return r.default.w("MSStreamLoader",f.message),!1}}}]),e(c,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._reader&&(this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr=null),n(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"destroy",this).call(this)}},{key:"open",value:function(p,f){this._internalOpen(p,f,!1)}},{key:"_internalOpen",value:function(p,f,i){this._dataSource=p,i?this._currentRange=f:this._totalRange=f;var m=p.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?m=this._currentRedirectedURL:p.redirectedURL!=null&&(m=p.redirectedURL));var o=this._seekHandler.getConfig(m,f);this._currentRequestURL=o.url;var u=this._reader=new self.MSStreamReader;u.onprogress=this._msrOnProgress.bind(this),u.onload=this._msrOnLoad.bind(this),u.onerror=this._msrOnError.bind(this);var E=this._xhr=new XMLHttpRequest;if(E.open("GET",o.url,!0),E.responseType="ms-stream",E.onreadystatechange=this._xhrOnReadyStateChange.bind(this),E.onerror=this._xhrOnError.bind(this),p.withCredentials&&(E.withCredentials=!0),a(o.headers)==="object"){var g=o.headers;for(var b in g)g.hasOwnProperty(b)&&E.setRequestHeader(b,g[b])}if(a(this._config.headers)==="object"){var L=this._config.headers;for(var S in L)L.hasOwnProperty(S)&&E.setRequestHeader(S,L[S])}this._isReconnecting?this._isReconnecting=!1:this._status=s.LoaderStatus.kConnecting,E.send()}},{key:"abort",value:function(){this._internalAbort(),this._status=s.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._reader&&(this._reader.readyState===1&&this._reader.abort(),this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.abort(),this._xhr.onreadystatechange=null,this._xhr=null)}},{key:"_xhrOnReadyStateChange",value:function(p){var f=p.target;if(f.readyState===2)if(f.status>=200&&f.status<=299){if(this._status=s.LoaderStatus.kBuffering,f.responseURL!=null){var i=this._seekHandler.removeURLParameters(f.responseURL);f.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}var m=f.getResponseHeader("Content-Length");if(m!=null&&this._contentLength==null){var o=parseInt(m);o>0&&(this._contentLength=o,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else{if(this._status=s.LoaderStatus.kError,!this._onError)throw new d.RuntimeException("MSStreamLoader: Http code invalid, "+f.status+" "+f.statusText);this._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText})}else if(f.readyState===3&&f.status>=200&&f.status<=299){this._status=s.LoaderStatus.kBuffering;var u=f.response;this._reader.readAsArrayBuffer(u)}}},{key:"_xhrOnError",value:function(p){this._status=s.LoaderStatus.kError;var f=s.LoaderErrors.EXCEPTION,i={code:-1,msg:p.constructor.name+" "+p.type};if(!this._onError)throw new d.RuntimeException(i.msg);this._onError(f,i)}},{key:"_msrOnProgress",value:function(p){var f=p.target,i=f.result;if(i==null)return void this._doReconnectIfNeeded();var m=i.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=i.byteLength;var o=this._totalRange.from+this._receivedLength;this._receivedLength+=m.byteLength,this._onDataArrival&&this._onDataArrival(m,o,this._receivedLength),i.byteLength>=this._bufferLimit&&(r.default.v(this.TAG,"MSStream buffer exceeded max size near "+(o+m.byteLength)+", reconnecting..."),this._doReconnectIfNeeded())}},{key:"_doReconnectIfNeeded",value:function(){if(this._contentLength==null||this._receivedLength<this._contentLength){this._isReconnecting=!0,this._lastTimeBufferSize=0,this._internalAbort();var p={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,p,!0)}}},{key:"_msrOnLoad",value:function(p){this._status=s.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)}},{key:"_msrOnError",value:function(p){this._status=s.LoaderStatus.kError;var f=0,i=null;if(this._contentLength&&this._receivedLength<this._contentLength?(f=s.LoaderErrors.EARLY_EOF,i={code:-1,msg:"MSStream meet Early-Eof"}):(f=s.LoaderErrors.EARLY_EOF,i={code:-1,msg:p.constructor.name+" "+p.type}),!this._onError)throw new d.RuntimeException(i.msg);this._onError(f,i)}}]),c}(s.BaseLoader);T.default=y},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24}],31:[function(R,P,T){"use strict";function k(f){return f&&f.__esModule?f:{default:f}}function C(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}function I(f,i){if(!f)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!i||typeof i!="object"&&typeof i!="function"?f:i}function a(f,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof i);f.prototype=Object.create(i&&i.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),i&&(Object.setPrototypeOf?Object.setPrototypeOf(f,i):f.__proto__=i)}Object.defineProperty(T,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},e=function f(i,m,o){i===null&&(i=Function.prototype);var u=Object.getOwnPropertyDescriptor(i,m);if(u===void 0){var E=Object.getPrototypeOf(i);return E===null?void 0:f(E,m,o)}if("value"in u)return u.value;var g=u.get;if(g!==void 0)return g.call(o)},t=function(){function f(i,m){for(var o=0;o<m.length;o++){var u=m[o];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(i,u.key,u)}}return function(i,m,o){return m&&f(i.prototype,m),o&&f(i,o),i}}(),r=R("../utils/logger.js"),s=k(r),d=R("./speed-sampler.js"),y=k(d),l=R("./loader.js"),c=R("../utils/exception.js"),p=function(f){function i(m,o){C(this,i);var u=I(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,"xhr-range-loader"));return u.TAG="RangeLoader",u._seekHandler=m,u._config=o,u._needStash=!1,u._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],u._currentChunkSizeKB=384,u._currentSpeedNormalized=0,u._zeroSpeedChunkCount=0,u._xhr=null,u._speedSampler=new y.default,u._requestAbort=!1,u._waitForTotalLength=!1,u._totalLengthReceived=!1,u._currentRequestURL=null,u._currentRedirectedURL=null,u._currentRequestRange=null,u._totalLength=null,u._contentLength=null,u._receivedLength=0,u._lastTimeLoaded=0,u}return a(i,f),t(i,null,[{key:"isSupported",value:function(){try{var m=new XMLHttpRequest;return m.open("GET","https://example.com",!0),m.responseType="arraybuffer",m.responseType==="arraybuffer"}catch(o){return s.default.w("RangeLoader",o.message),!1}}}]),t(i,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),e(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"destroy",this).call(this)}},{key:"open",value:function(m,o){this._dataSource=m,this._range=o,this._status=l.LoaderStatus.kConnecting;var u=!1;this._dataSource.filesize!=null&&this._dataSource.filesize!==0&&(u=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||u?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}},{key:"_openSubRange",value:function(){var m=1024*this._currentChunkSizeKB,o=this._range.from+this._receivedLength,u=o+m;this._contentLength!=null&&u-this._range.from>=this._contentLength&&(u=this._range.from+this._contentLength-1),this._currentRequestRange={from:o,to:u},this._internalOpen(this._dataSource,this._currentRequestRange)}},{key:"_internalOpen",value:function(m,o){this._lastTimeLoaded=0;var u=m.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?u=this._currentRedirectedURL:m.redirectedURL!=null&&(u=m.redirectedURL));var E=this._seekHandler.getConfig(u,o);this._currentRequestURL=E.url;var g=this._xhr=new XMLHttpRequest;if(g.open("GET",E.url,!0),g.responseType="arraybuffer",g.onreadystatechange=this._onReadyStateChange.bind(this),g.onprogress=this._onProgress.bind(this),g.onload=this._onLoad.bind(this),g.onerror=this._onXhrError.bind(this),m.withCredentials&&(g.withCredentials=!0),n(E.headers)==="object"){var b=E.headers;for(var L in b)b.hasOwnProperty(L)&&g.setRequestHeader(L,b[L])}if(n(this._config.headers)==="object"){var S=this._config.headers;for(var _ in S)S.hasOwnProperty(_)&&g.setRequestHeader(_,S[_])}g.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=l.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}},{key:"_onReadyStateChange",value:function(m){var o=m.target;if(o.readyState===2){if(o.responseURL!=null){var u=this._seekHandler.removeURLParameters(o.responseURL);o.responseURL!==this._currentRequestURL&&u!==this._currentRedirectedURL&&(this._currentRedirectedURL=u,this._onURLRedirect&&this._onURLRedirect(u))}if(o.status>=200&&o.status<=299){if(this._waitForTotalLength)return;this._status=l.LoaderStatus.kBuffering}else{if(this._status=l.LoaderStatus.kError,!this._onError)throw new c.RuntimeException("RangeLoader: Http code invalid, "+o.status+" "+o.statusText);this._onError(l.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:o.status,msg:o.statusText})}}}},{key:"_onProgress",value:function(m){if(this._status!==l.LoaderStatus.kError){if(this._contentLength===null){var o=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,o=!0;var u=m.total;this._internalAbort(),u!=null&u!==0&&(this._totalLength=u)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,o)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var E=m.loaded-this._lastTimeLoaded;this._lastTimeLoaded=m.loaded,this._speedSampler.addBytes(E)}}},{key:"_normalizeSpeed",value:function(m){var o=this._chunkSizeKBList,u=o.length-1,E=0,g=0,b=u;if(m<o[0])return o[0];for(;g<=b;){if((E=g+Math.floor((b-g)/2))===u||m>=o[E]&&m<o[E+1])return o[E];o[E]<m?g=E+1:b=E-1}}},{key:"_onLoad",value:function(m){if(this._status!==l.LoaderStatus.kError){if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;var o=this._speedSampler.lastSecondKBps;if(o===0&&++this._zeroSpeedChunkCount>=3&&(o=this._speedSampler.currentKBps),o!==0){var u=this._normalizeSpeed(o);this._currentSpeedNormalized!==u&&(this._currentSpeedNormalized=u,this._currentChunkSizeKB=u)}var E=m.target.response,g=this._range.from+this._receivedLength;this._receivedLength+=E.byteLength;var b=!1;this._contentLength!=null&&this._receivedLength<this._contentLength?this._openSubRange():b=!0,this._onDataArrival&&this._onDataArrival(E,g,this._receivedLength),b&&(this._status=l.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}}},{key:"_onXhrError",value:function(m){this._status=l.LoaderStatus.kError;var o=0,u=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(o=l.LoaderErrors.EARLY_EOF,u={code:-1,msg:"RangeLoader meet Early-Eof"}):(o=l.LoaderErrors.EXCEPTION,u={code:-1,msg:m.constructor.name+" "+m.type}),!this._onError)throw new c.RuntimeException(u.msg);this._onError(o,u)}},{key:"currentSpeed",get:function(){return this._speedSampler.lastSecondKBps}}]),i}(l.BaseLoader);T.default=p},{"../utils/exception.js":40,"../utils/logger.js":41,"./loader.js":24,"./speed-sampler.js":27}],32:[function(R,P,T){"use strict";function k(_){return _&&_.__esModule?_:{default:_}}function C(_,h){if(!(_ instanceof h))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},a=function(){function _(h,v){for(var A=0;A<v.length;A++){var w=v[A];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(h,w.key,w)}}return function(h,v,A){return v&&_(h.prototype,v),A&&_(h,A),h}}(),n=R("events"),e=k(n),t=R("../utils/logger.js"),r=k(t),s=R("../utils/browser.js"),d=k(s),y=R("./player-events.js"),l=k(y),c=R("../core/transmuxer.js"),p=k(c),f=R("../core/transmuxing-events.js"),i=k(f),m=R("../core/mse-controller.js"),o=k(m),u=R("../core/mse-events.js"),E=k(u),g=R("./player-errors.js"),b=R("../config.js"),L=R("../utils/exception.js"),S=function(){function _(h,v){if(C(this,_),this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new e.default,this._config=(0,b.createDefaultConfig)(),(v===void 0?"undefined":I(v))==="object"&&Object.assign(this._config,v),h.type.toLowerCase()!=="flv")throw new L.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");h.isLive===!0&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=h,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var A=d.default.chrome&&(d.default.version.major<50||d.default.version.major===50&&d.default.version.build<2661);this._alwaysSeekKeyframe=!!(A||d.default.msedge||d.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return a(_,[{key:"destroy",value:function(){this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(h,v){var A=this;h===l.default.MEDIA_INFO?this._mediaInfo!=null&&Promise.resolve().then(function(){A._emitter.emit(l.default.MEDIA_INFO,A.mediaInfo)}):h===l.default.STATISTICS_INFO&&this._statisticsInfo!=null&&Promise.resolve().then(function(){A._emitter.emit(l.default.STATISTICS_INFO,A.statisticsInfo)}),this._emitter.addListener(h,v)}},{key:"off",value:function(h,v){this._emitter.removeListener(h,v)}},{key:"attachMediaElement",value:function(h){var v=this;if(this._mediaElement=h,h.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),h.addEventListener("seeking",this.e.onvSeeking),h.addEventListener("canplay",this.e.onvCanPlay),h.addEventListener("stalled",this.e.onvStalled),h.addEventListener("progress",this.e.onvProgress),this._msectl=new o.default(this._config),this._msectl.on(E.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(E.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(E.default.SOURCE_OPEN,function(){v._mseSourceOpened=!0,v._hasPendingLoad&&(v._hasPendingLoad=!1,v.load())}),this._msectl.on(E.default.ERROR,function(A){v._emitter.emit(l.default.ERROR,g.ErrorTypes.MEDIA_ERROR,g.ErrorDetails.MEDIA_MSE_ERROR,A)}),this._msectl.attachMediaElement(h),this._pendingSeekTime!=null)try{h.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(A){}}},{key:"detachMediaElement",value:function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}},{key:"load",value:function(){var h=this;if(!this._mediaElement)throw new L.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new L.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");if(!this._hasPendingLoad){if(this._config.deferLoadAfterSourceOpen&&this._mseSourceOpened===!1)return void(this._hasPendingLoad=!0);this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new p.default(this._mediaDataSource,this._config),this._transmuxer.on(i.default.INIT_SEGMENT,function(v,A){h._msectl.appendInitSegment(A)}),this._transmuxer.on(i.default.MEDIA_SEGMENT,function(v,A){if(h._msectl.appendMediaSegment(A),h._config.lazyLoad&&!h._config.isLive){var w=h._mediaElement.currentTime;A.info.endDts>=1e3*(w+h._config.lazyLoadMaxDuration)&&h._progressChecker==null&&(r.default.v(h.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),h._suspendTransmuxer())}}),this._transmuxer.on(i.default.LOADING_COMPLETE,function(){h._msectl.endOfStream(),h._emitter.emit(l.default.LOADING_COMPLETE)}),this._transmuxer.on(i.default.RECOVERED_EARLY_EOF,function(){h._emitter.emit(l.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(i.default.IO_ERROR,function(v,A){h._emitter.emit(l.default.ERROR,g.ErrorTypes.NETWORK_ERROR,v,A)}),this._transmuxer.on(i.default.DEMUX_ERROR,function(v,A){h._emitter.emit(l.default.ERROR,g.ErrorTypes.MEDIA_ERROR,v,{code:-1,msg:A})}),this._transmuxer.on(i.default.MEDIA_INFO,function(v){h._mediaInfo=v,h._emitter.emit(l.default.MEDIA_INFO,Object.assign({},v))}),this._transmuxer.on(i.default.METADATA_ARRIVED,function(v){h._emitter.emit(l.default.METADATA_ARRIVED,v)}),this._transmuxer.on(i.default.SCRIPTDATA_ARRIVED,function(v){h._emitter.emit(l.default.SCRIPTDATA_ARRIVED,v)}),this._transmuxer.on(i.default.STATISTICS_INFO,function(v){h._statisticsInfo=h._fillStatisticsInfo(v),h._emitter.emit(l.default.STATISTICS_INFO,Object.assign({},h._statisticsInfo))}),this._transmuxer.on(i.default.RECOMMEND_SEEKPOINT,function(v){h._mediaElement&&!h._config.accurateSeek&&(h._requestSetTime=!0,h._mediaElement.currentTime=v/1e3)}),this._transmuxer.open()}}},{key:"unload",value:function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){console.log(this),this._mediaElement.pause()}},{key:"_fillStatisticsInfo",value:function(h){if(h.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return h;var v=!0,A=0,w=0;if(this._mediaElement.getVideoPlaybackQuality){var M=this._mediaElement.getVideoPlaybackQuality();A=M.totalVideoFrames,w=M.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(A=this._mediaElement.webkitDecodedFrameCount,w=this._mediaElement.webkitDroppedFrameCount):v=!1;return v&&(h.decodedFrames=A,h.droppedFrames=w),h}},{key:"_onmseUpdateEnd",value:function(){if(this._config.lazyLoad&&!this._config.isLive){for(var h=this._mediaElement.buffered,v=this._mediaElement.currentTime,A=0,w=0;w<h.length;w++){var M=h.start(w),B=h.end(w);if(M<=v&&v<B){A=B;break}}A>=v+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(r.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}},{key:"_onmseBufferFull",value:function(){r.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._progressChecker==null&&this._suspendTransmuxer()}},{key:"_suspendTransmuxer",value:function(){this._transmuxer&&(this._transmuxer.pause(),this._progressChecker==null&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}},{key:"_checkProgressAndResume",value:function(){for(var h=this._mediaElement.currentTime,v=this._mediaElement.buffered,A=!1,w=0;w<v.length;w++){var M=v.start(w),B=v.end(w);if(h>=M&&h<B){h>=B-this._config.lazyLoadRecoverDuration&&(A=!0);break}}A&&(window.clearInterval(this._progressChecker),this._progressChecker=null,A&&(r.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}},{key:"_isTimepointBuffered",value:function(h){for(var v=this._mediaElement.buffered,A=0;A<v.length;A++){var w=v.start(A),M=v.end(A);if(h>=w&&h<M)return!0}return!1}},{key:"_internalSeek",value:function(h){var v=this._isTimepointBuffered(h),A=!1,w=0;if(h<1&&this._mediaElement.buffered.length>0){var M=this._mediaElement.buffered.start(0);(M<1&&h<M||d.default.safari)&&(A=!0,w=d.default.safari?.1:M)}if(A)this._requestSetTime=!0,this._mediaElement.currentTime=w;else if(v){if(this._alwaysSeekKeyframe){var B=this._msectl.getNearestKeyframe(Math.floor(1e3*h));this._requestSetTime=!0,this._mediaElement.currentTime=B!=null?B.dts/1e3:h}else this._requestSetTime=!0,this._mediaElement.currentTime=h;this._progressChecker!=null&&this._checkProgressAndResume()}else this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(h),this._transmuxer.seek(Math.floor(1e3*h)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=h)}},{key:"_checkAndApplyUnbufferedSeekpoint",value:function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var h=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(h)||(this._progressChecker!=null&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(h),this._transmuxer.seek(Math.floor(1e3*h)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=h))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},{key:"_checkAndResumeStuckPlayback",value:function(h){var v=this._mediaElement;if(h||!this._receivedCanPlay||v.readyState<2){var A=v.buffered;A.length>0&&v.currentTime<A.start(0)&&(r.default.w(this.TAG,"Playback seems stuck at "+v.currentTime+", seek to "+A.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=A.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}},{key:"_onvLoadedMetadata",value:function(h){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}},{key:"_onvSeeking",value:function(h){var v=this._mediaElement.currentTime,A=this._mediaElement.buffered;if(this._requestSetTime)return void(this._requestSetTime=!1);if(v<1&&A.length>0){var w=A.start(0);if(w<1&&v<w||d.default.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=d.default.safari?.1:w)}if(this._isTimepointBuffered(v)){if(this._alwaysSeekKeyframe){var M=this._msectl.getNearestKeyframe(Math.floor(1e3*v));M!=null&&(this._requestSetTime=!0,this._mediaElement.currentTime=M.dts/1e3)}return void(this._progressChecker!=null&&this._checkProgressAndResume())}this._seekpointRecord={seekPoint:v,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},{key:"_onvCanPlay",value:function(h){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}},{key:"_onvStalled",value:function(h){this._checkAndResumeStuckPlayback(!0)}},{key:"_onvProgress",value:function(h){this._checkAndResumeStuckPlayback()}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(h){this._mediaElement.volume=h}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(h){this._mediaElement.muted=h}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(h){this._mediaElement?this._internalSeek(h):this._pendingSeekTime=h}},{key:"mediaInfo",get:function(){return Object.assign({},this._mediaInfo)}},{key:"statisticsInfo",get:function(){return this._statisticsInfo==null&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}}]),_}();T.default=S},{"../config.js":5,"../core/mse-controller.js":9,"../core/mse-events.js":10,"../core/transmuxer.js":11,"../core/transmuxing-events.js":13,"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./player-errors.js":34,"./player-events.js":35,events:2}],33:[function(R,P,T){"use strict";function k(l){return l&&l.__esModule?l:{default:l}}function C(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},a=function(){function l(c,p){for(var f=0;f<p.length;f++){var i=p[f];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(c,i.key,i)}}return function(c,p,f){return p&&l(c.prototype,p),f&&l(c,f),c}}(),n=R("events"),e=k(n),t=R("./player-events.js"),r=k(t),s=R("../config.js"),d=R("../utils/exception.js"),y=function(){function l(c,p){if(C(this,l),this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new e.default,this._config=(0,s.createDefaultConfig)(),(p===void 0?"undefined":I(p))==="object"&&Object.assign(this._config,p),c.type.toLowerCase()==="flv")throw new d.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(c.hasOwnProperty("segments"))throw new d.InvalidArgumentException("NativePlayer("+c.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=c,this._mediaElement=null}return a(l,[{key:"destroy",value:function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}},{key:"on",value:function(c,p){var f=this;c===r.default.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){f._emitter.emit(r.default.MEDIA_INFO,f.mediaInfo)}):c===r.default.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(function(){f._emitter.emit(r.default.STATISTICS_INFO,f.statisticsInfo)}),this._emitter.addListener(c,p)}},{key:"off",value:function(c,p){this._emitter.removeListener(c,p)}},{key:"attachMediaElement",value:function(c){if(this._mediaElement=c,c.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{c.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(p){}}},{key:"detachMediaElement",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"load",value:function(){if(!this._mediaElement)throw new d.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}},{key:"unload",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_onvLoadedMetadata",value:function(c){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(r.default.MEDIA_INFO,this.mediaInfo)}},{key:"_reportStatisticsInfo",value:function(){this._emitter.emit(r.default.STATISTICS_INFO,this.statisticsInfo)}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(c){this._mediaElement.volume=c}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(c){this._mediaElement.muted=c}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(c){this._mediaElement?this._mediaElement.currentTime=c:this._pendingSeekTime=c}},{key:"mediaInfo",get:function(){var c=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",p={mimeType:c+this._mediaDataSource.type};return this._mediaElement&&(p.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(p.width=this._mediaElement.videoWidth,p.height=this._mediaElement.videoHeight)),p}},{key:"statisticsInfo",get:function(){var c={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return c;var p=!0,f=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var m=this._mediaElement.getVideoPlaybackQuality();f=m.totalVideoFrames,i=m.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(f=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):p=!1;return p&&(c.decodedFrames=f,c.droppedFrames=i),c}}]),l}();T.default=y},{"../config.js":5,"../utils/exception.js":40,"./player-events.js":35,events:2}],34:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0}),T.ErrorDetails=T.ErrorTypes=void 0;var k=R("../io/loader.js"),C=R("../demux/demux-errors.js"),I=function(a){return a&&a.__esModule?a:{default:a}}(C);T.ErrorTypes={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},T.ErrorDetails={NETWORK_EXCEPTION:k.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:k.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:k.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:k.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:I.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:I.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:I.default.CODEC_UNSUPPORTED}},{"../demux/demux-errors.js":16,"../io/loader.js":24}],35:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};T.default=k},{}],36:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(){k(this,a)}return C(a,null,[{key:"getSilentFrame",value:function(n,e){if(n==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)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(e===6)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(e===1)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(e===2)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(e===3)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}}]),a}();T.default=I},{}],37:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(){k(this,a)}return C(a,null,[{key:"init",value:function(){a.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(var n in a.types)a.types.hasOwnProperty(n)&&(a.types[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]);var e=a.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=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]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}},{key:"box",value:function(n){for(var e=8,t=null,r=Array.prototype.slice.call(arguments,1),s=r.length,d=0;d<s;d++)e+=r[d].byteLength;t=new Uint8Array(e),t[0]=e>>>24&255,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=255&e,t.set(n,4);for(var y=8,l=0;l<s;l++)t.set(r[l],y),y+=r[l].byteLength;return t}},{key:"generateInitSegment",value:function(n){var e=a.box(a.types.ftyp,a.constants.FTYP),t=a.moov(n),r=new Uint8Array(e.byteLength+t.byteLength);return r.set(e,0),r.set(t,e.byteLength),r}},{key:"moov",value:function(n){var e=a.mvhd(n.timescale,n.duration),t=a.trak(n),r=a.mvex(n);return a.box(a.types.moov,e,t,r)}},{key:"mvhd",value:function(n,e){return a.box(a.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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]))}},{key:"trak",value:function(n){return a.box(a.types.trak,a.tkhd(n),a.mdia(n))}},{key:"tkhd",value:function(n){var e=n.id,t=n.duration,r=n.presentWidth,s=n.presentHeight;return a.box(a.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,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,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))}},{key:"mdia",value:function(n){return a.box(a.types.mdia,a.mdhd(n),a.hdlr(n),a.minf(n))}},{key:"mdhd",value:function(n){var e=n.timescale,t=n.duration;return a.box(a.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(n){var e=null;return e=n.type==="audio"?a.constants.HDLR_AUDIO:a.constants.HDLR_VIDEO,a.box(a.types.hdlr,e)}},{key:"minf",value:function(n){var e=null;return e=n.type==="audio"?a.box(a.types.smhd,a.constants.SMHD):a.box(a.types.vmhd,a.constants.VMHD),a.box(a.types.minf,e,a.dinf(),a.stbl(n))}},{key:"dinf",value:function(){return a.box(a.types.dinf,a.box(a.types.dref,a.constants.DREF))}},{key:"stbl",value:function(n){return a.box(a.types.stbl,a.stsd(n),a.box(a.types.stts,a.constants.STTS),a.box(a.types.stsc,a.constants.STSC),a.box(a.types.stsz,a.constants.STSZ),a.box(a.types.stco,a.constants.STCO))}},{key:"stsd",value:function(n){return n.type==="audio"?n.codec==="mp3"?a.box(a.types.stsd,a.constants.STSD_PREFIX,a.mp3(n)):a.box(a.types.stsd,a.constants.STSD_PREFIX,a.mp4a(n)):a.box(a.types.stsd,a.constants.STSD_PREFIX,a.avc1(n))}},{key:"mp3",value:function(n){var e=n.channelCount,t=n.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,t>>>8&255,255&t,0,0]);return a.box(a.types[".mp3"],r)}},{key:"mp4a",value:function(n){var e=n.channelCount,t=n.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e,0,16,0,0,0,0,t>>>8&255,255&t,0,0]);return a.box(a.types.mp4a,r,a.esds(n))}},{key:"esds",value:function(n){var e=n.config||[],t=e.length,r=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).concat([6,1,2]));return a.box(a.types.esds,r)}},{key:"avc1",value:function(n){var e=n.avcc,t=n.codecWidth,r=n.codecHeight,s=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,t>>>8&255,255&t,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return a.box(a.types.avc1,s,a.box(a.types.avcC,e))}},{key:"mvex",value:function(n){return a.box(a.types.mvex,a.trex(n))}},{key:"trex",value:function(n){var e=n.id,t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return a.box(a.types.trex,t)}},{key:"moof",value:function(n,e){return a.box(a.types.moof,a.mfhd(n.sequenceNumber),a.traf(n,e))}},{key:"mfhd",value:function(n){var e=new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n]);return a.box(a.types.mfhd,e)}},{key:"traf",value:function(n,e){var t=n.id,r=a.box(a.types.tfhd,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),s=a.box(a.types.tfdt,new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e])),d=a.sdtp(n),y=a.trun(n,d.byteLength+16+16+8+16+8+8);return a.box(a.types.traf,r,s,y,d)}},{key:"sdtp",value:function(n){for(var e=n.samples||[],t=e.length,r=new Uint8Array(4+t),s=0;s<t;s++){var d=e[s].flags;r[s+4]=d.isLeading<<6|d.dependsOn<<4|d.isDependedOn<<2|d.hasRedundancy}return a.box(a.types.sdtp,r)}},{key:"trun",value:function(n,e){var t=n.samples||[],r=t.length,s=12+16*r,d=new Uint8Array(s);e+=8+s,d.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0);for(var y=0;y<r;y++){var l=t[y].duration,c=t[y].size,p=t[y].flags,f=t[y].cts;d.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,p.isLeading<<2|p.dependsOn,p.isDependedOn<<6|p.hasRedundancy<<4|p.isNonSync,0,0,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*y)}return a.box(a.types.trun,d)}},{key:"mdat",value:function(n){return a.box(a.types.mdat,n)}}]),a}();I.init(),T.default=I},{}],38:[function(R,P,T){"use strict";function k(f){return f&&f.__esModule?f:{default:f}}function C(f,i){if(!(f instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function f(i,m){for(var o=0;o<m.length;o++){var u=m[o];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(i,u.key,u)}}return function(i,m,o){return m&&f(i.prototype,m),o&&f(i,o),i}}(),a=R("../utils/logger.js"),n=k(a),e=R("./mp4-generator.js"),t=k(e),r=R("./aac-silent.js"),s=k(r),d=R("../utils/browser.js"),y=k(d),l=R("../core/media-segment-info.js"),c=R("../utils/exception.js"),p=function(){function f(i){C(this,f),this.TAG="MP4Remuxer",this._config=i,this._isLive=i.isLive===!0,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new l.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new l.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!y.default.chrome||!(y.default.version.major<50||y.default.version.major===50&&y.default.version.build<2661)),this._fillSilentAfterSeek=y.default.msedge||y.default.msie,this._mp3UseMpegAudio=!y.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return I(f,[{key:"destroy",value:function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}},{key:"bindDataSource",value:function(i){return i.onDataAvailable=this.remux.bind(this),i.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}},{key:"insertDiscontinuity",value:function(){this._audioNextDts=this._videoNextDts=void 0}},{key:"seek",value:function(i){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}},{key:"remux",value:function(i,m){if(!this._onMediaSegment)throw new c.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(i,m),this._remuxVideo(m),this._remuxAudio(i)}},{key:"_onTrackMetadataReceived",value:function(i,m){var o=null,u="mp4",E=m.codec;if(i==="audio")this._audioMeta=m,m.codec==="mp3"&&this._mp3UseMpegAudio?(u="mpeg",E="",o=new Uint8Array):o=t.default.generateInitSegment(m);else{if(i!=="video")return;this._videoMeta=m,o=t.default.generateInitSegment(m)}if(!this._onInitSegment)throw new c.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(i,{type:i,data:o.buffer,codec:E,container:i+"/"+u,mediaDuration:m.duration})}},{key:"_calculateDtsBase",value:function(i,m){this._dtsBaseInited||(i.samples&&i.samples.length&&(this._audioDtsBase=i.samples[0].dts),m.samples&&m.samples.length&&(this._videoDtsBase=m.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}},{key:"flushStashedSamples",value:function(){var i=this._videoStashedLastSample,m=this._audioStashedLastSample,o={type:"video",id:1,sequenceNumber:0,samples:[],length:0};i!=null&&(o.samples.push(i),o.length=i.length);var u={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};m!=null&&(u.samples.push(m),u.length=m.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(o,!0),this._remuxAudio(u,!0)}},{key:"_remuxAudio",value:function(i,m){if(this._audioMeta!=null){var o=i,u=o.samples,E=void 0,g=-1,b=-1,L=this._audioMeta.refSampleDuration,S=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,_=this._dtsBaseInited&&this._audioNextDts===void 0,h=!1;if(u&&u.length!==0&&(u.length!==1||m)){var v=0,A=null,w=0;S?(v=0,w=o.length):(v=8,w=8+o.length);var M=null;if(u.length>1&&(M=u.pop(),w-=M.length),this._audioStashedLastSample!=null){var B=this._audioStashedLastSample;this._audioStashedLastSample=null,u.unshift(B),w+=B.length}M!=null&&(this._audioStashedLastSample=M);var G=u[0].dts-this._dtsBase;if(this._audioNextDts)E=G-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())E=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(h=!0);else{var U=this._audioSegmentInfoList.getLastSampleBefore(G);if(U!=null){var K=G-(U.originalDts+U.duration);K<=3&&(K=0);var z=U.dts+U.duration+K;E=G-z}else E=0}if(h){var W=G-E,F=this._videoSegmentInfoList.getLastSegmentBefore(G);if(F!=null&&F.beginDts<W){var X=s.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(X){var Y=F.beginDts,V=W-F.beginDts;n.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+Y+", duration: "+V),u.unshift({unit:X,dts:Y,pts:Y}),w+=X.byteLength}}else h=!1}for(var H=[],Q=0;Q<u.length;Q++){var Z=u[Q],ue=Z.unit,re=Z.dts-this._dtsBase,ee=re-E;g===-1&&(g=ee);var te=0;if(Q!==u.length-1)te=u[Q+1].dts-this._dtsBase-E-ee;else if(M!=null){var de=M.dts-this._dtsBase-E;te=de-ee}else te=H.length>=1?H[H.length-1].duration:Math.floor(L);var ne=!1,$=null;if(te>1.5*L&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!y.default.safari){ne=!0;var le=Math.abs(te-L),se=Math.ceil(le/L),he=ee+L;n.default.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.
dts: `+(ee+te)+" ms, expected: "+(ee+Math.round(L))+" ms, delta: "+Math.round(le)+" ms, generate: "+se+" frames");var ae=s.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);ae==null&&(n.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),ae=ue),$=[];for(var oe=0;oe<se;oe++){var ce=Math.round(he);if($.length>0){var me=$[$.length-1];me.duration=ce-me.dts}var ie={dts:ce,pts:ce,cts:0,unit:ae,size:ae.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};$.push(ie),w+=ie.size,he+=L}var O=$[$.length-1];O.duration=ee+te-O.dts,te=Math.round(L)}H.push({dts:ee,pts:ee,cts:0,unit:Z.unit,size:Z.unit.byteLength,duration:te,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),ne&&H.push.apply(H,$)}S?A=new Uint8Array(w):(A=new Uint8Array(w),A[0]=w>>>24&255,A[1]=w>>>16&255,A[2]=w>>>8&255,A[3]=255&w,A.set(t.default.types.mdat,4));for(var D=0;D<H.length;D++){var x=H[D].unit;A.set(x,v),v+=x.byteLength}var N=H[H.length-1];b=N.dts+N.duration,this._audioNextDts=b;var j=new l.MediaSegmentInfo;j.beginDts=g,j.endDts=b,j.beginPts=g,j.endPts=b,j.originalBeginDts=H[0].originalDts,j.originalEndDts=N.originalDts+N.duration,j.firstSample=new l.SampleInfo(H[0].dts,H[0].pts,H[0].duration,H[0].originalDts,!1),j.lastSample=new l.SampleInfo(N.dts,N.pts,N.duration,N.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(j),o.samples=H,o.sequenceNumber++;var q=null;q=S?new Uint8Array:t.default.moof(o,g),o.samples=[],o.length=0;var J={type:"audio",data:this._mergeBoxes(q,A).buffer,sampleCount:H.length,info:j};S&&_&&(J.timestampOffset=g),this._onMediaSegment("audio",J)}}}},{key:"_remuxVideo",value:function(i,m){if(this._videoMeta!=null){var o=i,u=o.samples,E=void 0,g=-1,b=-1,L=-1,S=-1;if(u&&u.length!==0&&(u.length!==1||m)){var _=8,h=null,v=8+i.length,A=null;if(u.length>1&&(A=u.pop(),v-=A.length),this._videoStashedLastSample!=null){var w=this._videoStashedLastSample;this._videoStashedLastSample=null,u.unshift(w),v+=w.length}A!=null&&(this._videoStashedLastSample=A);var M=u[0].dts-this._dtsBase;if(this._videoNextDts)E=M-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())E=0;else{var B=this._videoSegmentInfoList.getLastSampleBefore(M);if(B!=null){var G=M-(B.originalDts+B.duration);G<=3&&(G=0);var U=B.dts+B.duration+G;E=M-U}else E=0}for(var K=new l.MediaSegmentInfo,z=[],W=0;W<u.length;W++){var F=u[W],X=F.dts-this._dtsBase,Y=F.isKeyframe,V=X-E,H=F.cts,Q=V+H;g===-1&&(g=V,L=Q);var Z=0;if(W!==u.length-1)Z=u[W+1].dts-this._dtsBase-E-V;else if(A!=null){var ue=A.dts-this._dtsBase-E;Z=ue-V}else Z=z.length>=1?z[z.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(Y){var re=new l.SampleInfo(V,Q,Z,F.dts,!0);re.fileposition=F.fileposition,K.appendSyncPoint(re)}z.push({dts:V,pts:Q,cts:H,units:F.units,size:F.length,isKeyframe:Y,duration:Z,originalDts:X,flags:{isLeading:0,dependsOn:Y?2:1,isDependedOn:Y?1:0,hasRedundancy:0,isNonSync:Y?0:1}})}h=new Uint8Array(v),h[0]=v>>>24&255,h[1]=v>>>16&255,h[2]=v>>>8&255,h[3]=255&v,h.set(t.default.types.mdat,4);for(var ee=0;ee<z.length;ee++)for(var te=z[ee].units;te.length;){var de=te.shift(),ne=de.data;h.set(ne,_),_+=ne.byteLength}var $=z[z.length-1];if(b=$.dts+$.duration,S=$.pts+$.duration,this._videoNextDts=b,K.beginDts=g,K.endDts=b,K.beginPts=L,K.endPts=S,K.originalBeginDts=z[0].originalDts,K.originalEndDts=$.originalDts+$.duration,K.firstSample=new l.SampleInfo(z[0].dts,z[0].pts,z[0].duration,z[0].originalDts,z[0].isKeyframe),K.lastSample=new l.SampleInfo($.dts,$.pts,$.duration,$.originalDts,$.isKeyframe),this._isLive||this._videoSegmentInfoList.append(K),o.samples=z,o.sequenceNumber++,this._forceFirstIDR){var le=z[0].flags;le.dependsOn=2,le.isNonSync=0}var se=t.default.moof(o,g);o.samples=[],o.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(se,h).buffer,sampleCount:z.length,info:K})}}}},{key:"_mergeBoxes",value:function(i,m){var o=new Uint8Array(i.byteLength+m.byteLength);return o.set(i,0),o.set(m,i.byteLength),o}},{key:"onInitSegment",get:function(){return this._onInitSegment},set:function(i){this._onInitSegment=i}},{key:"onMediaSegment",get:function(){return this._onMediaSegment},set:function(i){this._onMediaSegment=i}}]),f}();T.default=p},{"../core/media-segment-info.js":8,"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./aac-silent.js":36,"./mp4-generator.js":37}],39:[function(R,P,T){"use strict";Object.defineProperty(T,"__esModule",{value:!0});var k={};(function(){var C=self.navigator.userAgent.toLowerCase(),I=/(edge)\/([\w.]+)/.exec(C)||/(opr)[\/]([\w.]+)/.exec(C)||/(chrome)[ \/]([\w.]+)/.exec(C)||/(iemobile)[\/]([\w.]+)/.exec(C)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(C)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(C)||/(webkit)[ \/]([\w.]+)/.exec(C)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(C)||/(msie) ([\w.]+)/.exec(C)||C.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(C)||C.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(C)||[],a=/(ipad)/.exec(C)||/(ipod)/.exec(C)||/(windows phone)/.exec(C)||/(iphone)/.exec(C)||/(kindle)/.exec(C)||/(android)/.exec(C)||/(windows)/.exec(C)||/(mac)/.exec(C)||/(linux)/.exec(C)||/(cros)/.exec(C)||[],n={browser:I[5]||I[3]||I[1]||"",version:I[2]||I[4]||"0",majorVersion:I[4]||I[2]||"0",platform:a[0]||""},e={};if(n.browser){e[n.browser]=!0;var t=n.majorVersion.split(".");e.version={major:parseInt(n.majorVersion,10),string:n.version},t.length>1&&(e.version.minor=parseInt(t[1],10)),t.length>2&&(e.version.build=parseInt(t[2],10))}n.platform&&(e[n.platform]=!0),(e.chrome||e.opr||e.safari)&&(e.webkit=!0),(e.rv||e.iemobile)&&(e.rv&&delete e.rv,n.browser="msie",e.msie=!0),e.edge&&(delete e.edge,n.browser="msedge",e.msedge=!0),e.opr&&(n.browser="opera",e.opera=!0),e.safari&&e.android&&(n.browser="android",e.android=!0),e.name=n.browser,e.platform=n.platform;for(var r in k)k.hasOwnProperty(r)&&delete k[r];Object.assign(k,e)})(),T.default=k},{}],40:[function(R,P,T){"use strict";function k(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||typeof t!="object"&&typeof t!="function"?e:t}function C(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function I(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var a=function(){function e(t,r){for(var s=0;s<r.length;s++){var d=r[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(t,d.key,d)}}return function(t,r,s){return r&&e(t.prototype,r),s&&e(t,s),t}}(),n=T.RuntimeException=function(){function e(t){I(this,e),this._message=t}return a(e,[{key:"toString",value:function(){return this.name+": "+this.message}},{key:"name",get:function(){return"RuntimeException"}},{key:"message",get:function(){return this._message}}]),e}();T.IllegalStateException=function(e){function t(r){return I(this,t),k(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r))}return C(t,e),a(t,[{key:"name",get:function(){return"IllegalStateException"}}]),t}(n),T.InvalidArgumentException=function(e){function t(r){return I(this,t),k(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r))}return C(t,e),a(t,[{key:"name",get:function(){return"InvalidArgumentException"}}]),t}(n),T.NotImplementedException=function(e){function t(r){return I(this,t),k(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r))}return C(t,e),a(t,[{key:"name",get:function(){return"NotImplementedException"}}]),t}(n)},{}],41:[function(R,P,T){"use strict";function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function e(t,r){for(var s=0;s<r.length;s++){var d=r[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(t,d.key,d)}}return function(t,r,s){return r&&e(t.prototype,r),s&&e(t,s),t}}(),I=R("events"),a=function(e){return e&&e.__esModule?e:{default:e}}(I),n=function(){function e(){k(this,e)}return C(e,null,[{key:"e",value:function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var s="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",s),e.ENABLE_ERROR&&(console.error?console.error(s):console.warn?console.warn(s):console.log(s))}},{key:"i",value:function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var s="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",s),e.ENABLE_INFO&&(console.info?console.info(s):console.log(s))}},{key:"w",value:function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var s="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",s),e.ENABLE_WARN&&(console.warn?console.warn(s):console.log(s))}},{key:"d",value:function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var s="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",s),e.ENABLE_DEBUG&&(console.debug?console.debug(s):console.log(s))}},{key:"v",value:function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var s="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",s),e.ENABLE_VERBOSE&&console.log(s)}}]),e}();n.GLOBAL_TAG="flv.js",n.FORCE_GLOBAL_TAG=!1,n.ENABLE_ERROR=!0,n.ENABLE_INFO=!0,n.ENABLE_WARN=!0,n.ENABLE_DEBUG=!0,n.ENABLE_VERBOSE=!0,n.ENABLE_CALLBACK=!1,n.emitter=new a.default,T.default=n},{events:2}],42:[function(R,P,T){"use strict";function k(s){return s&&s.__esModule?s:{default:s}}function C(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var I=function(){function s(d,y){for(var l=0;l<y.length;l++){var c=y[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(d,c.key,c)}}return function(d,y,l){return y&&s(d.prototype,y),l&&s(d,l),d}}(),a=R("events"),n=k(a),e=R("./logger.js"),t=k(e),r=function(){function s(){C(this,s)}return I(s,null,[{key:"getConfig",value:function(){return{globalTag:t.default.GLOBAL_TAG,forceGlobalTag:t.default.FORCE_GLOBAL_TAG,enableVerbose:t.default.ENABLE_VERBOSE,enableDebug:t.default.ENABLE_DEBUG,enableInfo:t.default.ENABLE_INFO,enableWarn:t.default.ENABLE_WARN,enableError:t.default.ENABLE_ERROR,enableCallback:t.default.ENABLE_CALLBACK}}},{key:"applyConfig",value:function(d){t.default.GLOBAL_TAG=d.globalTag,t.default.FORCE_GLOBAL_TAG=d.forceGlobalTag,t.default.ENABLE_VERBOSE=d.enableVerbose,t.default.ENABLE_DEBUG=d.enableDebug,t.default.ENABLE_INFO=d.enableInfo,t.default.ENABLE_WARN=d.enableWarn,t.default.ENABLE_ERROR=d.enableError,t.default.ENABLE_CALLBACK=d.enableCallback}},{key:"_notifyChange",value:function(){var d=s.emitter;if(d.listenerCount("change")>0){var y=s.getConfig();d.emit("change",y)}}},{key:"registerListener",value:function(d){s.emitter.addListener("change",d)}},{key:"removeListener",value:function(d){s.emitter.removeListener("change",d)}},{key:"addLogListener",value:function(d){t.default.emitter.addListener("log",d),t.default.emitter.listenerCount("log")>0&&(t.default.ENABLE_CALLBACK=!0,s._notifyChange())}},{key:"removeLogListener",value:function(d){t.default.emitter.removeListener("log",d),t.default.emitter.listenerCount("log")===0&&(t.default.ENABLE_CALLBACK=!1,s._notifyChange())}},{key:"forceGlobalTag",get:function(){return t.default.FORCE_GLOBAL_TAG},set:function(d){t.default.FORCE_GLOBAL_TAG=d,s._notifyChange()}},{key:"globalTag",get:function(){return t.default.GLOBAL_TAG},set:function(d){t.default.GLOBAL_TAG=d,s._notifyChange()}},{key:"enableAll",get:function(){return t.default.ENABLE_VERBOSE&&t.default.ENABLE_DEBUG&&t.default.ENABLE_INFO&&t.default.ENABLE_WARN&&t.default.ENABLE_ERROR},set:function(d){t.default.ENABLE_VERBOSE=d,t.default.ENABLE_DEBUG=d,t.default.ENABLE_INFO=d,t.default.ENABLE_WARN=d,t.default.ENABLE_ERROR=d,s._notifyChange()}},{key:"enableDebug",get:function(){return t.default.ENABLE_DEBUG},set:function(d){t.default.ENABLE_DEBUG=d,s._notifyChange()}},{key:"enableVerbose",get:function(){return t.default.ENABLE_VERBOSE},set:function(d){t.default.ENABLE_VERBOSE=d,s._notifyChange()}},{key:"enableInfo",get:function(){return t.default.ENABLE_INFO},set:function(d){t.default.ENABLE_INFO=d,s._notifyChange()}},{key:"enableWarn",get:function(){return t.default.ENABLE_WARN},set:function(d){t.default.ENABLE_WARN=d,s._notifyChange()}},{key:"enableError",get:function(){return t.default.ENABLE_ERROR},set:function(d){t.default.ENABLE_ERROR=d,s._notifyChange()}}]),s}();r.emitter=new n.default,T.default=r},{"./logger.js":41,events:2}],43:[function(R,P,T){"use strict";function k(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(T,"__esModule",{value:!0});var C=function(){function a(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&a(n.prototype,e),t&&a(n,t),n}}(),I=function(){function a(){k(this,a)}return C(a,null,[{key:"install",value:function(){Object.setPrototypeOf=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n},Object.assign=Object.assign||function(n){if(n==null)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(n),t=1;t<arguments.length;t++){var r=arguments[t];if(r!=null)for(var s in r)r.hasOwnProperty(s)&&(e[s]=r[s])}return e},typeof self.Promise!="function"&&R("es6-promise").polyfill()}}]),a}();I.install(),T.default=I},{"es6-promise":1}],44:[function(R,P,T){"use strict";function k(I,a,n){var e=I;if(a+n<e.length){for(;n--;)if((192&e[++a])!=128)return!1;return!0}return!1}function C(I){for(var a=[],n=I,e=0,t=I.length;e<t;)if(n[e]<128)a.push(String.fromCharCode(n[e])),++e;else{if(!(n[e]<192)){if(n[e]<224){if(k(n,e,1)){var r=(31&n[e])<<6|63&n[e+1];if(r>=128){a.push(String.fromCharCode(65535&r)),e+=2;continue}}}else if(n[e]<240){if(k(n,e,2)){var s=(15&n[e])<<12|(63&n[e+1])<<6|63&n[e+2];if(s>=2048&&(63488&s)!=55296){a.push(String.fromCharCode(65535&s)),e+=3;continue}}}else if(n[e]<248&&k(n,e,3)){var d=(7&n[e])<<18|(63&n[e+1])<<12|(63&n[e+2])<<6|63&n[e+3];if(d>65536&&d<1114112){d-=65536,a.push(String.fromCharCode(d>>>10|55296)),a.push(String.fromCharCode(1023&d|56320)),e+=4;continue}}}a.push(String.fromCharCode(65533)),++e}return a.join("")}Object.defineProperty(T,"__esModule",{value:!0}),T.default=C},{}]},{},[21])(21)});