IntelligentRecognition/ah-jjsp-web/.svn/pristine/f1/f1ca372f7e1d87ec8538a9a5edd...

1 line
179 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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