(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-40ad1794"],{1368:function(e,t,i){(function(t,i){ /*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version v4.2.8+1e68dce6 */ (function(t,i){e.exports=i()})(0,(function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function s(e){return"function"===typeof e}var r=void 0;r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var n=r,a=0,o=void 0,h=void 0,l=function(e,t){b[a]=e,b[a+1]=t,a+=2,2===a&&(h?h(A):L())};function d(e){h=e}function u(e){l=e}var _="undefined"!==typeof window?window:void 0,c=_||{},m=c.MutationObserver||c.WebKitMutationObserver,f="undefined"===typeof self&&"undefined"!==typeof t&&"[object process]"==={}.toString.call(t),p="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel;function g(){return function(){return t.nextTick(A)}}function E(){return"undefined"!==typeof o?function(){o(A)}:y()}function v(){var e=0,t=new m(A),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}function S(){var e=new MessageChannel;return e.port1.onmessage=A,function(){return e.port2.postMessage(0)}}function y(){var e=setTimeout;return function(){return e(A,1)}}var b=new Array(1e3);function A(){for(var e=0;e ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","error",i),o.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}static i(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","info",i),o.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}static w(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","warn",i),o.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}static d(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","debug",i),o.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}static v(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","verbose",i),o.ENABLE_VERBOSE&&console.log(i)}}o.GLOBAL_TAG="flv.js",o.FORCE_GLOBAL_TAG=!1,o.ENABLE_ERROR=!0,o.ENABLE_INFO=!0,o.ENABLE_WARN=!0,o.ENABLE_DEBUG=!0,o.ENABLE_VERBOSE=!0,o.ENABLE_CALLBACK=!1,o.emitter=new a.a;var h=o;class l{constructor(){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}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(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())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}}var d=l;class u{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class _ extends u{constructor(e){super(e)}get name(){return"IllegalStateException"}}class c extends u{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends u{constructor(e){super(e)}get name(){return"NotImplementedException"}}const f={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},p={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class g{constructor(e){this._type=e||"undefined",this._status=f.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=f.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===f.kConnecting||this._status===f.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(e,t){throw new m("Unimplemented abstract function!")}abort(){throw new m("Unimplemented abstract function!")}}let E={};function v(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],s={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},r={};if(s.browser){r[s.browser]=!0;let e=s.majorVersion.split(".");r.version={major:parseInt(s.majorVersion,10),string:s.version},e.length>1&&(r.version.minor=parseInt(e[1],10)),e.length>2&&(r.version.build=parseInt(e[2],10))}if(s.platform&&(r[s.platform]=!0),(r.chrome||r.opr||r.safari)&&(r.webkit=!0),r.rv||r.iemobile){r.rv&&delete r.rv;let e="msie";s.browser=e,r[e]=!0}if(r.edge){delete r.edge;let e="msedge";s.browser=e,r[e]=!0}if(r.opr){let e="opera";s.browser=e,r[e]=!0}if(r.safari&&r.android){let e="android";s.browser=e,r[e]=!0}r.name=s.browser,r.platform=s.platform;for(let n in E)E.hasOwnProperty(n)&&delete E[n];Object.assign(E,r)}v();var S=E;class y extends g{static isSupported(){try{let e=S.msedge&&S.version.minor>=15048,t=!S.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);let s=this._seekHandler.getConfig(i,t),r=new self.Headers;if("object"===typeof s.headers){let e=s.headers;for(let t in e)e.hasOwnProperty(t)&&r.append(t,e[t])}let n={method:"GET",headers:r,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"===typeof this._config.headers)for(let a in this._config.headers)r.append(a,this._config.headers[a]);!1===e.cors&&(n.mode="same-origin"),e.withCredentials&&(n.credentials="include"),e.referrerPolicy&&(n.referrerPolicy=e.referrerPolicy),this._status=f.kConnecting,self.fetch(s.url,n).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=f.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==s.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=f.kError,!this._onError)throw new u("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=f.kError,!this._onError)throw e;this._onError(p.EXCEPTION,{code:-1,msg:e.message})})}abort(){this._requestAbort=!0}_pump(e){return e.read().then(t=>{if(t.done)if(null!==this._contentLength&&this._receivedLength{if(11===e.code&&S.msedge)return;this._status=f.kError;let t=0,i=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength299)){if(this._status=f.kError,!this._onError)throw new u("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=f.kBuffering}}_onProgress(e){if(this._status===f.kError)return;null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==f.kError&&(this._status=f.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=f.kError;let t=0,i=null;if(this._contentLength&&e.loaded=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let i=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?i=this._currentRedirectedURL:void 0!=e.redirectedURL&&(i=e.redirectedURL));let s=this._seekHandler.getConfig(i,t);this._currentRequestURL=s.url;let r=this._xhr=new XMLHttpRequest;if(r.open("GET",s.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"===typeof s.headers){let e=s.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}if("object"===typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}r.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=f.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(void 0!=t.responseURL){let e=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&e!==this._currentRedirectedURL&&(this._currentRedirectedURL=e,this._onURLRedirect&&this._onURLRedirect(e))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=f.kBuffering}else{if(this._status=f.kError,!this._onError)throw new u("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===f.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-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)}let t=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(t)}_normalizeSpeed(e){let t=this._chunkSizeKBList,i=t.length-1,s=0,r=0,n=i;if(e=t[s]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let i=e.target.response,s=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;let r=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=f.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new u(t.msg);this._onError(p.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onWebSocketError(e){this._status=f.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new u(t.msg);this._onError(p.EXCEPTION,t)}}var k=T;class C{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let i={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,i["Range"]=e}else this._zeroStart&&(i["Range"]="bytes=0-");return{url:e,headers:i}}removeURLParameters(e){return e}}var I=C;class D{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let i=e;if(0!==t.from||-1!==t.to){let e=!0;-1===i.indexOf("?")&&(i+="?",e=!1),e&&(i+="&"),i+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(i+=`&${this._endName}=${t.to.toString()}`)}return{url:i,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],i=void 0,s=e.indexOf("?");-1!==s&&(i=e.substring(s+1));let r="";if(void 0!=i&&i.length>0){let e=i.split("&");for(let t=0;t0;i[0]!==this._startName&&i[0]!==this._endName&&(s&&(r+="&"),r+=e[t])}}return 0===r.length?t:t+"?"+r}}var O=D;class M{constructor(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=393216,void 0!=t.stashInitialSize&&t.stashInitialSize>0&&(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,!1===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?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new d,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()}destroy(){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}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||void 0!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===w?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new I(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new O(t,i)}else{if("custom"!==e.seekType)throw new c("Invalid seekType in config: "+e.seekType);if("function"!==typeof e.customSeekHandler)throw new c("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=k;else if(b.isSupported())this._loaderClass=b;else if(R.isSupported())this._loaderClass=R;else{if(!w.isSupported())throw new u("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=w}}_createLoader(){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)}open(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))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){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)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!==typeof e||0===e.length)throw new c("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;while(t+10485760){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed),s=new Uint8Array(i,0,t);s.set(e,0)}this._stashBuffer=i,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,i=t.length-1,s=0,r=0,n=i;if(e=t[s]&&e=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let i=1024*t+1048576;this._bufferSize0){let t=this._stashBuffer.slice(0,this._stashUsed),s=this._dispatchChunks(t,this._stashByteStart);if(s0){let e=new Uint8Array(t,s);i.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=s}}else this._stashUsed=0,this._stashByteStart+=s;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let s=this._dispatchChunks(e,t);if(sthis._bufferSize&&(this._expandBuffer(r),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e,s),0),this._stashUsed+=r,this._stashByteStart=t+s}}}else if(0===this._stashUsed){let i=this._dispatchChunks(e,t);if(ithis._bufferSize&&this._expandBuffer(s);let r=new Uint8Array(this._stashBuffer,0,this._bufferSize);r.set(new Uint8Array(e,i),0),this._stashUsed+=s,this._stashByteStart=t+i}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let i=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(i0){let e=new Uint8Array(this._stashBuffer,i);t.set(e,0)}this._stashUsed-=i,this._stashByteStart+=i}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),s=t.byteLength-i;if(i0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);e.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}h.w(this.TAG,s+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,s}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(h.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=p.UNRECOVERABLE_EARLY_EOF),e){case p.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e0){let t=V.getConfig();e.emit("change",t)}}static registerListener(e){V.emitter.addListener("change",e)}static removeListener(e){V.emitter.removeListener("change",e)}static addLogListener(e){h.emitter.addListener("log",e),h.emitter.listenerCount("log")>0&&(h.ENABLE_CALLBACK=!0,V._notifyChange())}static removeLogListener(e){h.emitter.removeListener("log",e),0===h.emitter.listenerCount("log")&&(h.ENABLE_CALLBACK=!1,V._notifyChange())}}V.emitter=new a.a;var z=V;class j{constructor(){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}isComplete(){let 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}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}}_search(e,t){let i=0,s=e.length-1,r=0,n=0,a=s;t=e[r]&&t=128){t.push(String.fromCharCode(65535&e)),s+=2;continue}}}else if(i[s]<240){if(H(i,s,2)){let e=(15&i[s])<<12|(63&i[s+1])<<6|63&i[s+2];if(e>=2048&&55296!==(63488&e)){t.push(String.fromCharCode(65535&e)),s+=3;continue}}}else if(i[s]<248&&H(i,s,3)){let e=(7&i[s])<<18|(63&i[s+1])<<12|(63&i[s+2])<<6|63&i[s+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}var W=q;let $=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class X{static parseScriptData(e,t,i){let s={};try{let r=X.parseValue(e,t,i),n=X.parseValue(e,t+r.size,i-r.size);s[r.data]=n.data}catch(r){h.e("AMF",r.toString())}return s}static parseObject(e,t,i){if(i<3)throw new _("Data not enough when parse ScriptDataObject");let s=X.parseString(e,t,i),r=X.parseValue(e,t+s.size,i-s.size),n=r.objectEnd;return{data:{name:s.data,value:r.data},size:s.size+r.size,objectEnd:n}}static parseVariable(e,t,i){return X.parseObject(e,t,i)}static parseString(e,t,i){if(i<2)throw new _("Data not enough when parse String");let s,r=new DataView(e,t,i),n=r.getUint16(0,!$);return s=n>0?W(new Uint8Array(e,t+2,n)):"",{data:s,size:2+n}}static parseLongString(e,t,i){if(i<4)throw new _("Data not enough when parse LongString");let s,r=new DataView(e,t,i),n=r.getUint32(0,!$);return s=n>0?W(new Uint8Array(e,t+4,n)):"",{data:s,size:4+n}}static parseDate(e,t,i){if(i<10)throw new _("Data size invalid when parse Date");let s=new DataView(e,t,i),r=s.getFloat64(0,!$),n=s.getInt16(8,!$);return r+=60*n*1e3,{data:new Date(r),size:10}}static parseValue(e,t,i){if(i<1)throw new _("Data not enough when parse Value");let s,r=new DataView(e,t,i),n=1,a=r.getUint8(0),o=!1;try{switch(a){case 0:s=r.getFloat64(1,!$),n+=8;break;case 1:{let e=r.getUint8(1);s=!!e,n+=1;break}case 2:{let r=X.parseString(e,t+1,i-1);s=r.data,n+=r.size;break}case 3:{s={};let a=0;9===(16777215&r.getUint32(i-4,!$))&&(a=3);while(n32)throw new c("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let i=e-this._current_word_bits_left;this._fillCurrentWord();let s=Math.min(i,this._current_word_bits_left),r=this._current_word>>>32-s;return this._current_word<<=s,this._current_word_bits_left-=s,t=t<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}var Q=Z;class J{static _ebsp2rbsp(e){let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let n=0;n=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(s[r]=t[n],r++);return new Uint8Array(s.buffer,0,r)}static parseSPS(e){let t=J._ebsp2rbsp(e),i=new Q(t);i.readByte();let s=i.readByte();i.readByte();let r=i.readByte();i.readUEG();let n=J.getProfileString(s),a=J.getLevelString(r),o=1,h=420,l=[0,420,422,444],d=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(o=i.readUEG(),3===o&&i.readBits(1),o<=3&&(h=l[o]),d=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==o?8:12;for(let t=0;t0&&e<16?(y=t[e-1],b=s[e-1]):255===e&&(y=i.readByte()<<8|i.readByte(),b=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){let e=i.readBits(32),t=i.readBits(32);R=i.readBool(),L=t,w=2*e,A=L/w}}let k=1;1===y&&1===b||(k=y/b);let C=0,I=0;if(0===o)C=1,I=2-f;else{let e=3===o?1:2,t=1===o?2:1;C=e,I=t*(2-f)}let D=16*(c+1),O=16*(m+1)*(2-f);D-=(p+g)*C,O-=(E+v)*I;let M=Math.ceil(D*k);return i.destroy(),i=null,{profile_string:n,level_string:a,bit_depth:d,ref_frames:_,chroma_format:h,chroma_format_string:J.getChromaFormatString(h),frame_rate:{fixed:R,fps:A,fps_den:w,fps_num:L},sar_ratio:{width:y,height:b},codec_size:{width:D,height:O},present_size:{width:M,height:O}}}static _skipScalingList(e,t){let i=8,s=8,r=0;for(let n=0;n>>2!==0,r=0!==(1&t[4]),n=se(t,5);return n<9?i:{match:!0,consumed:n,dataOffset:n,hasAudioTrack:s,hasVideoTrack:r}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new K}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new _("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let i=0,s=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;{let t=re.probe(e);i=t.dataOffset}}if(this._firstParse){this._firstParse=!1,t+i!==this._dataOffset&&h.w(this.TAG,"First time parsing but chunk byteStart invalid!");let r=new DataView(e,i),n=r.getUint32(0,!s);0!==n&&h.w(this.TAG,"PrevTagSize0 !== 0 !!!"),i+=4}while(ie.byteLength)break;let n=r.getUint8(0),a=16777215&r.getUint32(0,!s);if(i+11+a+4>e.byteLength)break;if(8!==n&&9!==n&&18!==n){h.w(this.TAG,`Unsupported tag type ${n}, skipped`),i+=11+a+4;continue}let o=r.getUint8(4),l=r.getUint8(5),d=r.getUint8(6),u=r.getUint8(7),_=d|l<<8|o<<16|u<<24,c=16777215&r.getUint32(7,!s);0!==c&&h.w(this.TAG,"Meet tag which has StreamID != 0!");let m=i+11;switch(n){case 8:this._parseAudioData(e,m,a,_);break;case 9:this._parseVideoData(e,m,a,_,t+i);break;case 18:this._parseScriptData(e,m,a);break}let f=r.getUint32(11+a,!s);f!==11+a&&h.w(this.TAG,"Invalid PrevTagSize "+f),i+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),i}_parseScriptData(e,t,i){let s=Y.parseScriptData(e,t,i);if(s.hasOwnProperty("onMetaData")){if(null==s.onMetaData||"object"!==typeof s.onMetaData)return void h.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&h.w(this.TAG,"Found another onMetaData tag!"),this._metadata=s;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"===typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"===typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"===typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"===typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"===typeof e.width&&(this._mediaInfo.width=e.width),"number"===typeof e.height&&(this._mediaInfo.height=e.height),"number"===typeof e.duration){if(!this._durationOverrided){let t=Math.floor(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}}else this._mediaInfo.duration=0;if("number"===typeof e.framerate){let t=Math.floor(1e3*e.framerate);if(t>0){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"===typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,h.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(s).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},s))}_parseKeyframesIndex(e){let t=[],i=[];for(let s=1;s>>4;if(2!==a&&10!==a)return void this._onError(ie.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+a);let o=0,l=(12&n)>>>2;if(!(l>=0&&l<=4))return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+l);o=this._flvSoundRateTable[l];let d=1&n,u=this._audioMetadata,_=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),u=this._audioMetadata={},u.type="audio",u.id=_.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=o,u.channelCount=0===d?1:2),10===a){let r=this._parseAACAudioData(e,t+1,i-1);if(void 0==r)return;if(0===r.packetType){u.config&&h.w(this.TAG,"Found another AudioSpecificConfig!");let e=r.data;u.audioSampleRate=e.samplingRate,u.channelCount=e.channelCount,u.codec=e.codec,u.originalCodec=e.originalCodec,u.config=e.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,h.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",u);let t=this._mediaInfo;t.audioCodec=u.originalCodec,t.audioSampleRate=u.audioSampleRate,t.audioChannelCount=u.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===r.packetType){let e=this._timestampBase+s,t={unit:r.data,length:r.data.byteLength,dts:e,pts:e};_.samples.push(t),_.length+=r.data.length}else h.e(this.TAG,"Flv: Unsupported AAC data type "+r.packetType)}else if(2===a){if(!u.codec){let s=this._parseMP3AudioData(e,t+1,i-1,!0);if(void 0==s)return;u.audioSampleRate=s.samplingRate,u.channelCount=s.channelCount,u.codec=s.codec,u.originalCodec=s.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,h.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u);let r=this._mediaInfo;r.audioCodec=u.codec,r.audioSampleRate=u.audioSampleRate,r.audioChannelCount=u.channelCount,r.audioDataRate=s.bitRate,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)}let r=this._parseMP3AudioData(e,t+1,i-1,!1);if(void 0==r)return;let n=this._timestampBase+s,a={unit:r,length:r.byteLength,dts:n,pts:n};_.samples.push(a),_.length+=r.length}}_parseAACAudioData(e,t,i){if(i<=1)return void h.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let s={},r=new Uint8Array(e,t,i);return s.packetType=r[0],0===r[0]?s.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):s.data=r.subarray(1),s}_parseAACAudioSpecificConfig(e,t,i){let s=new Uint8Array(e,t,i),r=null,n=0,a=0,o=null,h=0,l=null;if(n=a=s[0]>>>3,h=(7&s[0])<<1|s[1]>>>7,h<0||h>=this._mpegSamplingRates.length)return void this._onError(ie.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let d=this._mpegSamplingRates[h],u=(120&s[1])>>>3;if(u<0||u>=8)return void this._onError(ie.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===n&&(l=(7&s[1])<<1|s[2]>>>7,o=(124&s[2])>>>2);let _=self.navigator.userAgent.toLowerCase();return-1!==_.indexOf("firefox")?h>=6?(n=5,r=new Array(4),l=h-3):(n=2,r=new Array(2),l=h):-1!==_.indexOf("android")?(n=2,r=new Array(2),l=h):(n=5,l=h,r=new Array(4),h>=6?l=h-3:1===u&&(n=2,r=new Array(2),l=h)),r[0]=n<<3,r[0]|=(15&h)>>>1,r[1]=(15&h)<<7,r[1]|=(15&u)<<3,5===n&&(r[1]|=(15&l)>>>1,r[2]=(1&l)<<7,r[2]|=8,r[3]=0),{config:r,samplingRate:d,channelCount:u,codec:"mp4a.40."+n,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,i,s){if(i<4)return void h.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let r=new Uint8Array(e,t,i),n=null;if(s){if(255!==r[0])return;let e=r[1]>>>3&3,t=(6&r[1])>>1,i=(240&r[2])>>>4,s=(12&r[2])>>>2,a=r[3]>>>6&3,o=3!==a?2:1,h=0,l=0,d=34,u="mp3";switch(e){case 0:h=this._mpegAudioV25SampleRateTable[s];break;case 2:h=this._mpegAudioV20SampleRateTable[s];break;case 3:h=this._mpegAudioV10SampleRateTable[s];break}switch(t){case 1:d=34,i>>4,o=15&n;7===o?this._parseAVCVideoPacket(e,t+1,i-1,s,r,a):this._onError(ie.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+o)}_parseAVCVideoPacket(e,t,i,s,r,n){if(i<4)return void h.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,o=new DataView(e,t,i),l=o.getUint8(0),d=16777215&o.getUint32(0,!a),u=d<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===l)this._parseAVCVideoData(e,t+4,i-4,s,r,n,u);else if(2!==l)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,i){if(i<7)return void h.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let s=this._videoMetadata,r=this._videoTrack,n=this._littleEndian,a=new DataView(e,t,i);s?"undefined"!==typeof s.avcc&&h.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),s=this._videoMetadata={},s.type="video",s.id=r.id,s.timescale=this._timescale,s.duration=this._duration);let o=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==o||0===l)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(ie.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let d=31&a.getUint8(5);if(0===d)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");d>1&&h.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+d);let u=6;for(let h=0;h1&&h.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+_),u++;for(let e=0;e<_;e++){let e=a.getUint16(u,!n);u+=2,0!==e&&(u+=e)}s.avcc=new Uint8Array(i),s.avcc.set(new Uint8Array(e,t,i),0),h.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",s)}else this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}_parseAVCVideoData(e,t,i,s,r,n,a){let o=this._littleEndian,l=new DataView(e,t,i),d=[],u=0,_=0;const c=this._naluLengthSize;let m=this._timestampBase+s,f=1===n;while(_=i){h.w(this.TAG,`Malformed Nalu near timestamp ${m}, offset = ${_}, dataSize = ${i}`);break}let s=l.getUint32(_,!o);if(3===c&&(s>>>=8),s>i-c)return void h.w(this.TAG,`Malformed Nalus near timestamp ${m}, NaluSize > DataSize!`);let r=31&l.getUint8(_+c);5===r&&(f=!0);let n=new Uint8Array(e,t+_,c+s),a={type:r,data:n};d.push(a),u+=n.byteLength,_+=c+s}if(d.length){let e=this._videoTrack,t={units:d,length:u,isKeyframe:f,dts:m,cts:a,pts:m+a};f&&(t.fileposition=r),e.samples.push(t),e.length+=u}}}var ne=re;class ae{static init(){ae.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let t in ae.types)ae.types.hasOwnProperty(t)&&(ae.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);let e=ae.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let a=0;a>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let n=8;for(let a=0;a>>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]))}static trak(e){return ae.box(ae.types.trak,ae.tkhd(e),ae.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return ae.box(ae.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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static mdia(e){return ae.box(ae.types.mdia,ae.mdhd(e),ae.hdlr(e),ae.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return ae.box(ae.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,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?ae.constants.HDLR_AUDIO:ae.constants.HDLR_VIDEO,ae.box(ae.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?ae.box(ae.types.smhd,ae.constants.SMHD):ae.box(ae.types.vmhd,ae.constants.VMHD),ae.box(ae.types.minf,t,ae.dinf(),ae.stbl(e))}static dinf(){let e=ae.box(ae.types.dinf,ae.box(ae.types.dref,ae.constants.DREF));return e}static stbl(e){let t=ae.box(ae.types.stbl,ae.stsd(e),ae.box(ae.types.stts,ae.constants.STTS),ae.box(ae.types.stsc,ae.constants.STSC),ae.box(ae.types.stsz,ae.constants.STSZ),ae.box(ae.types.stco,ae.constants.STCO));return t}static stsd(e){return"audio"===e.type?"mp3"===e.codec?ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.mp3(e)):ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.mp4a(e)):ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.avc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,s=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 ae.box(ae.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,s=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 ae.box(ae.types.mp4a,s,ae.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return ae.box(ae.types.esds,s)}static avc1(e){let t=e.avcc,i=e.codecWidth,s=e.codecHeight,r=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,s>>>8&255,255&s,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 ae.box(ae.types.avc1,r,ae.box(ae.types.avcC,t))}static mvex(e){return ae.box(ae.types.mvex,ae.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return ae.box(ae.types.trex,i)}static moof(e,t){return ae.box(ae.types.moof,ae.mfhd(e.sequenceNumber),ae.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return ae.box(ae.types.mfhd,t)}static traf(e,t){let i=e.id,s=ae.box(ae.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=ae.box(ae.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),n=ae.sdtp(e),a=ae.trun(e,n.byteLength+16+16+8+16+8+8);return ae.box(ae.types.traf,s,r,a,n)}static sdtp(e){let t=e.samples||[],i=t.length,s=new Uint8Array(4+i);for(let r=0;r>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let a=0;a>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r],12+16*a)}return ae.box(ae.types.trun,n)}static mdat(e){return ae.box(ae.types.mdat,e)}}ae.init();var oe=ae;class he{static getSilentFrame(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}}var le=he;class de{constructor(e,t,i,s,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=s,this.isSyncPoint=r,this.fileposition=null}}class ue{constructor(){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}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class _e{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts=t[r].dts&&et[s].lastSample.originalDts&&e=t[s].lastSample.originalDts&&(s===t.length-1||s0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;while(0===i.length&&t>0)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null}}class me{constructor(e){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 ce("audio"),this._videoSegmentInfoList=new ce("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!S.chrome||!(S.version.major<50||50===S.version.major&&S.version.build<2661)),this._fillSilentAfterSeek=S.msedge||S.msie,this._mp3UseMpegAudio=!S.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){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}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new _("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let i=null,s="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(s="mpeg",r="",i=new Uint8Array):i=oe.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=oe.generateInitSegment(t)}if(!this._onInitSegment)throw new _("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:`${e}/${s}`,mediaDuration:t.duration})}_calculateDtsBase(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)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);let s={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(s.samples.push(t),s.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(s,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let i=e,s=i.samples,r=void 0,n=-1,a=-1,o=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,d=this._dtsBaseInited&&void 0===this._audioNextDts,u=!1;if(!s||0===s.length)return;if(1===s.length&&!t)return;let _=0,c=null,m=0;l?(_=0,m=i.length):(_=8,m=8+i.length);let f=null;if(s.length>1&&(f=s.pop(),m-=f.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,s.unshift(e),m+=e.length}null!=f&&(this._audioStashedLastSample=f);let p=s[0].dts-this._dtsBase;if(this._audioNextDts)r=p-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())r=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(u=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0);let i=e.dts+e.duration+t;r=p-i}else r=0}if(u){let e=p-r,t=this._videoSegmentInfoList.getLastSegmentBefore(p);if(null!=t&&t.beginDts=1?g[g.length-1].duration:Math.floor(o);let d=!1,u=null;if(l>1.5*o&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!S.safari){d=!0;let e=Math.abs(l-o),s=Math.ceil(e/o),r=a+o;h.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${a+l} ms, expected: ${a+Math.round(o)} ms, delta: ${Math.round(e)} ms, generate: ${s} frames`);let n=le.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==n&&(h.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),n=t),u=[];for(let t=0;t0){let t=u[u.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:n,size:n.byteLength,duration:0,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};u.push(t),m+=t.size,r+=o}let _=u[u.length-1];_.duration=a+l-_.dts,l=Math.round(o)}g.push({dts:a,pts:a,cts:0,unit:e.unit,size:e.unit.byteLength,duration:l,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,u)}l?c=new Uint8Array(m):(c=new Uint8Array(m),c[0]=m>>>24&255,c[1]=m>>>16&255,c[2]=m>>>8&255,c[3]=255&m,c.set(oe.types.mdat,4));for(let h=0;h1&&(_=s.pop(),u-=_.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(e),u+=e.length}null!=_&&(this._videoStashedLastSample=_);let c=s[0].dts-this._dtsBase;if(this._videoNextDts)r=c-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())r=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(c);if(null!=e){let t=c-(e.originalDts+e.duration);t<=3&&(t=0);let i=e.dts+e.duration+t;r=c-i}else r=0}let m=new ue,f=[];for(let E=0;E=1?f[f.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(i){let t=new de(a,l,d,e.dts,!0);t.fileposition=e.fileposition,m.appendSyncPoint(t)}f.push({dts:a,pts:l,cts:h,units:e.units,size:e.length,isKeyframe:i,duration:d,originalDts:t,flags:{isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1}})}d=new Uint8Array(u),d[0]=u>>>24&255,d[1]=u>>>16&255,d[2]=u>>>8&255,d[3]=255&u,d.set(oe.types.mdat,4);for(let E=0;E{s.timestampBase=i,i+=s.duration,s.cors=e.cors,s.withCredentials=e.withCredentials,t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy)}),isNaN(i)||this._mediaDataSource.duration===i||(this._mediaDataSource.duration=i),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){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}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let i=this._mediaDataSource.segments[e],s=this._ioctl=new B(i,this._config,e);s.onError=this._onIOException.bind(this),s.onSeeked=this._onIOSeeked.bind(this),s.onComplete=this._onIOComplete.bind(this),s.onRedirect=this._onIORedirect.bind(this),s.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):s.onDataArrival=this._onInitChunkArrival.bind(this),s.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let i=this._mediaInfo.segments[t];if(void 0==i)this._pendingSeekTime=e;else{let t=i.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let i=this._mediaInfo.segments[t];if(void 0==i)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let s=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,s.fileposition),this._pendingResolveSeekPoint=s.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,i=t.length-1;for(let s=0;s0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,s=this._demuxer.parseChunks(e,t);else if((i=ne.probe(e)).match){this._demuxer=new ne(i,this._config),this._remuxer||(this._remuxer=new fe(this._config));let r=this._mediaDataSource;void 0==r.duration||isNaN(r.duration)||(this._demuxer.overridedDuration=r.duration),"boolean"===typeof r.hasAudio&&(this._demuxer.overridedHasAudio=r.hasAudio),"boolean"===typeof r.hasVideo&&(this._demuxer.overridedHasVideo=r.hasVideo),this._demuxer.timestampBase=r.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),s=this._demuxer.parseChunks(e,t)}else i=null,h.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(ge.DEMUX_ERROR,ie.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),s=0;return s}_onMediaInfo(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,K.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,K.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(ge.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(ge.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e,i=t+1;i0&&e[0].originalDts===i&&(i=e[0].pts),this._emitter.emit(ge.RECOMMEND_SEEKPOINT,i)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(ge.MEDIA_INFO,i)}_reportStatisticsInfo(){let 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,this._emitter.emit(ge.STATISTICS_INFO,e)}}var ve=Ee;let Se=function(e){let t=null,i=f.bind(this);function s(t,i){let s={msg:ge.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(s,[i.data])}function n(t,i){let s={msg:ge.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(s,[i.data])}function a(){let t={msg:ge.LOADING_COMPLETE};e.postMessage(t)}function o(){let t={msg:ge.RECOVERED_EARLY_EOF};e.postMessage(t)}function h(t){let i={msg:ge.MEDIA_INFO,data:t};e.postMessage(i)}function l(t){let i={msg:ge.METADATA_ARRIVED,data:t};e.postMessage(i)}function d(t){let i={msg:ge.SCRIPTDATA_ARRIVED,data:t};e.postMessage(i)}function u(t){let i={msg:ge.STATISTICS_INFO,data:t};e.postMessage(i)}function _(t,i){e.postMessage({msg:ge.IO_ERROR,data:{type:t,info:i}})}function c(t,i){e.postMessage({msg:ge.DEMUX_ERROR,data:{type:t,info:i}})}function m(t){e.postMessage({msg:ge.RECOMMEND_SEEKPOINT,data:t})}function f(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}r.install(),e.addEventListener("message",(function(r){switch(r.data.cmd){case"init":t=new ve(r.data.param[0],r.data.param[1]),t.on(ge.IO_ERROR,_.bind(this)),t.on(ge.DEMUX_ERROR,c.bind(this)),t.on(ge.INIT_SEGMENT,s.bind(this)),t.on(ge.MEDIA_SEGMENT,n.bind(this)),t.on(ge.LOADING_COMPLETE,a.bind(this)),t.on(ge.RECOVERED_EARLY_EOF,o.bind(this)),t.on(ge.MEDIA_INFO,h.bind(this)),t.on(ge.METADATA_ARRIVED,l.bind(this)),t.on(ge.SCRIPTDATA_ARRIVED,d.bind(this)),t.on(ge.STATISTICS_INFO,u.bind(this)),t.on(ge.RECOMMEND_SEEKPOINT,m.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(r.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=r.data.param;z.applyConfig(e),!0===e.enableCallback?z.addLogListener(i):z.removeLogListener(i);break}}}))};var ye=Se;class be{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new a.a,t.enableWorker&&"undefined"!==typeof Worker)try{let s=i("d2be");this._worker=s(ye),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},z.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:z.getConfig()})}catch(s){h.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ve(e,t)}else this._controller=new ve(e,t);if(this._controller){let e=this._controller;e.on(ge.IO_ERROR,this._onIOError.bind(this)),e.on(ge.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(ge.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(ge.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(ge.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(ge.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(ge.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(ge.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(ge.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(ge.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(ge.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),z.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(ge.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(ge.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(ge.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(ge.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let 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 ge.INIT_SEGMENT:case ge.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case ge.LOADING_COMPLETE:case ge.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case ge.MEDIA_INFO:Object.setPrototypeOf(i,K.prototype),this._emitter.emit(t.msg,i);break;case ge.METADATA_ARRIVED:case ge.SCRIPTDATA_ARRIVED:case ge.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case ge.IO_ERROR:case ge.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case ge.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":h.emitter.emit("log",i.type,i.logcat);break;default:break}}}var Ae=be;const Re={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var Le=Re;class we{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new a.a,this._config.isLive&&void 0==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 _e}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new _("MediaSource has been attached to an HTMLMediaElement!");let 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}detachMediaElement(){if(this._mediaSource){let t=this._mediaSource;for(let i in this._sourceBuffers){let s=this._pendingSegments[i];s.splice(0,s.length),this._pendingSegments[i]=null,this._pendingRemoveRanges[i]=null,this._lastInitSegments[i]=null;let r=this._sourceBuffers[i];if(r){if("closed"!==t.readyState){try{t.removeSourceBuffer(r)}catch(e){h.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[i]=null,this._sourceBuffers[i]=null}}if("open"===t.readyState)try{t.endOfStream()}catch(e){h.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)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let i=e,s=""+i.container;i.codec&&i.codec.length>0&&(s+=";codecs="+i.codec);let r=!1;if(h.v(this.TAG,"Received Initialization Segment, mimeType: "+s),this._lastInitSegments[i.type]=i,s!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])h.v(this.TAG,`Notice: ${i.type} mimeType changed, origin: ${this._mimeTypes[i.type]}, target: ${s}`);else{r=!0;try{let e=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(s);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(n){return h.e(this.TAG,n.message),void this._emitter.emit(Le.ERROR,{code:n.code,msg:n.message})}}this._mimeTypes[i.type]=s}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),S.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let i in this._sourceBuffers){if(!this._sourceBuffers[i])continue;let e=this._sourceBuffers[i];if("open"===this._mediaSource.readyState)try{e.abort()}catch(t){h.e(this.TAG,t.message)}this._idrList.clear();let s=this._pendingSegments[i];if(s.splice(0,s.length),"closed"!==this._mediaSource.readyState){for(let t=0;t=1&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let i=this._sourceBuffers[t];if(i){let s=i.buffered,r=!1;for(let i=0;i=this._config.autoCleanupMaxBackwardDuration){r=!0;let i=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:n,end:i})}}else a0&&(isNaN(t)||i>t)&&(h.v(this.TAG,`Update MediaSource duration from ${t} to ${i}`),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let e in this._pendingRemoveRanges){if(!this._sourceBuffers[e]||this._sourceBuffers[e].updating)continue;let t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];while(i.length&&!t.updating){let e=i.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let i in e)if(this._sourceBuffers[i]&&!this._sourceBuffers[i].updating&&e[i].length>0){let s=e[i].shift();if(s.timestampOffset){let e=this._sourceBuffers[i].timestampOffset,t=s.timestampOffset/1e3,r=Math.abs(e-t);r>.1&&(h.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${t}`),this._sourceBuffers[i].timestampOffset=t),delete s.timestampOffset}if(!s.data||0===s.data.byteLength)continue;try{this._sourceBuffers[i].appendBuffer(s.data),this._isBufferFull=!1,"video"===i&&s.hasOwnProperty("info")&&this._idrList.appendArray(s.info.syncPoints)}catch(t){this._pendingSegments[i].unshift(s),22===t.code?(this._isBufferFull||this._emitter.emit(Le.BUFFER_FULL),this._isBufferFull=!0):(h.e(this.TAG,t.message),this._emitter.emit(Le.ERROR,{code:t.code,msg:t.message}))}}}_onSourceOpen(){if(h.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;while(e.length){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(Le.SOURCE_OPEN)}_onSourceEnded(){h.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){h.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))}_hasPendingSegments(){let e=this._pendingSegments;return e.video.length>0||e.audio.length>0}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(Le.UPDATE_END)}_onSourceBufferError(e){h.e(this.TAG,"SourceBuffer Error: "+e)}}var Te=we;const ke={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},Ce={NETWORK_EXCEPTION:p.EXCEPTION,NETWORK_STATUS_CODE_INVALID:p.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:p.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:p.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:ie.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:ie.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:ie.CODEC_UNSUPPORTED};class Ie{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new a.a,this._config=U(),"object"===typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new c("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;let i=S.chrome&&(S.version.major<50||50===S.version.major&&S.version.build<2661);this._alwaysSeekKeyframe=!!(i||S.msedge||S.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){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.removeAllListeners(),this._emitter=null}on(e,t){e===G.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}):e===G.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,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 Te(this._config),this._msectl.on(Le.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(Le.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(Le.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(Le.ERROR,e=>{this._emitter.emit(G.ERROR,ke.MEDIA_ERROR,Ce.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){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)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new _("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new Ae(this._mediaDataSource,this._config),this._transmuxer.on(ge.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(ge.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(h.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(ge.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(G.LOADING_COMPLETE)}),this._transmuxer.on(ge.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(G.RECOVERED_EARLY_EOF)}),this._transmuxer.on(ge.IO_ERROR,(e,t)=>{this._emitter.emit(G.ERROR,ke.NETWORK_ERROR,e,t)}),this._transmuxer.on(ge.DEMUX_ERROR,(e,t)=>{this._emitter.emit(G.ERROR,ke.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(ge.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(G.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(ge.METADATA_ARRIVED,e=>{this._emitter.emit(G.METADATA_ARRIVED,e)}),this._transmuxer.on(ge.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(G.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(ge.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(G.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(ge.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open()))}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,s=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,s=e.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,s=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=s),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,i=0,s=0;for(let r=0;r=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(h.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){h.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1;for(let s=0;s=r&&e=n-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(h.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let i=0;i=s&&e0){let t=this._mediaElement.buffered.start(0);(t<1&&e0&&t.currentTime0){let e=i.start(0);if(e<1&&t{this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}):e===G.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){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)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,s=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,s=e.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,s=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=s),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}}var Me=Oe;function Be(e,t){let i=e;if(null==i||"object"!==typeof i)throw new c("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new c("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"flv":return new De(i,t);default:return new Me(i,t)}}function xe(){return P.supportMSEH264Playback()}function Ue(){return P.getFeatureList()}r.install();let Ne={};Ne.createPlayer=Be,Ne.isSupported=xe,Ne.getFeatureList=Ue,Ne.BaseLoader=g,Ne.LoaderStatus=f,Ne.LoaderErrors=p,Ne.Events=G,Ne.ErrorTypes=ke,Ne.ErrorDetails=Ce,Ne.FlvPlayer=De,Ne.NativePlayer=Me,Ne.LoggingControl=z,Object.defineProperty(Ne,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var Pe=Ne;function Fe(e){var t=e.src,i=e.autoplay,s=void 0!==i&&i,r=e.media,n=e.options,a=void 0===n?{type:"flv",url:t}:n,o=e.callback,h=void 0===o?function(){return{}}:o;if(Pe.isSupported()){var l=Pe.createPlayer(a);l.attachMediaElement(r),l.load(),l.on(Pe.Events.ERROR,(function(e){switch(e){case Pe.ErrorTypes.NETWORK_ERROR:l.load();break;default:l.destroy();break}})),s&&l.play(),h(l)}}t["default"]=Fe},4362:function(e,t,i){t.nextTick=function(e){var t=Array.prototype.slice.call(arguments);t.shift(),setTimeout((function(){e.apply(null,t)}),0)},t.platform=t.arch=t.execPath=t.title="browser",t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(e){throw new Error("No such module. (Possibly not yet loaded)")},function(){var e,s="/";t.cwd=function(){return s},t.chdir=function(t){e||(e=i("df7c")),s=e.resolve(t,s)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},d2be:function(e,t){var i=arguments[3],s=arguments[4],r=arguments[5],n=JSON.stringify;e.exports=function(e,t){for(var a,o=Object.keys(r),h=0,l=o.length;h=0;s--){var r=e[s];"."===r?e.splice(s,1):".."===r?(e.splice(s,1),i++):i&&(e.splice(s,1),i--)}if(t)for(;i--;i)e.unshift("..");return e}function s(e){"string"!==typeof e&&(e+="");var t,i=0,s=-1,r=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!r){i=t+1;break}}else-1===s&&(r=!1,s=t+1);return-1===s?"":e.slice(i,s)}function r(e,t){if(e.filter)return e.filter(t);for(var i=[],s=0;s=-1&&!s;n--){var a=n>=0?arguments[n]:e.cwd();if("string"!==typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,s="/"===a.charAt(0))}return t=i(r(t.split("/"),(function(e){return!!e})),!s).join("/"),(s?"/":"")+t||"."},t.normalize=function(e){var s=t.isAbsolute(e),a="/"===n(e,-1);return e=i(r(e.split("/"),(function(e){return!!e})),!s).join("/"),e||s||(e="."),e&&a&&(e+="/"),(s?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(r(e,(function(e,t){if("string"!==typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,i){function s(e){for(var t=0;t=0;i--)if(""!==e[i])break;return t>i?[]:e.slice(t,i-t+1)}e=t.resolve(e).substr(1),i=t.resolve(i).substr(1);for(var r=s(e.split("/")),n=s(i.split("/")),a=Math.min(r.length,n.length),o=a,h=0;h=1;--n)if(t=e.charCodeAt(n),47===t){if(!r){s=n;break}}else r=!1;return-1===s?i?"/":".":i&&1===s?"/":e.slice(0,s)},t.basename=function(e,t){var i=s(e);return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i},t.extname=function(e){"string"!==typeof e&&(e+="");for(var t=-1,i=0,s=-1,r=!0,n=0,a=e.length-1;a>=0;--a){var o=e.charCodeAt(a);if(47!==o)-1===s&&(r=!1,s=a+1),46===o?-1===t?t=a:1!==n&&(n=1):-1!==t&&(n=-1);else if(!r){i=a+1;break}}return-1===t||-1===s||0===n||1===n&&t===s-1&&t===i+1?"":e.slice(t,s)};var n="b"==="ab".substr(-1)?function(e,t,i){return e.substr(t,i)}:function(e,t,i){return t<0&&(t=e.length+t),e.substr(t,i)}}).call(this,i("4362"))},faa1:function(e,t,i){"use strict";var s,r="object"===typeof Reflect?Reflect:null,n=r&&"function"===typeof r.apply?r.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};function a(e){console&&console.warn&&console.warn(e)}s=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!==e};function h(){h.init.call(this)}e.exports=h,h.EventEmitter=h,h.prototype._events=void 0,h.prototype._eventsCount=0,h.prototype._maxListeners=void 0;var l=10;function d(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?h.defaultMaxListeners:e._maxListeners}function _(e,t,i,s){var r,n,o;if(d(i),n=e._events,void 0===n?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),n=e._events),o=n[t]),void 0===o)o=n[t]=i,++e._eventsCount;else if("function"===typeof o?o=n[t]=s?[i,o]:[o,i]:s?o.unshift(i):o.push(i),r=u(e),r>0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,a(h)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function m(e,t,i){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=c.bind(s);return r.listener=i,s.wrapFn=r,r}function f(e,t,i){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"===typeof r?i?[r.listener||r]:[r]:i?v(r):g(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"===typeof i)return 1;if(void 0!==i)return i.length}return 0}function g(e,t){for(var i=new Array(t),s=0;s0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var h=r[e];if(void 0===h)return!1;if("function"===typeof h)n(h,this,t);else{var l=h.length,d=g(h,l);for(i=0;i=0;n--)if(i[n]===t||i[n].listener===t){a=i[n].listener,r=n;break}if(r<0)return this;0===r?i.shift():E(i,r),1===i.length&&(s[e]=i[0]),void 0!==s.removeListener&&this.emit("removeListener",e,a||t)}return this},h.prototype.off=h.prototype.removeListener,h.prototype.removeAllListeners=function(e){var t,i,s;if(i=this._events,void 0===i)return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,n=Object.keys(i);for(s=0;s=0;s--)this.removeListener(e,t[s]);return this},h.prototype.listeners=function(e){return f(this,e,!0)},h.prototype.rawListeners=function(e){return f(this,e,!1)},h.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},h.prototype.listenerCount=p,h.prototype.eventNames=function(){return this._eventsCount>0?s(this._events):[]}}}]);