| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581 |
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.flvjs=e()}}(function(){var e;return function(){function e(t,i,n){function r(a,o){if(!i[a]){if(!t[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[a]={exports:{}};t[a][0].call(h.exports,function(e){return r(t[a][1][e]||e)},h,h.exports,e,t,i,n)}return i[a].exports}for(var s="function"==typeof require&&require,a=0;a<n.length;a++)r(n[a]);return r}return e}()({1:[function(t,i,n){(function(r,s){!function(t,r){"object"==typeof n&&void 0!==i?i.exports=r():"function"==typeof e&&e.amd?e(r):t.ES6Promise=r()}(this,function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function i(e){return"function"==typeof e}function n(e){G=e}function a(e){V=e}function o(){return void 0!==z?function(){z(l)}:u()}function u(){var e=setTimeout;return function(){return e(l,1)}}function l(){for(var e=0;e<F;e+=2){(0,Y[e])(Y[e+1]),Y[e]=void 0,Y[e+1]=void 0}F=0}function h(e,t){var i=this,n=new this.constructor(c);void 0===n[$]&&T(n);var r=i._state;if(r){var s=arguments[r-1];V(function(){return A(r,n,s,i._result)})}else w(i,n,e,t);return n}function d(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var i=new t(c);return b(i,e),i}function c(){}function f(){return new TypeError("You cannot resolve a promise with itself")}function _(){return new TypeError("A promises callback cannot return that same promise.")}function p(e){try{return e.then}catch(e){return te.error=e,te}}function m(e,t,i,n){try{e.call(t,i,n)}catch(e){return e}}function v(e,t,i){V(function(e){var n=!1,r=m(i,t,function(i){n||(n=!0,t!==i?b(e,i):S(e,i))},function(t){n||(n=!0,k(e,t))},"Settle: "+(e._label||" unknown promise"));!n&&r&&(n=!0,k(e,r))},e)}function g(e,t){t._state===J?S(e,t._result):t._state===ee?k(e,t._result):w(t,void 0,function(t){return b(e,t)},function(t){return k(e,t)})}function y(e,t,n){t.constructor===e.constructor&&n===h&&t.constructor.resolve===d?g(e,t):n===te?(k(e,te.error),te.error=null):void 0===n?S(e,t):i(n)?v(e,t,n):S(e,t)}function b(t,i){t===i?k(t,f()):e(i)?y(t,i,p(i)):S(t,i)}function E(e){e._onerror&&e._onerror(e._result),L(e)}function S(e,t){e._state===Q&&(e._result=t,e._state=J,0!==e._subscribers.length&&V(L,e))}function k(e,t){e._state===Q&&(e._state=ee,e._result=t,V(E,e))}function w(e,t,i,n){var r=e._subscribers,s=r.length;e._onerror=null,r[s]=t,r[s+J]=i,r[s+ee]=n,0===s&&e._state&&V(L,e)}function L(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var n=void 0,r=void 0,s=e._result,a=0;a<t.length;a+=3)n=t[a],r=t[a+i],n?A(i,n,r,s):r(s);e._subscribers.length=0}}function R(e,t){try{return e(t)}catch(e){return te.error=e,te}}function A(e,t,n,r){var s=i(n),a=void 0,o=void 0,u=void 0,l=void 0;if(s){if(a=R(n,r),a===te?(l=!0,o=a.error,a.error=null):u=!0,t===a)return void k(t,_())}else a=r,u=!0;t._state!==Q||(s&&u?b(t,a):l?k(t,o):e===J?S(t,a):e===ee&&k(t,a))}function O(e,t){try{t(function(t){b(e,t)},function(t){k(e,t)})}catch(t){k(e,t)}}function x(){return ie++}function T(e){e[$]=ie++,e._state=void 0,e._result=void 0,e._subscribers=[]}function C(){return new Error("Array Methods must be provided an Array")}function B(e){return new ne(this,e).promise}function D(e){var t=this;return new t(N(e)?function(i,n){for(var r=e.length,s=0;s<r;s++)t.resolve(e[s]).then(i,n)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function I(e){var t=this,i=new t(c);return k(i,e),i}function M(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function j(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function P(){var e=void 0;if(void 0!==s)e=s;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=re}var U=void 0;U=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var N=U,F=0,z=void 0,G=void 0,V=function(e,t){Y[F]=e,Y[F+1]=t,2===(F+=2)&&(G?G(l):Z())},H="undefined"!=typeof window?window:void 0,q=H||{},K=q.MutationObserver||q.WebKitMutationObserver,W="undefined"==typeof self&&void 0!==r&&"[object process]"==={}.toString.call(r),X="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Y=new Array(1e3),Z=void 0;Z=W?function(){return function(){return r.nextTick(l)}}():K?function(){var e=0,t=new K(l),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}():X?function(){var e=new MessageChannel;return e.port1.onmessage=l,function(){return e.port2.postMessage(0)}}():void 0===H&&"function"==typeof t?function(){try{var e=Function("return this")().require("vertx");return z=e.runOnLoop||e.runOnContext,o()}catch(e){return u()}}():u();var $=Math.random().toString(36).substring(2),Q=void 0,J=1,ee=2,te={error:null},ie=0,ne=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(c),this.promise[$]||T(this.promise),N(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?S(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&S(this.promise,this._result))):k(this.promise,C())}return e.prototype._enumerate=function(e){for(var t=0;this._state===Q&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,n=i.resolve;if(n===d){var r=p(e);if(r===h&&e._state!==Q)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(i===re){var s=new i(c);y(s,e,r),this._willSettleAt(s,t)}else this._willSettleAt(new i(function(t){return t(e)}),t)}else this._willSettleAt(n(e),t)},e.prototype._settledAt=function(e,t,i){var n=this.promise;n._state===Q&&(this._remaining--,e===ee?k(n,i):this._result[t]=i),0===this._remaining&&S(n,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;w(e,void 0,function(e){return i._settledAt(J,t,e)},function(e){return i._settledAt(ee,t,e)})},e}(),re=function(){function e(t){this[$]=x(),this._result=this._state=void 0,this._subscribers=[],c!==t&&("function"!=typeof t&&M(),this instanceof e?O(this,t):j())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,n=t.constructor;return i(e)?t.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})}):t.then(e,e)},e}();return re.prototype.then=h,re.all=B,re.race=D,re.resolve=d,re.reject=I,re._setScheduler=n,re._setAsap=a,re._asap=V,re.polyfill=P,re.Promise=re,re})}).call(this,t("_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 r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(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,s,u,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i=this._events[e],o(i))return!1;if(r(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(a(i))for(s=Array.prototype.slice.call(arguments,1),l=i.slice(),n=l.length,u=0;u<n;u++)l[u].apply(this,s);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(i=o(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(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},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},n.prototype.removeListener=function(e,t){var i,n,s,o;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(i)){for(o=s;o-- >0;)if(i[o]===t||i[o].listener&&i[o].listener===t){n=o;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)return this;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(i=this._events[e],r(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(e,t,i){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(d===setTimeout)return setTimeout(e,0);if((d===n||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function a(e){if(c===clearTimeout)return clearTimeout(e);if((c===r||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function o(){m&&_&&(m=!1,_.length?p=_.concat(p):v=-1,p.length&&u())}function u(){if(!m){var e=s(o);m=!0;for(var t=p.length;t;){for(_=p,p=[];++v<t;)_&&_[v].run();v=-1,t=p.length}_=null,m=!1,a(e)}}function l(e,t){this.fun=e,this.array=t}function h(){}var d,c,f=t.exports={};!function(){try{d="function"==typeof setTimeout?setTimeout:n}catch(e){d=n}try{c="function"==typeof clearTimeout?clearTimeout:r}catch(e){c=r}}();var _,p=[],m=!1,v=-1;f.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];p.push(new l(e,t)),1!==p.length||m||s(u)},l.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=h,f.addListener=h,f.once=h,f.off=h,f.removeListener=h,f.removeAllListeners=h,f.emit=h,f.prependListener=h,f.prependOnceListener=h,f.listeners=function(e){return[]},f.binding=function(e){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(e){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},{}],4:[function(e,t,i){var n=arguments[3],r=arguments[4],s=arguments[5],a=JSON.stringify;t.exports=function(e,t){function i(e){m[e]=!0;for(var t in r[e][1]){var n=r[e][1][t];m[n]||i(n)}}for(var o,u=Object.keys(s),l=0,h=u.length;l<h;l++){var d=u[l],c=s[d].exports;if(c===e||c&&c.default===e){o=d;break}}if(!o){o=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var f={},l=0,h=u.length;l<h;l++){var d=u[l];f[d]=d}r[o]=["function(require,module,exports){"+e+"(self); }",f]}var _=Math.floor(Math.pow(16,8)*Math.random()).toString(16),p={};p[o]=o,r[_]=["function(require,module,exports){var f = require("+a(o)+");(f.default ? f.default : f)(self);}",p];var m={};i(_);var v="("+n+")({"+Object.keys(m).map(function(e){return a(e)+":["+r[e][0]+","+a(r[e][1])+"]"}).join(",")+"},{},["+a(_)+"])",g=window.URL||window.webkitURL||window.mozURL||window.msURL,y=new Blob([v],{type:"text/javascript"});if(t&&t.bare)return y;var b=g.createObjectURL(y),E=new Worker(b);return E.objectURL=b,E}},{}],5:[function(e,t,i){"use strict";function n(){return Object.assign({},r)}Object.defineProperty(i,"__esModule",{value:!0}),i.createDefaultConfig=n;var r=i.defaultConfig={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:3600,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1}},{}],6:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("../io/io-controller.js"),a=function(e){return e&&e.__esModule?e:{default:e}}(s),o=e("../config.js"),u=function(){function e(){n(this,e)}return r(e,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(t){void 0==e.videoElement&&(e.videoElement=window.document.createElement("video"));var i=e.videoElement.canPlayType(t);return"probably"===i||"maybe"==i}},{key:"getFeatureList",value:function(){var t={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.mseFlvPlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLiveFlvPlayback=t.mseFlvPlayback&&t.networkStreamIO,t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t}}]),e}();i.default=u},{"../config.js":5,"../io/io-controller.js":24}],7:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function e(){n(this,e),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.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return r(e,[{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.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,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}}},{key:"_search",value:function(e,t){var i=0,n=e.length-1,r=0,s=0,a=n;for(t<e[0]&&(i=0,s=a+1);s<=a;){if((r=s+Math.floor((a-s)/2))===n||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?s=r+1:a=r-1}return i}}]),e}();i.default=s},{}],8:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}();i.SampleInfo=function e(t,i,r,s,a){n(this,e),this.dts=t,this.pts=i,this.duration=r,this.originalDts=s,this.isSyncPoint=a,this.fileposition=null},i.MediaSegmentInfo=function(){function e(){n(this,e),this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return r(e,[{key:"appendSyncPoint",value:function(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}]),e}(),i.IDRSampleList=function(){function e(){n(this,e),this._list=[]}return r(e,[{key:"clear",value:function(){this._list=[]}},{key:"appendArray",value:function(e){var t=this._list;0!==e.length&&(t.length>0&&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=this._list,i=0,n=t.length-1,r=0,s=0,a=n;for(e<t[0].dts&&(i=0,s=a+1);s<=a;){if((r=s+Math.floor((a-s)/2))===n||e>=t[r].dts&&e<t[r+1].dts){i=r;break}t[r].dts<e?s=r+1:a=r-1}return this._list[i]}}]),e}(),i.MediaSegmentInfoList=function(){function e(t){n(this,e),this._type=t,this._list=[],this._lastAppendLocation=-1}return r(e,[{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=t.length-1,n=0,r=0,s=i,a=0;if(e<t[0].originalBeginDts)return a=-1;for(;r<=s;){if((n=r+Math.floor((s-r)/2))===i||e>t[n].lastSample.originalDts&&e<t[n+1].originalBeginDts){a=n;break}t[n].originalBeginDts<e?r=n+1:s=n-1}return a}},{key:"_searchNearestSegmentAfter",value:function(e){return this._searchNearestSegmentBefore(e)+1}},{key:"append",value:function(e){var t=this._list,i=e,n=this._lastAppendLocation,r=0;-1!==n&&n<t.length&&i.originalBeginDts>=t[n].lastSample.originalDts&&(n===t.length-1||n<t.length-1&&i.originalBeginDts<t[n+1].originalBeginDts)?r=n+1:t.length>0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)}},{key:"getLastSegmentBefore",value:function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}},{key:"getLastSampleBefore",value:function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}},{key:"getLastSyncPointBefore",value:function(e){for(var t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null}},{key:"type",get:function(){return this._type}},{key:"length",get:function(){return this._list.length}}]),e}()},{}],9:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("events"),o=n(a),u=e("../utils/logger.js"),l=n(u),h=e("../utils/browser.js"),d=n(h),c=e("./mse-events.js"),f=n(c),_=e("./media-segment-info.js"),p=e("../utils/exception.js"),m=function(){function e(t){r(this,e),this.TAG="MSEController",this._config=t,this._emitter=new o.default,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 _.IDRSampleList}return s(e,[{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 p.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=this._mediaSource;for(var t in this._sourceBuffers){var i=this._pendingSegments[t];i.splice(0,i.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var n=this._sourceBuffers[t];n&&("closed"!==e.readyState&&(e.removeSourceBuffer(n),n.removeEventListener("error",this.e.onSourceBufferError),n.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)),this._mimeTypes[t]=null,this._sourceBuffers[t]=null)}if("open"===e.readyState)try{e.endOfStream()}catch(e){l.default.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}},{key:"appendInitSegment",value:function(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var i=e,n=""+i.container;i.codec&&i.codec.length>0&&(n+=";codecs="+i.codec);var r=!1;if(l.default.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])l.default.v(this.TAG,"Notice: "+i.type+" mimeType changed, origin: "+this._mimeTypes[i.type]+", target: "+n);else{r=!0;try{if("audio"===i.type&&!this._sourceBuffers.video&&(void 0===this._config.hasAudio||this._config.hasAudio)){var s=this._sourceBuffers.video=this._mediaSource.addSourceBuffer('video/mp4; codecs="avc1.42E01E');s.addEventListener("error",this.e.onSourceBufferError),s.addEventListener("updateend",this.e.onSourceBufferUpdateEnd),s.mode="sequence",this._mimeTypes.video='video/mp4; codecs="avc1.42E01E'}var a=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);a.addEventListener("error",this.e.onSourceBufferError),a.addEventListener("updateend",this.e.onSourceBufferUpdateEnd),a.mode="sequence"}catch(e){return l.default.e(this.TAG,e.message),void this._emitter.emit(f.default.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),d.default.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())}},{key:"appendMediaSegment",value:function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}},{key:"seek",value:function(e){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){l.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})}if(i.updating||this._doRemoveRanges(),d.default.safari){var o=this._lastInitSegments[t];o&&(this._pendingSegments[t].push(o),i.updating||this._doAppendSegments())}}}}},{key:"endOfStream",value:function(){var e=this._mediaSource,t=this._sourceBuffers;if(!e||"open"!==e.readyState)return void(e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0));t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream())}},{key:"getNearestKeyframe",value:function(e){return this._idrList.getLastSyncPointBeforeDts(e)}},{key:"_needCleanupSourceBuffer",value:function(){if(!this._config.autoCleanupSourceBuffer)return!1;var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var i=this._sourceBuffers[t];if(i){var n=i.buffered;if(n.length>=1&&e-n.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var e=this._mediaElement.currentTime;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=n.start(s),o=n.end(s);if(a<=e&&e<o+3){if(e-a>=this._config.autoCleanupMaxBackwardDuration){r=!0;var u=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:a,end:u})}}else o<e&&(r=!0,this._pendingRemoveRanges[t].push({start:a,end:o}))}r&&!i.updating&&this._doRemoveRanges()}}}},{key:"_updateMediaSourceDuration",value:function(){var e=this._sourceBuffers;if(0!==this._mediaElement.readyState&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){var t=this._mediaSource.duration,i=this._pendingMediaDuration;i>0&&(isNaN(t)||i>t)&&(l.default.v(this.TAG,"Update MediaSource duration from "+t+" to "+i),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}},{key:"_doRemoveRanges",value:function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];i.length&&!t.updating;){var n=i.shift();n.start<n.end&&t.remove(n.start,n.end)}}},{key:"_doAppendSegments",value:function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var i=e[t].shift();if(i.timestampOffset){var n=this._sourceBuffers[t].timestampOffset,r=i.timestampOffset/1e3,s=Math.abs(n-r);s>.1&&(l.default.v(this.TAG,"Update MPEG audio timestampOffset from "+n+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(f.default.BUFFER_FULL),this._isBufferFull=!0):(l.default.e(this.TAG,e.message),this._emitter.emit(f.default.ERROR,{code:e.code,msg:e.message}))}}}},{key:"_onSourceOpen",value:function(){if(l.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(f.default.SOURCE_OPEN)}},{key:"_onSourceEnded",value:function(){l.default.v(this.TAG,"MediaSource onSourceEnded")}},{key:"_onSourceClose",value:function(){l.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))}},{key:"_hasPendingSegments",value:function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}},{key:"_onSourceBufferUpdateEnd",value:function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(f.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(e){l.default.e(this.TAG,"SourceBuffer Error: "+e)}}]),e}();i.default=m},{"../utils/browser.js":40,"../utils/exception.js":41,"../utils/logger.js":42,"./media-segment-info.js":8,"./mse-events.js":10,events:2}],10:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={ERROR:"error",SOURCE_OPEN:"source_open",
- UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};i.default=n},{}],11:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("events"),o=n(a),u=e("../utils/logger.js"),l=n(u),h=e("../utils/logging-control.js"),d=n(h),c=e("./transmuxing-controller.js"),f=n(c),_=e("./transmuxing-events.js"),p=n(_),m=e("./transmuxing-worker.js"),v=n(m),g=e("./media-info.js"),y=n(g),b=function(){function t(i,n){if(r(this,t),this.TAG="Transmuxer",this._emitter=new o.default,n.enableWorker&&"undefined"!=typeof Worker)try{var s=e("webworkify");this._worker=s(v.default),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[i,n]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},d.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:d.default.getConfig()})}catch(e){l.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new f.default(i,n)}else this._controller=new f.default(i,n);if(this._controller){var a=this._controller;a.on(p.default.IO_ERROR,this._onIOError.bind(this)),a.on(p.default.DEMUX_ERROR,this._onDemuxError.bind(this)),a.on(p.default.INIT_SEGMENT,this._onInitSegment.bind(this)),a.on(p.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),a.on(p.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),a.on(p.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),a.on(p.default.MEDIA_INFO,this._onMediaInfo.bind(this)),a.on(p.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),a.on(p.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return s(t,[{key:"destroy",value:function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),d.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(){i._emitter.emit(p.default.INIT_SEGMENT,e,t)})}},{key:"_onMediaSegment",value:function(e,t){var i=this;Promise.resolve().then(function(){i._emitter.emit(p.default.MEDIA_SEGMENT,e,t)})}},{key:"_onLoadingComplete",value:function(){var e=this;Promise.resolve().then(function(){e._emitter.emit(p.default.LOADING_COMPLETE)})}},{key:"_onRecoveredEarlyEof",value:function(){var e=this;Promise.resolve().then(function(){e._emitter.emit(p.default.RECOVERED_EARLY_EOF)})}},{key:"_onMediaInfo",value:function(e){var t=this;Promise.resolve().then(function(){t._emitter.emit(p.default.MEDIA_INFO,e)})}},{key:"_onStatisticsInfo",value:function(e){var t=this;Promise.resolve().then(function(){t._emitter.emit(p.default.STATISTICS_INFO,e)})}},{key:"_onIOError",value:function(e,t){var i=this;Promise.resolve().then(function(){i._emitter.emit(p.default.IO_ERROR,e,t)})}},{key:"_onDemuxError",value:function(e,t){var i=this;Promise.resolve().then(function(){i._emitter.emit(p.default.DEMUX_ERROR,e,t)})}},{key:"_onRecommendSeekpoint",value:function(e){var t=this;Promise.resolve().then(function(){t._emitter.emit(p.default.RECOMMEND_SEEKPOINT,e)})}},{key:"_onLoggingConfigChanged",value:function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}},{key:"_onWorkerMessage",value:function(e){var 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 p.default.INIT_SEGMENT:case p.default.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case p.default.LOADING_COMPLETE:case p.default.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case p.default.MEDIA_INFO:Object.setPrototypeOf(i,y.default.prototype),this._emitter.emit(t.msg,i);break;case p.default.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case p.default.IO_ERROR:case p.default.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case p.default.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":l.default.emitter.emit("log",i.type,i.logcat)}}}]),t}();i.default=b},{"../utils/logger.js":42,"../utils/logging-control.js":43,"./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";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("events"),o=n(a),u=e("../utils/logger.js"),l=n(u),h=e("../utils/browser.js"),d=n(h),c=e("./media-info.js"),f=n(c),_=e("../demux/flv-demuxer.js"),p=n(_),m=e("../remux/mp4-remuxer.js"),v=n(m),g=e("../demux/demux-errors.js"),y=n(g),b=e("../io/io-controller.js"),E=n(b),S=e("./transmuxing-events.js"),k=n(S),w=(e("../io/loader.js"),function(){function e(t,i){r(this,e),this.TAG="TransmuxingController",this._emitter=new o.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,this._currentSegmentIndex=0;var n=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,this._enableDecrypt=!1}return s(e,[{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,this._enableDecrypt=!1}},{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],n=this._ioctl=new E.default(i,this._config,e);n.onError=this._onIOException.bind(this),n.onSeeked=this._onIOSeeked.bind(this),n.onComplete=this._onIOComplete.bind(this),n.onRedirect=this._onIORedirect.bind(this),n.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),n.onOpened=this._onIOOpened.bind(this),t?this._demuxer.bindDataSource(this._ioctl):n.onDataArrival=this._onInitChunkArrival.bind(this),n.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._demuxer._firstParse=!0,this._demuxer._dataOffset=0,this._ioctl.resumeTime(this._remuxer._videoNextDts),this._enableStatisticsReporter())}},{key:"seek",value:function(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var i=this._mediaInfo.segments[t];if(void 0==i)this._pendingSeekTime=e;else{var n=i.getNearestKeyframe(e);this._remuxer.seek(n.milliseconds),this._ioctl.seek(n.fileposition),this._pendingResolveSeekPoint=n.milliseconds}}else{var r=this._mediaInfo.segments[t];if(void 0==r)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{var s=r.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()}}},{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=this,n=null,r=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=p.default.probe(e)).match){this._demuxer=new p.default(n,this._config),this._demuxer.enableDecrypt(this._enableDecrypt),this._remuxer||(this._remuxer=new v.default(this._config));var s=this._mediaDataSource;void 0==s.duration||isNaN(s.duration)||(this._demuxer.overridedDuration=s.duration),"boolean"==typeof s.hasAudio&&(this._demuxer.overridedHasAudio=s.hasAudio),"boolean"==typeof s.hasVideo&&(this._demuxer.overridedHasVideo=s.hasVideo),this._demuxer.timestampBase=s.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,l.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){i._internalAbort()}),this._emitter.emit(k.default.DEMUX_ERROR,y.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}},{key:"_onMediaInfo",value:function(e){var t=this;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,f.default.prototype));var i=Object.assign({},e);Object.setPrototypeOf(i,f.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)})}},{key:"_onIOOpened",value:function(e){this._enableDecrypt=e}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(e){var t=e,i=t+1;i<this._mediaDataSource.segments.length?(this._internalAbort(),this._loadSegment(i)):(this._emitter.emit(k.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(k.default.RECOVERED_EARLY_EOF)}},{key:"_onIOException",value:function(e,t){l.default.e(this.TAG,"IOException: type = "+e+", code = "+t.code+", msg = "+t.msg),this._emitter.emit(k.default.IO_ERROR,e,t),this._disableStatisticsReporter()}},{key:"_onDemuxException",value:function(e,t){l.default.e(this.TAG,"DemuxException: type = "+e+", info = "+t),this._emitter.emit(k.default.DEMUX_ERROR,e,t)}},{key:"_onRemuxerInitSegmentArrival",value:function(e,t){this._emitter.emit(k.default.INIT_SEGMENT,e,t)}},{key:"_onRemuxerMediaSegmentArrival",value:function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(k.default.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var i=t.info.syncPoints,n=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,d.default.safari&&i.length>0&&i[0].originalDts===n&&(n=i[0].pts),this._emitter.emit(k.default.RECOMMEND_SEEKPOINT,n)}}},{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){var 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(k.default.MEDIA_INFO,i)}},{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,this._emitter.emit(k.default.STATISTICS_INFO,e)}}]),e}());i.default=w},{"../demux/demux-errors.js":17,"../demux/flv-demuxer.js":19,"../io/io-controller.js":24,"../io/loader.js":25,"../remux/mp4-remuxer.js":39,"../utils/browser.js":40,"../utils/logger.js":42,"./media-info.js":7,"./transmuxing-events.js":13,events:2}],13:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={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",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};i.default=n},{}],14:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(i,"__esModule",{value:!0});var r=e("../utils/logger.js"),s=(n(r),e("../utils/logging-control.js")),a=n(s),o=e("../utils/polyfill.js"),u=n(o),l=e("./transmuxing-controller.js"),h=n(l),d=e("./transmuxing-events.js"),c=n(d),f=function(e){function t(t,i){var n={msg:c.default.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(n,[i.data])}function i(t,i){var n={msg:c.default.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(n,[i.data])}function n(){var t={msg:c.default.LOADING_COMPLETE};e.postMessage(t)}function r(){var t={msg:c.default.RECOVERED_EARLY_EOF};e.postMessage(t)}function s(t){var i={msg:c.default.MEDIA_INFO,data:t};e.postMessage(i)}function o(t){var i={msg:c.default.STATISTICS_INFO,data:t};e.postMessage(i)}function l(t,i){e.postMessage({msg:c.default.IO_ERROR,data:{type:t,info:i}})}function d(t,i){e.postMessage({msg:c.default.DEMUX_ERROR,data:{type:t,info:i}})}function f(t){e.postMessage({msg:c.default.RECOMMEND_SEEKPOINT,data:t})}function _(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}var p=null,m=_.bind(this);u.default.install(),e.addEventListener("message",function(u){switch(u.data.cmd){case"init":p=new h.default(u.data.param[0],u.data.param[1]),p.on(c.default.IO_ERROR,l.bind(this)),p.on(c.default.DEMUX_ERROR,d.bind(this)),p.on(c.default.INIT_SEGMENT,t.bind(this)),p.on(c.default.MEDIA_SEGMENT,i.bind(this)),p.on(c.default.LOADING_COMPLETE,n.bind(this)),p.on(c.default.RECOVERED_EARLY_EOF,r.bind(this)),p.on(c.default.MEDIA_INFO,s.bind(this)),p.on(c.default.STATISTICS_INFO,o.bind(this)),p.on(c.default.RECOMMEND_SEEKPOINT,f.bind(this));break;case"destroy":p&&(p.destroy(),p=null),e.postMessage({msg:"destroyed"});break;case"start":p.start();break;case"stop":p.stop();break;case"seek":p.seek(u.data.param);break;case"pause":p.pause();break;case"resume":p.resume();break;case"logging_config":var _=u.data.param;a.default.applyConfig(_),!0===_.enableCallback?a.default.addLogListener(m):a.default.removeLogListener(m)}})};i.default=f},{"../utils/logger.js":42,"../utils/logging-control.js":43,"../utils/polyfill.js":44,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=n||function(e,t){var i={},n=i.lib={},r=function(){},s=n.Base={extend:function(e){r.prototype=this;var t=new r;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,i=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var r=0;r<e;r++)t[n+r>>>2]|=(i[r>>>2]>>>24-r%4*8&255)<<24-(n+r)%4*8;else if(65535<i.length)for(r=0;r<e;r+=4)t[n+r>>>2]=i[r>>>2];else t.push.apply(t,i);return this.sigBytes+=e,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var i=[],n=0;n<t;n+=4)i.push(4294967296*e.random()|0);return new a.init(i,t)}}),o=i.enc={},u=o.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++){var r=t[n>>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(i,t/2)}},l=o.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++)i.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(i,t)}},h=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},d=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i=this._data,n=i.words,r=i.sigBytes,s=this.blockSize,o=r/(4*s),o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0);if(t=o*s,r=e.min(4*t,r),t){for(var u=0;u<t;u+=s)this._doProcessBlock(n,u);u=n.splice(0,t),i.sigBytes-=r}return new a.init(u,r)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=d.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new c.HMAC.init(e,i).finalize(t)}}});var c=i.algo={};return i}(Math),n=n||function(e,t){var i={},n=i.lib={},r=function(){},s=n.Base={extend:function(e){r.prototype=this;var t=new r;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,i=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var r=0;r<e;r++)t[n+r>>>2]|=(i[r>>>2]>>>24-r%4*8&255)<<24-(n+r)%4*8;else if(65535<i.length)for(r=0;r<e;r+=4)t[n+r>>>2]=i[r>>>2];else t.push.apply(t,i);return this.sigBytes+=e,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var i=[],n=0;n<t;n+=4)i.push(4294967296*e.random()|0);return new a.init(i,t)}}),o=i.enc={},u=o.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++){var r=t[n>>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(i,t/2)}},l=o.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++)i.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(i,t)}},h=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},d=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i=this._data,n=i.words,r=i.sigBytes,s=this.blockSize,o=r/(4*s),o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0);if(t=o*s,r=e.min(4*t,r),t){for(var u=0;u<t;u+=s)this._doProcessBlock(n,u);u=n.splice(0,t),i.sigBytes-=r}return new a.init(u,r)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=d.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new c.HMAC.init(e,i).finalize(t)}}});var c=i.algo={};return i}(Math);!function(){var e=n,t=e.lib.WordArray;e.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,n=this._map;e.clamp(),e=[];for(var r=0;r<i;r+=3)for(var s=(t[r>>>2]>>>24-r%4*8&255)<<16|(t[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|t[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;4>a&&r+.75*a<i;a++)e.push(n.charAt(s>>>6*(3-a)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var i=e.length,n=this._map,r=n.charAt(64);r&&-1!=(r=e.indexOf(r))&&(i=r);for(var r=[],s=0,a=0;a<i;a++)if(a%4){var o=n.indexOf(e.charAt(a-1))<<a%4*2,u=n.indexOf(e.charAt(a))>>>6-a%4*2;r[s>>>2]|=(o|u)<<24-s%4*8,s++}return t.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,i,n,r,s,a){return((e=e+(t&i|~t&n)+r+a)<<s|e>>>32-s)+t}function i(e,t,i,n,r,s,a){return((e=e+(t&n|i&~n)+r+a)<<s|e>>>32-s)+t}function r(e,t,i,n,r,s,a){return((e=e+(t^i^n)+r+a)<<s|e>>>32-s)+t}function s(e,t,i,n,r,s,a){return((e=e+(i^(t|~n))+r+a)<<s|e>>>32-s)+t}for(var a=n,o=a.lib,u=o.WordArray,l=o.Hasher,o=a.algo,h=[],d=0;64>d;d++)h[d]=4294967296*e.abs(e.sin(d+1))|0;o=o.MD5=l.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,n){for(var a=0;16>a;a++){var o=n+a,u=e[o];e[o]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var a=this._hash.words,o=e[n+0],u=e[n+1],l=e[n+2],d=e[n+3],c=e[n+4],f=e[n+5],_=e[n+6],p=e[n+7],m=e[n+8],v=e[n+9],g=e[n+10],y=e[n+11],b=e[n+12],E=e[n+13],S=e[n+14],k=e[n+15],w=a[0],L=a[1],R=a[2],A=a[3],w=t(w,L,R,A,o,7,h[0]),A=t(A,w,L,R,u,12,h[1]),R=t(R,A,w,L,l,17,h[2]),L=t(L,R,A,w,d,22,h[3]),w=t(w,L,R,A,c,7,h[4]),A=t(A,w,L,R,f,12,h[5]),R=t(R,A,w,L,_,17,h[6]),L=t(L,R,A,w,p,22,h[7]),w=t(w,L,R,A,m,7,h[8]),A=t(A,w,L,R,v,12,h[9]),R=t(R,A,w,L,g,17,h[10]),L=t(L,R,A,w,y,22,h[11]),w=t(w,L,R,A,b,7,h[12]),A=t(A,w,L,R,E,12,h[13]),R=t(R,A,w,L,S,17,h[14]),L=t(L,R,A,w,k,22,h[15]),w=i(w,L,R,A,u,5,h[16]),A=i(A,w,L,R,_,9,h[17]),R=i(R,A,w,L,y,14,h[18]),L=i(L,R,A,w,o,20,h[19]),w=i(w,L,R,A,f,5,h[20]),A=i(A,w,L,R,g,9,h[21]),R=i(R,A,w,L,k,14,h[22]),L=i(L,R,A,w,c,20,h[23]),w=i(w,L,R,A,v,5,h[24]),A=i(A,w,L,R,S,9,h[25]),R=i(R,A,w,L,d,14,h[26]),L=i(L,R,A,w,m,20,h[27]),w=i(w,L,R,A,E,5,h[28]),A=i(A,w,L,R,l,9,h[29]),R=i(R,A,w,L,p,14,h[30]),L=i(L,R,A,w,b,20,h[31]),w=r(w,L,R,A,f,4,h[32]),A=r(A,w,L,R,m,11,h[33]),R=r(R,A,w,L,y,16,h[34]),L=r(L,R,A,w,S,23,h[35]),w=r(w,L,R,A,u,4,h[36]),A=r(A,w,L,R,c,11,h[37]),R=r(R,A,w,L,p,16,h[38]),L=r(L,R,A,w,g,23,h[39]),w=r(w,L,R,A,E,4,h[40]),A=r(A,w,L,R,o,11,h[41]),R=r(R,A,w,L,d,16,h[42]),L=r(L,R,A,w,_,23,h[43]),w=r(w,L,R,A,v,4,h[44]),A=r(A,w,L,R,b,11,h[45]),R=r(R,A,w,L,k,16,h[46]),L=r(L,R,A,w,l,23,h[47]),w=s(w,L,R,A,o,6,h[48]),A=s(A,w,L,R,p,10,h[49]),R=s(R,A,w,L,S,15,h[50]),L=s(L,R,A,w,f,21,h[51]),w=s(w,L,R,A,b,6,h[52]),A=s(A,w,L,R,d,10,h[53]),R=s(R,A,w,L,g,15,h[54]),L=s(L,R,A,w,u,21,h[55]),w=s(w,L,R,A,m,6,h[56]),A=s(A,w,L,R,k,10,h[57]),R=s(R,A,w,L,_,15,h[58]),L=s(L,R,A,w,E,21,h[59]),w=s(w,L,R,A,c,6,h[60]),A=s(A,w,L,R,y,10,h[61]),R=s(R,A,w,L,l,15,h[62]),L=s(L,R,A,w,v,21,h[63]);a[0]=a[0]+w|0,a[1]=a[1]+L|0,a[2]=a[2]+R|0,a[3]=a[3]+A|0},_doFinalize:function(){var t=this._data,i=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;i[r>>>5]|=128<<24-r%32;var s=e.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(i.length+1),this._process(),t=this._hash,i=t.words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var e=l.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=l._createHelper(o),a.HmacMD5=l._createHmacHelper(o)}(Math),function(){var e=n,t=e.lib,i=t.Base,r=t.WordArray,t=e.algo,s=t.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,n=i.hasher.create(),s=r.create(),a=s.words,o=i.keySize,i=i.iterations;a.length<o;){u&&n.update(u);var u=n.update(e).finalize(t);n.reset();for(var l=1;l<i;l++)u=n.finalize(u),n.reset();s.concat(u)}return s.sigBytes=4*o,s}});e.EvpKDF=function(e,t,i){return s.create(i).compute(e,t)}}(),n.lib.Cipher||function(e){var t=n,i=t.lib,r=i.Base,s=i.WordArray,a=i.BufferedBlockAlgorithm,o=t.enc.Base64,u=t.algo.EvpKDF,l=i.Cipher=a.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(e){return{encrypt:function(t,i,n){return("string"==typeof i?p:_).encrypt(e,t,i,n)},decrypt:function(t,i,n){return("string"==typeof i?p:_).decrypt(e,t,i,n)}}}});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=t.mode={},d=function(e,t,i){var n=this._iv;n?this._iv=void 0:n=this._prevBlock;for(var r=0;r<i;r++)e[t+r]^=n[r]},c=(i.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}})).extend();c.Encryptor=c.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;d.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),c.Decryptor=c.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=e.slice(t,t+n);i.decryptBlock(e,t),d.call(this,e,t,n),this._prevBlock=r}}),h=h.CBC=c,c=(t.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,i=i-e.sigBytes%i,n=i<<24|i<<16|i<<8|i,r=[],a=0;a<i;a+=4)r.push(n);i=s.create(r,i),e.concat(i)},unpad:function(e){e.sigBytes-=255&e.words[e.sigBytes-1>>>2]}},i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:h,padding:c}),reset:function(){l.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var f=i.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?s.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){e=o.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var i=s.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return f.create({ciphertext:e,salt:i})}},_=i.SerializableCipher=r.extend({cfg:r.extend({format:h}),encrypt:function(e,t,i,n){n=this.cfg.extend(n);var r=e.createEncryptor(i,n);return t=r.finalize(t),r=r.cfg,f.create({ciphertext:t,key:i,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,i,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(i,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,i,n){return n||(n=s.random(8)),e=u.create({keySize:t+i}).compute(e,n),i=s.create(e.words.slice(t),4*i),e.sigBytes=4*t,f.create({key:e,iv:i,salt:n})}},p=i.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:t}),encrypt:function(e,t,i,n){return n=this.cfg.extend(n),i=n.kdf.execute(i,e.keySize,e.ivSize),n.iv=i.iv,e=_.encrypt.call(this,e,t,i.key,n),e.mixIn(i),e},decrypt:function(e,t,i,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),i=n.kdf.execute(i,e.keySize,e.ivSize,t.salt),n.iv=i.iv,_.decrypt.call(this,e,t,i.key,n)}})}(),function(){for(var e=n,t=e.lib.BlockCipher,i=e.algo,r=[],s=[],a=[],o=[],u=[],l=[],h=[],d=[],c=[],f=[],_=[],p=0;256>p;p++)_[p]=128>p?p<<1:p<<1^283;for(var m=0,v=0,p=0;256>p;p++){var g=v^v<<1^v<<2^v<<3^v<<4,g=g>>>8^255&g^99;r[m]=g,s[g]=m;var y=_[m],b=_[y],E=_[b],S=257*_[g]^16843008*g
- ;a[m]=S<<24|S>>>8,o[m]=S<<16|S>>>16,u[m]=S<<8|S>>>24,l[m]=S,S=16843009*E^65537*b^257*y^16843008*m,h[g]=S<<24|S>>>8,d[g]=S<<16|S>>>16,c[g]=S<<8|S>>>24,f[g]=S,m?(m=y^_[_[_[E^y]]],v^=_[_[v]]):m=v=1}var k=[0,1,2,4,8,16,32,64,128,27,54],i=i.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes/4,e=4*((this._nRounds=i+6)+1),n=this._keySchedule=[],s=0;s<e;s++)if(s<i)n[s]=t[s];else{var a=n[s-1];s%i?6<i&&4==s%i&&(a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=a<<8|a>>>24,a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=k[s/i|0]<<24),n[s]=n[s-i]^a}for(t=this._invKeySchedule=[],i=0;i<e;i++)s=e-i,a=i%4?n[s]:n[s-4],t[i]=4>i||4>=s?a:h[r[a>>>24]]^d[r[a>>>16&255]]^c[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,o,u,l,r)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,h,d,c,f,s),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,n,r,s,a,o){for(var u=this._nRounds,l=e[t]^i[0],h=e[t+1]^i[1],d=e[t+2]^i[2],c=e[t+3]^i[3],f=4,_=1;_<u;_++)var p=n[l>>>24]^r[h>>>16&255]^s[d>>>8&255]^a[255&c]^i[f++],m=n[h>>>24]^r[d>>>16&255]^s[c>>>8&255]^a[255&l]^i[f++],v=n[d>>>24]^r[c>>>16&255]^s[l>>>8&255]^a[255&h]^i[f++],c=n[c>>>24]^r[l>>>16&255]^s[h>>>8&255]^a[255&d]^i[f++],l=p,h=m,d=v;p=(o[l>>>24]<<24|o[h>>>16&255]<<16|o[d>>>8&255]<<8|o[255&c])^i[f++],m=(o[h>>>24]<<24|o[d>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^i[f++],v=(o[d>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&h])^i[f++],c=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[h>>>8&255]<<8|o[255&d])^i[f++],e[t]=p,e[t+1]=m,e[t+2]=v,e[t+3]=c},keySize:8});e.AES=t._createHelper(i)}();var n=n||function(e,t){var i={},n=i.lib={},r=function(){},s=n.Base={extend:function(e){r.prototype=this;var t=new r;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,i=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var r=0;r<e;r++)t[n+r>>>2]|=(i[r>>>2]>>>24-r%4*8&255)<<24-(n+r)%4*8;else if(65535<i.length)for(r=0;r<e;r+=4)t[n+r>>>2]=i[r>>>2];else t.push.apply(t,i);return this.sigBytes+=e,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var i=[],n=0;n<t;n+=4)i.push(4294967296*e.random()|0);return new a.init(i,t)}}),o=i.enc={},u=o.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++){var r=t[n>>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(i,t/2)}},l=o.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++)i.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(i,t)}},h=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},d=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i=this._data,n=i.words,r=i.sigBytes,s=this.blockSize,o=r/(4*s),o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0);if(t=o*s,r=e.min(4*t,r),t){for(var u=0;u<t;u+=s)this._doProcessBlock(n,u);u=n.splice(0,t),i.sigBytes-=r}return new a.init(u,r)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=d.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new c.HMAC.init(e,i).finalize(t)}}});var c=i.algo={};return i}(Math);!function(){var e=n,t=e.lib.WordArray;e.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,n=this._map;e.clamp(),e=[];for(var r=0;r<i;r+=3)for(var s=(t[r>>>2]>>>24-r%4*8&255)<<16|(t[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|t[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;4>a&&r+.75*a<i;a++)e.push(n.charAt(s>>>6*(3-a)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var i=e.length,n=this._map,r=n.charAt(64);r&&-1!=(r=e.indexOf(r))&&(i=r);for(var r=[],s=0,a=0;a<i;a++)if(a%4){var o=n.indexOf(e.charAt(a-1))<<a%4*2,u=n.indexOf(e.charAt(a))>>>6-a%4*2;r[s>>>2]|=(o|u)<<24-s%4*8,s++}return t.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,i,n,r,s,a){return((e=e+(t&i|~t&n)+r+a)<<s|e>>>32-s)+t}function i(e,t,i,n,r,s,a){return((e=e+(t&n|i&~n)+r+a)<<s|e>>>32-s)+t}function r(e,t,i,n,r,s,a){return((e=e+(t^i^n)+r+a)<<s|e>>>32-s)+t}function s(e,t,i,n,r,s,a){return((e=e+(i^(t|~n))+r+a)<<s|e>>>32-s)+t}for(var a=n,o=a.lib,u=o.WordArray,l=o.Hasher,o=a.algo,h=[],d=0;64>d;d++)h[d]=4294967296*e.abs(e.sin(d+1))|0;o=o.MD5=l.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,n){for(var a=0;16>a;a++){var o=n+a,u=e[o];e[o]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var a=this._hash.words,o=e[n+0],u=e[n+1],l=e[n+2],d=e[n+3],c=e[n+4],f=e[n+5],_=e[n+6],p=e[n+7],m=e[n+8],v=e[n+9],g=e[n+10],y=e[n+11],b=e[n+12],E=e[n+13],S=e[n+14],k=e[n+15],w=a[0],L=a[1],R=a[2],A=a[3],w=t(w,L,R,A,o,7,h[0]),A=t(A,w,L,R,u,12,h[1]),R=t(R,A,w,L,l,17,h[2]),L=t(L,R,A,w,d,22,h[3]),w=t(w,L,R,A,c,7,h[4]),A=t(A,w,L,R,f,12,h[5]),R=t(R,A,w,L,_,17,h[6]),L=t(L,R,A,w,p,22,h[7]),w=t(w,L,R,A,m,7,h[8]),A=t(A,w,L,R,v,12,h[9]),R=t(R,A,w,L,g,17,h[10]),L=t(L,R,A,w,y,22,h[11]),w=t(w,L,R,A,b,7,h[12]),A=t(A,w,L,R,E,12,h[13]),R=t(R,A,w,L,S,17,h[14]),L=t(L,R,A,w,k,22,h[15]),w=i(w,L,R,A,u,5,h[16]),A=i(A,w,L,R,_,9,h[17]),R=i(R,A,w,L,y,14,h[18]),L=i(L,R,A,w,o,20,h[19]),w=i(w,L,R,A,f,5,h[20]),A=i(A,w,L,R,g,9,h[21]),R=i(R,A,w,L,k,14,h[22]),L=i(L,R,A,w,c,20,h[23]),w=i(w,L,R,A,v,5,h[24]),A=i(A,w,L,R,S,9,h[25]),R=i(R,A,w,L,d,14,h[26]),L=i(L,R,A,w,m,20,h[27]),w=i(w,L,R,A,E,5,h[28]),A=i(A,w,L,R,l,9,h[29]),R=i(R,A,w,L,p,14,h[30]),L=i(L,R,A,w,b,20,h[31]),w=r(w,L,R,A,f,4,h[32]),A=r(A,w,L,R,m,11,h[33]),R=r(R,A,w,L,y,16,h[34]),L=r(L,R,A,w,S,23,h[35]),w=r(w,L,R,A,u,4,h[36]),A=r(A,w,L,R,c,11,h[37]),R=r(R,A,w,L,p,16,h[38]),L=r(L,R,A,w,g,23,h[39]),w=r(w,L,R,A,E,4,h[40]),A=r(A,w,L,R,o,11,h[41]),R=r(R,A,w,L,d,16,h[42]),L=r(L,R,A,w,_,23,h[43]),w=r(w,L,R,A,v,4,h[44]),A=r(A,w,L,R,b,11,h[45]),R=r(R,A,w,L,k,16,h[46]),L=r(L,R,A,w,l,23,h[47]),w=s(w,L,R,A,o,6,h[48]),A=s(A,w,L,R,p,10,h[49]),R=s(R,A,w,L,S,15,h[50]),L=s(L,R,A,w,f,21,h[51]),w=s(w,L,R,A,b,6,h[52]),A=s(A,w,L,R,d,10,h[53]),R=s(R,A,w,L,g,15,h[54]),L=s(L,R,A,w,u,21,h[55]),w=s(w,L,R,A,m,6,h[56]),A=s(A,w,L,R,k,10,h[57]),R=s(R,A,w,L,_,15,h[58]),L=s(L,R,A,w,E,21,h[59]),w=s(w,L,R,A,c,6,h[60]),A=s(A,w,L,R,y,10,h[61]),R=s(R,A,w,L,l,15,h[62]),L=s(L,R,A,w,v,21,h[63]);a[0]=a[0]+w|0,a[1]=a[1]+L|0,a[2]=a[2]+R|0,a[3]=a[3]+A|0},_doFinalize:function(){var t=this._data,i=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;i[r>>>5]|=128<<24-r%32;var s=e.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(i.length+1),this._process(),t=this._hash,i=t.words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var e=l.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=l._createHelper(o),a.HmacMD5=l._createHmacHelper(o)}(Math),function(){var e=n,t=e.lib,i=t.Base,r=t.WordArray,t=e.algo,s=t.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,n=i.hasher.create(),s=r.create(),a=s.words,o=i.keySize,i=i.iterations;a.length<o;){u&&n.update(u);var u=n.update(e).finalize(t);n.reset();for(var l=1;l<i;l++)u=n.finalize(u),n.reset();s.concat(u)}return s.sigBytes=4*o,s}});e.EvpKDF=function(e,t,i){return s.create(i).compute(e,t)}}(),n.lib.Cipher||function(e){var t=n,i=t.lib,r=i.Base,s=i.WordArray,a=i.BufferedBlockAlgorithm,o=t.enc.Base64,u=t.algo.EvpKDF,l=i.Cipher=a.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(e){return{encrypt:function(t,i,n){return("string"==typeof i?p:_).encrypt(e,t,i,n)},decrypt:function(t,i,n){return("string"==typeof i?p:_).decrypt(e,t,i,n)}}}});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=t.mode={},d=function(e,t,i){var n=this._iv;n?this._iv=void 0:n=this._prevBlock;for(var r=0;r<i;r++)e[t+r]^=n[r]},c=(i.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}})).extend();c.Encryptor=c.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;d.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),c.Decryptor=c.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,r=e.slice(t,t+n);i.decryptBlock(e,t),d.call(this,e,t,n),this._prevBlock=r}}),h=h.CBC=c,c=(t.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,i=i-e.sigBytes%i,n=i<<24|i<<16|i<<8|i,r=[],a=0;a<i;a+=4)r.push(n);i=s.create(r,i),e.concat(i)},unpad:function(e){e.sigBytes-=255&e.words[e.sigBytes-1>>>2]}},i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:h,padding:c}),reset:function(){l.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var f=i.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return e=e.salt,(e?s.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){e=o.parse(e);var t=e.words;if(1398893684==t[0]&&1701076831==t[1]){var i=s.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return f.create({ciphertext:e,salt:i})}},_=i.SerializableCipher=r.extend({cfg:r.extend({format:h}),encrypt:function(e,t,i,n){n=this.cfg.extend(n);var r=e.createEncryptor(i,n);return t=r.finalize(t),r=r.cfg,f.create({ciphertext:t,key:i,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,i,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(i,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,i,n){return n||(n=s.random(8)),e=u.create({keySize:t+i}).compute(e,n),i=s.create(e.words.slice(t),4*i),e.sigBytes=4*t,f.create({key:e,iv:i,salt:n})}},p=i.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:t}),encrypt:function(e,t,i,n){return n=this.cfg.extend(n),i=n.kdf.execute(i,e.keySize,e.ivSize),n.iv=i.iv,e=_.encrypt.call(this,e,t,i.key,n),e.mixIn(i),e},decrypt:function(e,t,i,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),i=n.kdf.execute(i,e.keySize,e.ivSize,t.salt),n.iv=i.iv,_.decrypt.call(this,e,t,i.key,n)}})}(),function(){function e(){for(var e=this._S,t=this._i,i=this._j,n=0,r=0;4>r;r++){var t=(t+1)%256,i=(i+e[t])%256,s=e[t];e[t]=e[i],e[i]=s,n|=e[(e[t]+e[i])%256]<<24-8*r}return this._i=t,this._j=i,n}var t=n,i=t.lib.StreamCipher,r=t.algo,s=r.RC4=i.extend({_doReset:function(){for(var e=this._key,t=e.words,e=e.sigBytes,i=this._S=[],n=0;256>n;n++)i[n]=n;for(var r=n=0;256>n;n++){var s=n%e,r=(r+i[n]+(t[s>>>2]>>>24-s%4*8&255))%256,s=i[n];i[n]=i[r],i[r]=s}this._i=this._j=0},_doProcessBlock:function(t,i){t[i]^=e.call(this)},keySize:8,ivSize:0});t.RC4=i._createHelper(s),r=r.RC4Drop=s.extend({cfg:s.cfg.extend({drop:192}),_doReset:function(){s._doReset.call(this);for(var t=this.cfg.drop;0<t;t--)e.call(this)}}),t.RC4Drop=i._createHelper(r)}(),n.pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){for(var t=e.words,i=e.sigBytes-1;!(t[i>>>2]>>>24-i%4*8&255);)i--;e.sigBytes=i+1}};var n=n||function(e,t){var i={},n=i.lib={},r=function(){},s=n.Base={extend:function(e){r.prototype=this;var t=new r;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,i=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var r=0;r<e;r++)t[n+r>>>2]|=(i[r>>>2]>>>24-r%4*8&255)<<24-(n+r)%4*8;else if(65535<i.length)for(r=0;r<e;r+=4)t[n+r>>>2]=i[r>>>2];else t.push.apply(t,i);return this.sigBytes+=e,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var i=[],n=0;n<t;n+=4)i.push(4294967296*e.random()|0);return new a.init(i,t)}}),o=i.enc={},u=o.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++){var r=t[n>>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(i,t/2)}},l=o.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var i=[],n=0;n<e;n++)i.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return i.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(i,t)}},h=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},d=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i=this._data,n=i.words,r=i.sigBytes,s=this.blockSize,o=r/(4*s),o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0);if(t=o*s,r=e.min(4*t,r),t){for(var u=0;u<t;u+=s)this._doProcessBlock(n,u);u=n.splice(0,t),i.sigBytes-=r}return new a.init(u,r)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=d.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new c.HMAC.init(e,i).finalize(t)}}});var c=i.algo={};return i}(Math);!function(e){function t(e,t,i,n,r,s,a){return((e=e+(t&i|~t&n)+r+a)<<s|e>>>32-s)+t}function i(e,t,i,n,r,s,a){return((e=e+(t&n|i&~n)+r+a)<<s|e>>>32-s)+t}function r(e,t,i,n,r,s,a){return((e=e+(t^i^n)+r+a)<<s|e>>>32-s)+t}function s(e,t,i,n,r,s,a){return((e=e+(i^(t|~n))+r+a)<<s|e>>>32-s)+t}for(var a=n,o=a.lib,u=o.WordArray,l=o.Hasher,o=a.algo,h=[],d=0;64>d;d++)h[d]=4294967296*e.abs(e.sin(d+1))|0;o=o.MD5=l.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,n){for(var a=0;16>a;a++){var o=n+a,u=e[o];e[o]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var a=this._hash.words,o=e[n+0],u=e[n+1],l=e[n+2],d=e[n+3],c=e[n+4],f=e[n+5],_=e[n+6],p=e[n+7],m=e[n+8],v=e[n+9],g=e[n+10],y=e[n+11],b=e[n+12],E=e[n+13],S=e[n+14],k=e[n+15],w=a[0],L=a[1],R=a[2],A=a[3],w=t(w,L,R,A,o,7,h[0]),A=t(A,w,L,R,u,12,h[1]),R=t(R,A,w,L,l,17,h[2]),L=t(L,R,A,w,d,22,h[3]),w=t(w,L,R,A,c,7,h[4]),A=t(A,w,L,R,f,12,h[5]),R=t(R,A,w,L,_,17,h[6]),L=t(L,R,A,w,p,22,h[7]),w=t(w,L,R,A,m,7,h[8]),A=t(A,w,L,R,v,12,h[9]),R=t(R,A,w,L,g,17,h[10]),L=t(L,R,A,w,y,22,h[11]),w=t(w,L,R,A,b,7,h[12]),A=t(A,w,L,R,E,12,h[13]),R=t(R,A,w,L,S,17,h[14]),L=t(L,R,A,w,k,22,h[15]),w=i(w,L,R,A,u,5,h[16]),A=i(A,w,L,R,_,9,h[17]),R=i(R,A,w,L,y,14,h[18]),L=i(L,R,A,w,o,20,h[19]),w=i(w,L,R,A,f,5,h[20]),A=i(A,w,L,R,g,9,h[21]),R=i(R,A,w,L,k,14,h[22]),L=i(L,R,A,w,c,20,h[23]),w=i(w,L,R,A,v,5,h[24]),A=i(A,w,L,R,S,9,h[25]),R=i(R,A,w,L,d,14,h[26]),L=i(L,R,A,w,m,20,h[27]),w=i(w,L,R,A,E,5,h[28]),A=i(A,w,L,R,l,9,h[29]),R=i(R,A,w,L,p,14,h[30]),L=i(L,R,A,w,b,20,h[31]),w=r(w,L,R,A,f,4,h[32]),A=r(A,w,L,R,m,11,h[33]),R=r(R,A,w,L,y,16,h[34]),L=r(L,R,A,w,S,23,h[35]),w=r(w,L,R,A,u,4,h[36]),A=r(A,w,L,R,c,11,h[37]),R=r(R,A,w,L,p,16,h[38]),L=r(L,R,A,w,g,23,h[39]),w=r(w,L,R,A,E,4,h[40]),A=r(A,w,L,R,o,11,h[41]),R=r(R,A,w,L,d,16,h[42]),L=r(L,R,A,w,_,23,h[43]),w=r(w,L,R,A,v,4,h[44]),A=r(A,w,L,R,b,11,h[45]),R=r(R,A,w,L,k,16,h[46]),L=r(L,R,A,w,l,23,h[47]),w=s(w,L,R,A,o,6,h[48]),A=s(A,w,L,R,p,10,h[49]),R=s(R,A,w,L,S,15,h[50]),L=s(L,R,A,w,f,21,h[51]),w=s(w,L,R,A,b,6,h[52]),A=s(A,w,L,R,d,10,h[53]),R=s(R,A,w,L,g,15,h[54]),L=s(L,R,A,w,u,21,h[55]),w=s(w,L,R,A,m,6,h[56]),A=s(A,w,L,R,k,10,h[57]),R=s(R,A,w,L,_,15,h[58]),L=s(L,R,A,w,E,21,h[59]),w=s(w,L,R,A,c,6,h[60]),A=s(A,w,L,R,y,10,h[61]),R=s(R,A,w,L,l,15,h[62]),L=s(L,R,A,w,v,21,h[63]);a[0]=a[0]+w|0,a[1]=a[1]+L|0,a[2]=a[2]+R|0,a[3]=a[3]+A|0},_doFinalize:function(){var t=this._data,i=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;i[r>>>5]|=128<<24-r%32;var s=e.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(i.length+1),this._process(),t=this._hash,i=t.words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var e=l.clone.call(this);return e._hash=this._hash.clone(),e}}),a.MD5=l._createHelper(o),a.HmacMD5=l._createHmacHelper(o)}(Math),n.enc.u8array={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=new Uint8Array(i),r=0;r<i;r++){var s=t[r>>>2]>>>24-r%4*8&255;n[r]=s}return t=i=null,n},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e[r])<<24-r%4*8;var s=n.lib.WordArray.create(i,t);return i=null,s}};var r={};r.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)})},r.rc4=function(){this._skd=null,this._key=null,this._iv=null,this.init=function(e){if(this._skd=new Uint8Array(256),this._key=e,e.length<16)for(var t=e.length;t<16;t++)e+="0";else e.length>16&&(e=e.substring(0,16));var t,i,n=this._skd,r=0;for(t=0;t<256;t++)n[t]=t;for(t=0;t<256;t++)r=(r+n[t]+e.charCodeAt(t%e.length))%256,i=n[t],n[t]=n[r],n[r]=i},this.decrypt=function(e){var t,i,n,r=0,s=0,a=this._skd,o=new Uint8Array(e.length);for(n=0;n<o.length;n++)r=(r+1)%256,t=a[r],s=(s+t)%256,i=a[s],a[r]=i,a[s]=t,o[n]=e[n]^a[(t+i)%256];return o}},r.aes=function(){this.init=function(e,t){this._key=e,this._iv=t},this.decrypt=function(e){if(this._key&&this._iv){var t=this._key;if(t.length<16&&t.length>0)for(var i=t.length;i<16;i++)t+="0";else t.length>16&&(t=t.substring(0,16));var r=n.enc.Utf8.parse(t),s=n.enc.Utf8.parse(this._iv),a=n.enc.u8array.parse(e),o=n.AES.decrypt(n.enc.Base64.stringify(a),r,{iv:s,mode:n.mode.CBC,padding:n.pad.ZeroPadding}),u=n.enc.u8array.stringify(o);return o=r=a=s=null,u}return e}},r.Digest=function(e,t,i,r,s,a,o,u,l,h){var d=new Uint8Array(32),c=new Uint8Array(32),f=function(e,t){var i,n;for(i=0;i<16;i++)n=e[i]>>4&15,t[2*i]=n<=9?n+48:n+97-10,n=15&e[i],t[2*i+1]=n<=9?n+48:n+97-10;t[32]=0},_=n.algo.MD5.create();_.update(e),_.update(":"),_.update(r),_.update(":"),_.update(t);var p=_.finalize();"md5-sess"==i&&(_=n.algo.MD5.create(),_.update(n.enc.u8array.stringify(p)),_.update(":"),_.update(s),_.update(":"),_.update(a),p=_.finalize()),f(n.enc.u8array.stringify(p),d),p=null,_=null;var m=new Uint8Array(32),_=n.algo.MD5.create();_.update(u),_.update(":"),_.update(l),"auth-int"==h&&(_.update(":"),_.update(m));var v=_.finalize(),g=new Uint8Array(32);f(n.enc.u8array.stringify(v),g);var y=n.algo.MD5.create();y.update(n.enc.u8array.parse(d)),y.update(":"),y.update(s),y.update(":"),h&&(y.update(o),y.update(":"),y.update(a),y.update(":"),y.update(h),y.update(":")),y.update(n.enc.u8array.parse(g));var b=y.finalize();f(n.enc.u8array.stringify(b),c),_=null,y=null,b=null,v=null,g=null,p=null;for(var E="",S=0;S<c.length;S++)E+=String.fromCharCode(c[S]);return E},i.default=r},{}],16:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("../utils/logger.js"),o=n(a),u=e("../utils/utf8-conv.js"),l=n(u),h=e("../utils/exception.js"),d=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),c=function(){function e(){r(this,e)}return s(e,null,[{key:"parseScriptData",value:function(t,i,n){var r={};try{var s=e.parseValue(t,i,n),a=e.parseValue(t,i+s.size,n-s.size);r[s.data]=a.data}catch(e){o.default.e("AMF",e.toString())}return r}},{key:"parseObject",value:function(t,i,n){if(n<3)throw new h.IllegalStateException("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,n),s=e.parseValue(t,i+r.size,n-r.size),a=s.objectEnd;return{data:{name:r.data,value:s.data},size:r.size+s.size,objectEnd:a}}},{key:"parseVariable",value:function(t,i,n){return e.parseObject(t,i,n)}},{key:"parseString",value:function(e,t,i){if(i<2)throw new h.IllegalStateException("Data not enough when parse String");var n=new DataView(e,t,i),r=n.getUint16(0,!d),s=void 0;return s=r>0?(0,l.default)(new Uint8Array(e,t+2,r)):"",{data:s,size:2+r}}},{key:"parseLongString",value:function(e,t,i){if(i<4)throw new h.IllegalStateException("Data not enough when parse LongString");var n=new DataView(e,t,i),r=n.getUint32(0,!d),s=void 0;return s=r>0?(0,l.default)(new Uint8Array(e,t+4,r)):"",{data:s,size:4+r}}},{key:"parseDate",value:function(e,t,i){if(i<10)throw new h.IllegalStateException("Data size invalid when parse Date");var n=new DataView(e,t,i),r=n.getFloat64(0,!d);return r+=60*n.getInt16(8,!d)*1e3,{data:new Date(r),size:10}}},{key:"parseValue",value:function(t,i,n){if(n<1)throw new h.IllegalStateException("Data not enough when parse Value");var r=new DataView(t,i,n),s=1,a=r.getUint8(0),u=void 0,l=!1;try{switch(a){case 0:u=r.getFloat64(1,!d),s+=8;break;case 1:u=!!r.getUint8(1),s+=1;break;case 2:var c=e.parseString(t,i+1,n-1);u=c.data,s+=c.size;break;case 3:u={};var f=0;for(9==(16777215&r.getUint32(n-4,!d))&&(f=3);s<n-4;){var _=e.parseObject(t,i+s,n-s-f);if(_.objectEnd)break;u[_.data.name]=_.data.value,s+=_.size}if(s<=n-3){9===(16777215&r.getUint32(s-1,!d))&&(s+=3)}break;case 8:u={},s+=4;var p=0;for(9==(16777215&r.getUint32(n-4,!d))&&(p=3);s<n-8;){var m=e.parseVariable(t,i+s,n-s-p);if(m.objectEnd)break;u[m.data.name]=m.data.value,s+=m.size}if(s<=n-3){9===(16777215&r.getUint32(s-1,!d))&&(s+=3)}break;case 9:u=void 0,s=1,l=!0;break;case 10:u=[];var v=r.getUint32(1,!d);s+=4;for(var g=0;g<v;g++){var y=e.parseValue(t,i+s,n-s);u.push(y.data),s+=y.size}break;case 11:var b=e.parseDate(t,i+1,n-1);u=b.data,s+=b.size;break;case 12:var E=e.parseString(t,i+1,n-1);u=E.data,s+=E.size;break;default:s=n,o.default.w("AMF","Unsupported AMF value type "+a)}}catch(e){o.default.e("AMF",e.toString())}return{data:u,size:s,objectEnd:l}}}]),e}();i.default=c},{"../utils/exception.js":41,"../utils/logger.js":42,"../utils/utf8-conv.js":45}],17:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};i.default=n},{}],18:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("../utils/exception.js"),a=function(){function e(t){n(this,e),this.TAG="ExpGolomb",this._buffer=t,this._buffer_index=0,this._total_bytes=t.byteLength,this._total_bits=8*t.byteLength,this._current_word=0,this._current_word_bits_left=0}return r(e,[{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 t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}},{key:"readBits",value:function(e){if(e>32)throw new s.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var i=this._current_word_bits_left?this._current_word:0;i>>>=32-this._current_word_bits_left;var n=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(n,this._current_word_bits_left),a=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,i=i<<r|a}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readByte",value:function(){return this.readBits(8)}},{key:"_skipLeadingZero",value:function(){var e=void 0;for(e=0;e<this._current_word_bits_left;e++)if(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}();i.default=a},{"../utils/exception.js":41}],19:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}Object.defineProperty(i,"__esModule",{value:!0});var a="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},o=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),u=e("../utils/logger.js"),l=n(u),h=e("./amf-parser.js"),d=n(h),c=e("./sps-parser.js"),f=n(c),_=e("./demux-errors.js"),p=n(_),m=e("../core/media-info.js"),v=n(m),g=e("../utils/exception.js"),y=e("../crypto/crypto.js"),b=n(y),E=e("../remux/aac-silent.js"),S=n(E),k=function(){function e(t,i){r(this,e),this.TAG="FLVDemuxer",this._config=i,this._onError=null,this._onMediaInfo=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=t.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=t.hasAudioTrack,this._hasVideo=t.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new v.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:25,fps_num:25e3,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),this._lastTagType=0,this._enableDecrypt=!1,this._rc4=new b.default.rc4,this._rc4.init(this._config.password),this._aes=new b.default.aes,this._aes.init(this._config.password,"0000000000000000"),this._inputSilent=this._hasAudio}return o(e,[{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._onTrackMetadata=null,this._onDataAvailable=null,this._enableDecrypt=!1,this._rc4=null,this._aes=null}},{key:"bindDataSource",value:function(e){return e.onDataArrival=this.parseChunks.bind(this),this}},{key:"resetMediaInfo",value:function(){this._mediaInfo=new v.default}},{key:"_isInitialMetadataDispatched",value:function(){return this._hasVideo&&this._videoInitialMetadataDispatched}},{key:"parseChunks",value:function(t,i){
- if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new g.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var n=0,r=this._littleEndian;if(0===i){if(!(t.byteLength>13))return 0;n=e.probe(t).dataOffset}if(this._firstParse){this._firstParse=!1,i+n!==this._dataOffset&&l.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");0!==new DataView(t,n).getUint32(0,!r)&&l.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4}for(;n<t.byteLength;){this._dispatch=!0;var s=new DataView(t,n);if(n+11+4>t.byteLength)break;var a=s.getUint8(0),o=16777215&s.getUint32(0,!r);if(n+11+o+4>t.byteLength)break;if(8===a||9===a||18===a){var u=s.getUint8(4),h=s.getUint8(5),d=s.getUint8(6),c=s.getUint8(7);c>63&&(c=0);var f=d|h<<8|u<<16|c<<24;0!==(16777215&s.getUint32(7,!r))&&l.default.w(this.TAG,"Meet tag which has StreamID != 0!");var _=n+11;switch(a){case 8:this._parseAudioData(t,_,o,f);break;case 9:this._parseVideoData(t,_,o,f,i+n);break;case 18:this._parseScriptData(t,_,o)}var p=s.getUint32(11+o,!r);p!==11+o&&l.default.w(this.TAG,"Invalid PrevTagSize "+p),n+=11+o+4}else l.default.w(this.TAG,"Unsupported tag type "+a+", skipped"),n+=11+o+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n}},{key:"_parseScriptData",value:function(e,t,i){var n=d.default.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!==a(n.onMetaData))return void l.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&l.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var r=this._metadata.onMetaData;if("boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio,this._inputSilent=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var s=Math.floor(r.duration*this._timescale);this._duration=s,this._mediaInfo.duration=s}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var o=Math.floor(1e3*r.framerate);if(o>0){var u=o/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=u,this._referenceFrameRate.fps_num=o,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=u}}if("object"===a(r.keyframes)){this._mediaInfo.hasKeyframesIndex=!0;var h=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(h),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;if(this._dispatch=!1,this._mediaInfo.metadata=r,l.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo),this._hasAudio){var c={};c.type="audio",c.id=2,c.timescale=1e3,c.duration=this._mediaInfo.duration,c.audioSampleRate=8e3,c.channelCount=1,c.codec="mp4a.40.5",c.originalCodec="mp4a.40.2",c.config=[45,1420,8,0],c.refSampleDuration=1024/c.audioSampleRate*c.timescale,this._dispatch=!1,this._onTrackMetadata("audio",c)}}}},{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)return void l.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0!==this._hasAudioFlagOverrided||!1!==this._hasAudio){var r=(this._littleEndian,new DataView(e,t,i)),s=r.getUint8(0),a=s>>>4;if(2!==a&&10!==a)return void this._onError(p.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+a);var o=0,u=(12&s)>>>2;if(!(u>=0&&u<=4))return void this._onError(p.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+u);o=this._flvSoundRateTable[u];var h=1&s,d=this._audioMetadata,c=this._audioTrack;if(d||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),d=this._audioMetadata={},d.type="audio",d.id=c.id,d.timescale=this._timescale,d.duration=this._duration,d.audioSampleRate=o,d.channelCount=0===h?1:2),10===a){var f=this._parseAACAudioData(e,t+1,i-1);if(void 0==f)return;if(0===f.packetType){d.config&&l.default.w(this.TAG,"Found another AudioSpecificConfig!");var _=f.data;d.audioSampleRate=_.samplingRate,d.channelCount=_.channelCount,d.codec=_.codec,d.originalCodec=_.originalCodec,d.config=_.config,d.refSampleDuration=1024/d.audioSampleRate*d.timescale,l.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",d);var m=this._mediaInfo;m.audioCodec=d.originalCodec,m.audioSampleRate=d.audioSampleRate,m.audioChannelCount=d.channelCount,m.hasVideo?null!=m.videoCodec&&(m.mimeType='video/x-flv; codecs="'+m.videoCodec+","+m.audioCodec+'"'):m.mimeType='video/x-flv; codecs="'+m.audioCodec+'"',m.isComplete()&&this._onMediaInfo(m)}else if(1===f.packetType){this._inputSilent&&(this._inputSilent=!1);var v=this._timestampBase+n,g={unit:f.data,dts:v,pts:v};c.samples.push(g),c.length+=f.data.length}else l.default.e(this.TAG,"Flv: Unsupported AAC data type "+f.packetType)}else if(2===a){if(!d.codec){var y=this._parseMP3AudioData(e,t+1,i-1,!0);if(void 0==y)return;d.audioSampleRate=y.samplingRate,d.channelCount=y.channelCount,d.codec=y.codec,d.originalCodec=y.originalCodec,d.refSampleDuration=1152/d.audioSampleRate*d.timescale,l.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",d);var b=this._mediaInfo;b.audioCodec=d.codec,b.audioSampleRate=d.audioSampleRate,b.audioChannelCount=d.channelCount,b.audioDataRate=y.bitRate,b.hasVideo?null!=b.videoCodec&&(b.mimeType='video/x-flv; codecs="'+b.videoCodec+","+b.audioCodec+'"'):b.mimeType='video/x-flv; codecs="'+b.audioCodec+'"',b.isComplete()&&this._onMediaInfo(b)}var E=this._parseMP3AudioData(e,t+1,i-1,!1);if(void 0==E)return;var S=this._timestampBase+n,k={unit:E,dts:S,pts:S};c.samples.push(k),c.length+=E.length}}}},{key:"_parseAACAudioData",value:function(e,t,i){if(i<=1)return void l.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");var n={},r=new Uint8Array(e,t,i);return n.packetType=r[0],0===r[0]?n.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):n.data=r.subarray(1),n}},{key:"_parseAACAudioSpecificConfig",value:function(e,t,i){var n=new Uint8Array(e,t,i),r=null,s=0,a=0,o=0,u=null;if(s=a=n[0]>>>3,(o=(7&n[0])<<1|n[1]>>>7)<0||o>=this._mpegSamplingRates.length)return void this._onError(p.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");var l=this._mpegSamplingRates[o],h=(120&n[1])>>>3;if(h<0||h>=8)return void this._onError(p.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===s&&(u=(7&n[1])<<1|n[2]>>>7,n[2]);var d=self.navigator.userAgent.toLowerCase();return-1!==d.indexOf("firefox")?o>=6?(s=5,r=new Array(4),u=o-3):(s=2,r=new Array(2),u=o):-1!==d.indexOf("android")?(s=2,r=new Array(2),u=o):(s=5,u=o,r=new Array(4),o>=6?u=o-3:1===h&&(s=2,r=new Array(2),u=o)),r[0]=s<<3,r[0]|=(15&o)>>>1,r[1]=(15&o)<<7,r[1]|=(15&h)<<3,5===s&&(r[1]|=(15&u)>>>1,r[2]=(1&u)<<7,r[2]|=8,r[3]=0),{config:r,samplingRate:l,channelCount:h,codec:"mp4a.40."+s,originalCodec:"mp4a.40."+a}}},{key:"_parseMP3AudioData",value:function(e,t,i,n){if(i<4)return void l.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");var r=(this._littleEndian,new Uint8Array(e,t,i)),s=null;if(n){if(255!==r[0])return;var a=r[1]>>>3&3,o=(6&r[1])>>1,u=(240&r[2])>>>4,h=(12&r[2])>>>2,d=r[3]>>>6&3,c=3!==d?2:1,f=0,_=0;switch(a){case 0:f=this._mpegAudioV25SampleRateTable[h];break;case 2:f=this._mpegAudioV20SampleRateTable[h];break;case 3:f=this._mpegAudioV10SampleRateTable[h]}switch(o){case 1:34,u<this._mpegAudioL3BitRateTable.length&&(_=this._mpegAudioL3BitRateTable[u]);break;case 2:33,u<this._mpegAudioL2BitRateTable.length&&(_=this._mpegAudioL2BitRateTable[u]);break;case 3:32,u<this._mpegAudioL1BitRateTable.length&&(_=this._mpegAudioL1BitRateTable[u])}s={bitRate:_,samplingRate:f,channelCount:c,codec:"mp3",originalCodec:"mp3"}}else s=r;return s}},{key:"_parseVideoData",value:function(e,t,i,n,r){if(i<=1)return void l.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){var s=new Uint8Array(e,t,i)[0],a=(240&s)>>>4,o=15&s;if(7!==o)return void this._onError(p.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+o);this._parseAVCVideoPacket(e,t+1,i-1,n,r,a)}}},{key:"_parseAVCVideoPacket",value:function(e,t,i,n,r,s){if(i<4)return void l.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");var a=this._littleEndian,o=new DataView(e,t,i),u=o.getUint8(0),h=16777215&o.getUint32(0,!a);if(0===u)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===u)this._parseAVCVideoData(e,t+4,i-4,n,r,s,h);else if(2!==u)return void this._onError(p.default.FORMAT_ERROR,"Flv: Invalid video packet type "+u)}},{key:"_parseAVCDecoderConfigurationRecord",value:function(e,t,i){if(i<7)return void l.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");var n=this._videoMetadata,r=this._videoTrack,s=this._littleEndian,a=new DataView(e,t,i);n?void 0!==n.avcc&&l.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),n=this._videoMetadata={},n.type="video",n.id=r.id,n.timescale=this._timescale,n.duration=this._duration);var o=a.getUint8(0),u=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==o||0===u)return void this._onError(p.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(p.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));var h=31&a.getUint8(5);if(0===h)return void this._onError(p.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");h>1&&l.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+h);var d=6;this._lastTagType=1,this._config.password&&this._enableDecrypt&&this._rc4.init(this._config.password);for(var c=0,_=0;_<h;_++){var m=a.getUint16(d,!s);if(d+=2,0!==m){if(this._config.password&&this._enableDecrypt){var v=new Uint8Array(e,t+d+1,m-1),g=this._aes.decrypt(v);a.setUint8(d-1,g.length+1,!s),v.set(g),c=g.length-v.length,v=g=null}var y=new Uint8Array(e,t+d,m+c);d+=m;var b=f.default.parseSPS(y);if(0===_){n.codecWidth=b.codec_size.width,n.codecHeight=b.codec_size.height,n.presentWidth=b.present_size.width,n.presentHeight=b.present_size.height,n.profile=b.profile_string,n.profileValue=b.profile_value,n.level=b.level_string,n.bitDepth=b.bit_depth,n.chromaFormat=b.chroma_format,n.sarRatio=b.sar_ratio,n.frameRate=b.frame_rate,!1!==b.frame_rate.fixed&&0!==b.frame_rate.fps_num&&0!==b.frame_rate.fps_den||(n.frameRate=this._referenceFrameRate);var E=n.frameRate.fps_den,S=n.frameRate.fps_num;n.refSampleDuration=n.timescale*(E/S);for(var k=y.subarray(1,4),w="avc1.",L=0;L<3;L++){var R=k[L].toString(16);R.length<2&&(R="0"+R),w+=R}"avc1.640032"==w&&(w="avc1.4d0014"),n.codec=w;var A=this._mediaInfo;A.width=n.codecWidth,A.height=n.codecHeight,A.fps=n.frameRate.fps,A.profile=n.profile,A.level=n.level,A.chromaFormat=b.chroma_format_string,A.sarNum=n.sarRatio.width,A.sarDen=n.sarRatio.height,A.videoCodec=w,A.hasAudio?null!=A.audioCodec&&(A.mimeType='video/x-flv; codecs="'+A.videoCodec+","+A.audioCodec+'"'):A.mimeType='video/x-flv; codecs="'+A.videoCodec+'"',A.isComplete()&&this._onMediaInfo(A)}}}var O=a.getUint8(d);if(0===O)return void this._onError(p.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");O>1&&l.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+O),d++;for(var x=0,T=0;T<O;T++){var C=a.getUint16(d,!s);if(d+=2,0!==C){if(this._config.password&&this._enableDecrypt){var B=new Uint8Array(e,t+d+1,C-1),D=this._aes.decrypt(B);a.setUint8(d-1,D.length+1),B.set(D),x=D.length-B.length,B=D=null}d+=C}}n.avcc=new Uint8Array(i+c+x);var I=new Uint8Array(e,t,i+c+x);if(I[1]!=n.profileValue&&(I[1]=n.profileValue),this._config.password&&this._config.password.length>0&&this._enableDecrypt)for(var M=22;M<29;M++)I[M]=a.getUint8(M+3);n.avcc.set(I,0),l.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",n)}},{key:"_parseAVCVideoData",value:function(e,t,i,n,r,s,a){for(var o=this._littleEndian,u=new DataView(e,t,i),h=[],d=0,c=0,f=this._naluLengthSize,_=this._timestampBase+n,p=1===s;c<i;){if(c+4>=i){l.default.w(this.TAG,"Malformed Nalu near timestamp "+_+", offset = "+c+", dataSize = "+i);break}var m=u.getUint32(c,!o);if(3===f&&(m>>>=8),m>i-f)return void l.default.w(this.TAG,"Malformed Nalus near timestamp "+_+", NaluSize > DataSize!");this._config.password&&this._config.password.length>0&&this._enableDecrypt;var v=31&u.getUint8(c+f);if(5===v&&(p=!0,this._lastTagType=1),this._inputSilent){var g=S.default.getSilentFrame("mp4a.40.2",1),y=this._audioTrack,b={unit:g,dts:_,pts:_,duration:35};y.samples.push(b),y.length+=g.byteLength}var E=0;if(this._config.password&&this._config.password.length>0&&this._enableDecrypt){var k=new Uint8Array(e,t+c+5,f+m-5),w=this._aes.decrypt(k);u.setUint32(c,w.length+1,!o),k.set(w),E=w.length-k.length,k=w=null}var L=new Uint8Array(e,t+c,f+m+E),R={type:v,data:L};h.push(R),d+=L.byteLength,c+=f+m}if(h.length){var A=this._videoTrack,O={units:h,length:d,isKeyframe:p,dts:_,cts:a,pts:_+a};p&&(O.fileposition=r),A.samples.push(O),A.length+=d}}},{key:"enableDecrypt",value:function(e){this._enableDecrypt=e}},{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:"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,this._inputSilent=e}},{key:"overridedHasVideo",set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}}],[{key:"probe",value:function(e){var t=new Uint8Array(e),i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;var n=(4&t[4])>>>2!=0,r=0!=(1&t[4]),a=s(t,5);return a<9?i:{match:!0,consumed:a,dataOffset:a,hasAudioTrack:n,hasVideoTrack:r}}}]),e}();i.default=k},{"../core/media-info.js":7,"../crypto/crypto.js":15,"../remux/aac-silent.js":37,"../utils/exception.js":41,"../utils/logger.js":42,"./amf-parser.js":16,"./demux-errors.js":17,"./sps-parser.js":20}],20:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("./exp-golomb.js"),a=function(e){return e&&e.__esModule?e:{default:e}}(s),o=function(){function e(){n(this,e)}return r(e,null,[{key:"_ebsp2rbsp",value:function(e){for(var t=e,i=t.byteLength,n=new Uint8Array(i),r=0,s=0;s<i;s++)s>=2&&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(t){var i=e._ebsp2rbsp(t),n=new a.default(i);n.readByte();var r=n.readByte();n.readByte();var s=n.readByte();n.readUEG();var o=e.getProfileString(r),u=e.getLevelString(s),l=1,h=420,d=[0,420,422,444],c=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(l=n.readUEG(),3===l&&n.readBits(1),l<=3&&(h=d[l]),c=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool()))for(var f=3!==l?8:12,_=0;_<f;_++)n.readBool()&&(_<6?e._skipScalingList(n,16):e._skipScalingList(n,64));n.readUEG();var p=n.readUEG();if(0===p)n.readUEG();else if(1===p){n.readBits(1),n.readSEG(),n.readSEG();for(var m=n.readUEG(),v=0;v<m;v++)n.readSEG()}n.readUEG(),n.readBits(1);var g=n.readUEG(),y=n.readUEG(),b=n.readBits(1);0===b&&n.readBits(1),n.readBits(1);var E=0,S=0,k=0,w=0;n.readBool()&&(E=n.readUEG(),S=n.readUEG(),k=n.readUEG(),w=n.readUEG());var L=1,R=1,A=0,O=!0,x=0,T=0;if(n.readBool()){if(n.readBool()){var C=n.readByte(),B=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],D=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];C>0&&C<16?(L=B[C-1],R=D[C-1]):255===C&&(L=n.readByte()<<8|n.readByte(),R=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){var I=n.readBits(32),M=n.readBits(32);O=n.readBool(),x=M,T=2*I,A=x/T}}var j=1;1===L&&1===R||(j=L/R);var P=0,U=0;if(0===l)P=1,U=2-b;else{var N=3===l?1:2,F=1===l?2:1;P=N,U=F*(2-b)}var z=16*(g+1),G=16*(y+1)*(2-b);z-=(E+S)*P,G-=(k+w)*U;var V=Math.ceil(z*j);return n.destroy(),n=null,{profile_value:r,profile_string:o,level_string:u,bit_depth:c,chroma_format:h,chroma_format_string:e.getChromaFormatString(h),frame_rate:{fixed:O,fps:A,fps_den:T,fps_num:x},sar_ratio:{width:L,height:R},codec_size:{width:z,height:G},present_size:{width:V,height:G}}}},{key:"_skipScalingList",value:function(e,t){for(var i=8,n=8,r=0,s=0;s<t;s++)0!==n&&(r=e.readSEG(),n=(i+r+256)%256),i=0===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}();i.default=o},{"./exp-golomb.js":18}],21:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var i=e;if(null==i||"object"!==(void 0===i?"undefined":o(i)))throw new E.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new E.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"flv":return new f.default(i,t);case"janusstream":return null;default:return new p.default(i,t)}}function s(){return d.default.supportMSEH264Playback()}function a(){return d.default.getFeatureList()}Object.defineProperty(i,"__esModule",{value:!0});var o="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},u=e("./utils/polyfill.js"),l=n(u),h=e("./core/features.js"),d=n(h),c=e("./player/flv-player.js"),f=n(c),_=e("./player/native-player.js"),p=n(_),m=e("./player/player-events.js"),v=n(m),g=e("./player/player-errors.js"),y=e("./utils/logging-control.js"),b=n(y),E=e("./utils/exception.js");l.default.install();var S={};S.createPlayer=r,S.isSupported=s,S.getFeatureList=a,S.Events=v.default,S.ErrorTypes=g.ErrorTypes,S.ErrorDetails=g.ErrorDetails,S.FlvPlayer=f.default,S.NativePlayer=p.default,S.LoggingControl=b.default,Object.defineProperty(S,"version",{enumerable:!0,get:function(){return"1.3.3"}}),i.default=S},{"./core/features.js":6,"./player/flv-player.js":33,"./player/native-player.js":34,"./player/player-errors.js":35,"./player/player-events.js":36,"./utils/exception.js":41,"./utils/logging-control.js":43,"./utils/polyfill.js":44}],22:[function(e,t,i){"use strict";t.exports=e("./flv.js").default},{"./flv.js":21}],23:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}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)}Object.defineProperty(i,"__esModule",{value:!0});var o="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},u=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(n)},l=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),h=e("../utils/logger.js"),d=(n(h),e("../utils/browser.js")),c=n(d),f=e("./loader.js"),_=e("../utils/exception.js"),p=e("../crypto/crypto.js"),m=n(p),v=function(e){function t(e,i){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"fetch-stream-loader"));return n.TAG="FetchStreamLoader",n._seekHandler=e,n._config=i,n._needStash=!0,n._requestAbort=!1,n._contentLength=null,n._receivedLength=0,n._requestURL="",n._bInvaidPwd=!1,n._authInfo=null,n}return a(t,e),l(t,null,[{key:"isSupported",value:function(){try{var e=c.default.msedge&&c.default.version.minor>=15048,t=!c.default.msedge||e;return self.fetch&&self.ReadableStream&&t&&(!c.default.firefox||c.default.firefox&&c.default.version.major>=68)}catch(e){return!1}}}]),l(t,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"open",value:function(e,t){var i=this;this._dataSource=e,this._range=t,this._receivedLength=0;var n=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(n=e.redirectedURL);var r=this._seekHandler.getConfig(n,t);this._requestURL=r.url;var s=new self.Headers;if("object"===o(r.headers)){var a=r.headers;for(var u in a)a.hasOwnProperty(u)&&s.append(u,a[u])}this._authInfo&&this._authInfo.length?(s.append("Authorization",this._authInfo),this._authInfo=null):(this._config.date&&s.append("x-amz-date",this._config.date),this._config.auth&&s.append("Authorization",this._config.auth));var l={method:"GET",headers:s,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};!1===e.cors&&(l.mode="same-origin"),e.withCredentials&&(l.credentials="include"),e.referrerPolicy&&(l.referrerPolicy=e.referrerPolicy),this._status=f.LoaderStatus.kConnecting,self.fetch(r.url,l).then(function(e){if(i._requestAbort)return i._authInfo=null,i._requestAbort=!1,void(i._status=f.LoaderStatus.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(i._authInfo=null,e.url!==r.url&&i._onURLRedirect){var t=i._seekHandler.removeURLParameters(e.url);i._onURLRedirect(t)}var n=e.headers.get("Content-Length");null!=n&&(i._contentLength=parseInt(n),0!==i._contentLength&&i._onContentLengthKnown&&i._onContentLengthKnown(i._contentLength));var s="true"===e.headers.get("Secretive");return console.log("encrypted ? "+s),i.onOpened(s),i._pump.call(i,e.body.getReader())}if(401==e.status&&!i._bInvaidPwd){(e.redirected||e.url&&e.url.length&&e.url!=i._dataSource.url)&&(i._dataSource.url=i._requestURL=e.url),i._bInvaidPwd=!0;var a=e.headers.get("WWW-Authenticate"),o=a.indexOf('realm="')+7,u=a.substring(o,a.indexOf(",",o)-1);o=a.indexOf('qop="')+5;var l=a.substring(o,a.indexOf(",",o)-1);l.replace('"',""),o=a.indexOf('nonce="')+7;var h=a.substring(o,a.indexOf('"',o));o=a.indexOf('algorithm="')+11;var d=a.substring(o,a.indexOf(",",o)-1),c=i._config.username,p=i._config.password,v=i._requestURL.substring(i._requestURL.indexOf("/",8),i._requestURL.length),g=m.default.generateUUID(),y=m.default.Digest(c,p,d,u,h,g,"00000001","GET",v,l);return i._authInfo='Digest username="'+c+'", realm="'+u+'", nonce="'+h+'", uri="'+v+'", algorithm='+d+', response="'+y+'", opaque="5ccc069c403ebaf9f0171e9517f40e41", qop="'+l+'", nc=00000001, cnonce="'+g+'"',void i.open(i._dataSource,i._range)}if(i._status=f.LoaderStatus.kError,!i._onError)throw new _.RuntimeException("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);i._onError(f.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(function(e){if(i._status=f.LoaderStatus.kError,!i._onError)throw e;i._onError(f.LoaderErrors.EXCEPTION,{code:-1,msg:e.message})})}},{key:"abort",value:function(){this._authInfo=null,this._bInvaidPwd=!1,this._requestAbort=!0,this._reader&&this._reader.cancel()}},{key:"_pump",value:function(e){var t=this;return e.read().then(function(i){if(i.done)t._status=f.LoaderStatus.kComplete,t._onComplete&&t._onComplete(t._range.from,t._range.from+t._receivedLength-1);else{if(!0===t._requestAbort)return t._requestAbort=!1,t._status=f.LoaderStatus.kComplete,e.cancel();c.default.firefox&&!t._reader&&(t._reader=e),t._status=f.LoaderStatus.kBuffering;var n=i.value.buffer,r=t._range.from+t._receivedLength;t._receivedLength+=n.byteLength,t._onDataArrival&&t._onDataArrival(n,r,t._receivedLength),t._pump(e)}}).catch(function(e){if(11!==e.code||!c.default.msedge){t._status=f.LoaderStatus.kError;var i=0,n=null;if(19!==e.code&&"network error"!==e.message||!(null===t._contentLength||null!==t._contentLength&&t._receivedLength<t._contentLength)?(i=f.LoaderErrors.EXCEPTION,n={code:e.code,msg:e.message}):(i=f.LoaderErrors.EARLY_EOF,n={code:e.code,msg:"Fetch stream meet Early-EOF"}),!t._onError)throw new _.RuntimeException(n.msg);t._onError(i,n)}})}}]),t}(f.BaseLoader);i.default=v},{"../crypto/crypto.js":15,"../utils/browser.js":40,"../utils/exception.js":41,"../utils/logger.js":42,"./loader.js":25}],24:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("../utils/logger.js"),o=n(a),u=e("./speed-sampler.js"),l=n(u),h=e("./loader.js"),d=e("./fetch-stream-loader.js"),c=n(d),f=e("./xhr-moz-chunked-loader.js"),_=n(f),p=e("./xhr-msstream-loader.js"),m=(n(p),e("./xhr-range-loader.js")),v=n(m),g=e("./websocket-loader.js"),y=n(g),b=e("./range-seek-handler.js"),E=n(b),S=e("./param-seek-handler.js"),k=n(S),w=e("../utils/exception.js"),L=function(){function e(t,i,n){r(this,e),this.TAG="IOController",this._config=i,this._extraData=n,this._stashInitialSize=393216,void 0!=i.stashInitialSize&&i.stashInitialSize>0&&(this._stashInitialSize=i.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===i.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=t,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(t.url),this._refTotalLength=t.filesize?t.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new l.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return s(e,[{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 E.default(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new k.default(t,i)}else{if("custom"!==e.seekType)throw new w.InvalidArgumentException("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new w.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}},{key:"_selectLoader",value:function(){if(this._isWebSocketURL)this._loaderClass=y.default;else if(c.default.isSupported())this._loaderClass=c.default;else if(_.default.isSupported())this._loaderClass=_.default;else{if(!v.default.isSupported())throw new w.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=v.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),this._loader.onOpened=this._onIOOpened.bind(this)}},{key:"open",value:function(e){this._currentRange={from:0,to:-1},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(){
- if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}},{key:"resumeTime",value:function(e){this._paused&&(this._paused=!1,this._resumeFrom=0,this._internalSeekTime(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;var 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._loader._range.from=0,this._onSeeked&&this._onSeeked()}},{key:"_internalSeekTime",value:function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var i={from:0,to:-1,time:e};this._currentRange={from:i.from,to:-1,time:e},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._loader._range.from=0,this.updateUrl(this._loader._requestURL),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(e){if(!e||"string"!=typeof e||0===e.length)throw new w.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=e,console.log("update url "+e)}},{key:"_expandBuffer",value:function(e){for(var t=this._stashSize;t+1048576<e;)t*=2;if((t+=1048576)!==this._bufferSize){var i=new ArrayBuffer(t);if(this._stashUsed>0){var n=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(n,0)}this._stashBuffer=i,this._bufferSize=t}}},{key:"_normalizeSpeed",value:function(e){var t=this._speedNormalizeList,i=t.length-1,n=0,r=0,s=i;if(e<t[0])return t[0];for(;r<=s;){if((n=r+Math.floor((s-r)/2))===i||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?r=n+1:s=n-1}}},{key:"_adjustStashSize",value:function(e){var t=0;(t=this._config.isLive?e:e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var i=1024*t+1048576;this._bufferSize<i&&this._expandBuffer(i),this._stashSize=1024*t}},{key:"_dispatchChunks",value:function(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}},{key:"_onIOOpened",value:function(e){this.onOpened&&this.onOpened(e)}},{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){if(!this._onDataArrival)throw new w.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused)if(this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength),this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){var n=new Uint8Array(this._stashBuffer,0,this._stashSize);n.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{var r=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var s=this._stashBuffer.slice(0,this._stashUsed),a=this._dispatchChunks(s,this._stashByteStart);if(a<s.byteLength){if(a>0){var o=new Uint8Array(s,a);r.set(o,0),this._stashUsed=o.byteLength,this._stashByteStart+=a}}else 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}else{var u=this._dispatchChunks(e,t);if(u<e.byteLength){var l=e.byteLength-u;l>this._bufferSize&&(this._expandBuffer(l),r=new Uint8Array(this._stashBuffer,0,this._bufferSize)),r.set(new Uint8Array(e,u),0),this._stashUsed+=l,this._stashByteStart=t+u}}}else if(0===this._stashUsed){var h=this._dispatchChunks(e,t);if(h<e.byteLength){var d=e.byteLength-h;d>this._bufferSize&&this._expandBuffer(d);var c=new Uint8Array(this._stashBuffer,0,this._bufferSize);c.set(new Uint8Array(e,h),0),this._stashUsed+=d,this._stashByteStart=t+h}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);var f=new Uint8Array(this._stashBuffer,0,this._bufferSize);f.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;var _=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(_<this._stashUsed&&_>0){var p=new Uint8Array(this._stashBuffer,_);f.set(p,0)}this._stashUsed-=_,this._stashByteStart+=_}}},{key:"_flushStashBuffer",value:function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-i;if(i<t.byteLength){if(!e){if(i>0){var r=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);r.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}o.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(o.default.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=h.LoaderErrors.UNRECOVERABLE_EARLY_EOF),e){case h.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=this._currentRange.to+1;return void(i<this._totalLength&&(o.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(i,!1)))}e=h.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break;case h.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case h.LoaderErrors.CONNECTING_TIMEOUT:case h.LoaderErrors.HTTP_STATUS_CODE_INVALID:case h.LoaderErrors.EXCEPTION:}if(!this._onError)throw new w.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||void 0!=this._dataSource.redirectedURL}},{key:"currentRedirectedURL",get:function(){return this._redirectedURL||this._dataSource.redirectedURL}},{key:"currentSpeed",get:function(){return this._loaderClass===v.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}},{key:"loaderType",get:function(){return this._loader.type}}]),e}();i.default=L},{"../utils/exception.js":41,"../utils/logger.js":42,"./fetch-stream-loader.js":23,"./loader.js":25,"./param-seek-handler.js":26,"./range-seek-handler.js":27,"./speed-sampler.js":28,"./websocket-loader.js":29,"./xhr-moz-chunked-loader.js":30,"./xhr-msstream-loader.js":31,"./xhr-range-loader.js":32}],25:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0}),i.BaseLoader=i.LoaderErrors=i.LoaderStatus=void 0;var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("../utils/exception.js"),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=function(){function e(t){n(this,e),this._type=t||"undefined",this._status=a.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return r(e,[{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}}]),e}()},{"../utils/exception.js":41}],26:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){return(Array(t).join("0")+e).slice(-t)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=function(){function e(t,i){n(this,e),this._startName=t,this._endName=i}return s(e,[{key:"getConfig",value:function(e,t){var i=e,n=i;if(t&&t.time){var s=t.time/1e3,a=i.indexOf("starttime=")+10,o=i.substring(a,a+15),u=(i.substring(0,a),i.substring(a+15,i.length),o.substring(0,4)),l=o.substring(4,6),h=o.substring(6,8),d=o.substring(9,11),c=o.substring(11,13),f=o.substring(13,15),_=new Date(u,l,h,d,c,f,0),p=Date.parse(_);p+=1e3*s;var m=new Date(p),v=r(m.getFullYear(),4)+r(m.getMonth(),2)+r(m.getDate(),2)+"T"+r(m.getHours(),2)+r(m.getMinutes(),2)+r(m.getSeconds(),2);n=n.replace(o,v)}return{url:n,headers:null}}},{key:"removeURLParameters",value:function(e){return e}}]),e}();i.default=a},{}],27:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function e(t){n(this,e),this._zeroStart=t||!1}return r(e,[{key:"getConfig",value:function(e,t){var i={};if(0!==t.from||-1!==t.to){var n=void 0;n=-1!==t.to?"bytes="+t.from.toString()+"-"+t.to.toString():"bytes="+t.from.toString()+"-",i.Range=n}else this._zeroStart&&(i.Range="bytes=0-");return{url:e,headers:i}}},{key:"removeURLParameters",value:function(e){return e}}]),e}();i.default=s},{}],28:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function e(){n(this,e),this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return r(e,[{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 0==e&&(e=1),this._intervalBytes/e/1024}},{key:"lastSecondKBps",get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}}]),e}();i.default=s},{}],29:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}Object.defineProperty(i,"__esModule",{value:!0});var a=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(n)},o=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),u=e("../utils/logger.js"),l=(function(e){e&&e.__esModule}(u),e("./loader.js")),h=e("../utils/exception.js"),d=function(e){function t(){n(this,t);var e=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"websocket-loader"));return e.TAG="WebSocketLoader",e._needStash=!0,e._ws=null,e._requestAbort=!1,e._receivedLength=0,e}return s(t,e),o(t,null,[{key:"isSupported",value:function(){try{return void 0!==self.WebSocket}catch(e){return!1}}}]),o(t,[{key:"destroy",value:function(){this._ws&&this.abort(),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"open",value:function(e){try{var t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=l.LoaderStatus.kConnecting}catch(e){this._status=l.LoaderStatus.kError;var i={code:e.code,msg:e.message};if(!this._onError)throw new h.RuntimeException(i.msg);this._onError(l.LoaderErrors.EXCEPTION,i)}}},{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=l.LoaderStatus.kComplete}},{key:"_onWebSocketOpen",value:function(e){this._status=l.LoaderStatus.kBuffering}},{key:"_onWebSocketClose",value:function(e){if(!0===this._requestAbort)return void(this._requestAbort=!1);this._status=l.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)}},{key:"_onWebSocketMessage",value:function(e){var t=this;if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){var i=new FileReader;i.onload=function(){t._dispatchArrayBuffer(i.result)},i.readAsArrayBuffer(e.data)}else{this._status=l.LoaderStatus.kError;var n={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new h.RuntimeException(n.msg);this._onError(l.LoaderErrors.EXCEPTION,n)}}},{key:"_dispatchArrayBuffer",value:function(e){var t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},{key:"_onWebSocketError",value:function(e){this._status=l.LoaderStatus.kError;var t={code:e.code,msg:e.message};if(!this._onError)throw new h.RuntimeException(t.msg);this._onError(l.LoaderErrors.EXCEPTION,t)}}]),t}(l.BaseLoader);i.default=d},{"../utils/exception.js":41,"../utils/logger.js":42,"./loader.js":25}],30:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}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)}Object.defineProperty(i,"__esModule",{value:!0});var o="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},u=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(n)},l=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),h=e("../utils/logger.js"),d=n(h),c=e("./loader.js"),f=e("../utils/exception.js"),_=e("../crypto/crypto.js"),p=n(_),m=function(e){function t(e,i){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"xhr-moz-chunked-loader"));return n.TAG="MozChunkedLoader",n._seekHandler=e,n._config=i,n._needStash=!0,n._xhr=null,n._requestAbort=!1,n._contentLength=null,n._receivedLength=0,n._requestURL="",n._bInvaidPwd=!1,n}return a(t,e),l(t,null,[{key:"isSupported",value:function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return d.default.w("MozChunkedLoader",e.message),!1}}}]),l(t,[{key:"destroy",value:function(){this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"open",value:function(e,t){this._dataSource=e,this._range=t,this._receivedLength=0;var i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);var n=this._seekHandler.getConfig(i,t);this._requestURL=n.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",n.url,!0),r.responseType="moz-chunked-arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onloadend=this._onLoadEnd.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&r.withCredentials&&(r.withCredentials=!0),"object"===o(n.headers)){var s=n.headers;for(var a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a,s[a])}this._config.date&&r.setRequestHeader("x-amz-date",this._config.date),this._config.auth&&r.setRequestHeader("Authorization",this._config.auth),this._status=c.LoaderStatus.kConnecting,r.send()}},{key:"abort",value:function(){this._bInvaidPwd=!1,this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=c.LoaderStatus.kComplete}},{key:"_onReadyStateChange",value:function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL&&t.responseURL!==this._requestURL&&t.responseURL.length)return;if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=c.LoaderStatus.kError,!this._onError)throw new f.RuntimeException("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(c.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else{this._status=c.LoaderStatus.kBuffering;var i="true"===t.getResponseHeader("Secretive");this.onOpened(i)}}}},{key:"_onProgress",value:function(e){if(this._status!==c.LoaderStatus.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}}},{key:"_onLoadEnd",value:function(e){if(401==e.target.status&&!this._bInvaidPwd){this._bInvaidPwd=!0;var t=e.target.getResponseHeader("WWW-Authenticate"),i=t.indexOf('realm="')+7,n=t.substring(i,t.indexOf(",",i)-1);i=t.indexOf('qop="')+5;var r=t.substring(i,t.indexOf(",",i)-1);r.replace('"',""),i=t.indexOf('nonce="')+7;var s=t.substring(i,t.indexOf('"',i));i=t.indexOf('algorithm="')+11;var a=t.substring(i,t.indexOf(",",i)-1),o=this._config.username,u=this._config.password,l=this._requestURL.substring(this._requestURL.indexOf("/",8),this._requestURL.length),h=p.default.generateUUID(),d=p.default.Digest(o,u,a,n,s,h,"00000001","GET",l,r);this.abort();var f=this._xhr=new XMLHttpRequest;return f.open("GET",this._requestURL,!0),f.responseType="moz-chunked-arraybuffer",f.onreadystatechange=this._onReadyStateChange.bind(this),f.onprogress=this._onProgress.bind(this),f.onloadend=this._onLoadEnd.bind(this),f.onerror=this._onXhrError.bind(this),f.withCredentials=!0,t='Digest username="'+o+'", realm="'+n+'", nonce="'+s+'", uri="'+l+'", algorithm='+a+', response="'+d+'", opaque="5ccc069c403ebaf9f0171e9517f40e41", qop="'+r+'", nc=00000001, cnonce="'+h+'"',f.setRequestHeader("Authorization",t),void f.send()}if(!0===this._requestAbort)return void(this._requestAbort=!1);this._status!==c.LoaderStatus.kError&&(this._status=c.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1),this._receivedLength<=0&&200==e.target.status?this._onError&&this._onError("error",{code:-999,msg:"no stream , server disconnected"}):this._onError&&this._onError(c.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.target.status,msg:e.target.statusText}))}},{key:"_onXhrError",value:function(e){this._status=c.LoaderStatus.kError;var t=0,i=null;if(this._contentLength&&e.loaded<this._contentLength?(t=c.LoaderErrors.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=c.LoaderErrors.EXCEPTION,this._receivedLength?(this._receivedLength=0,i={code:-999,msg:"no stream , server disconnected , try to reconnect"}):i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new f.RuntimeException(i.msg);this._onError(t,i)}}]),t}(c.BaseLoader);i.default=m},{"../crypto/crypto.js":15,"../utils/exception.js":41,"../utils/logger.js":42,"./loader.js":25}],31:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(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)}Object.defineProperty(i,"__esModule",{value:!0});var a="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},o=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(n)},u=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),l=e("../utils/logger.js"),h=function(e){return e&&e.__esModule?e:{default:e}}(l),d=e("./loader.js"),c=e("../utils/exception.js"),f=function(e){function t(e,i){n(this,t);var s=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"xhr-msstream-loader"));return s.TAG="MSStreamLoader",s._seekHandler=e,s._config=i,s._needStash=!0,s._xhr=null,s._reader=null,s._totalRange=null,s._currentRange=null,s._currentRequestURL=null,s._currentRedirectedURL=null,s._contentLength=null,s._receivedLength=0,s._bufferLimit=16777216,s._lastTimeBufferSize=0,s._isReconnecting=!1,s}return s(t,e),u(t,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","ms-stream"===e.responseType}catch(e){return h.default.w("MSStreamLoader",e.message),!1}}}]),u(t,[{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),o(t.prototype.__proto__||Object.getPrototypeOf(t.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 n=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?n=this._currentRedirectedURL:void 0!=e.redirectedURL&&(n=e.redirectedURL));var r=this._seekHandler.getConfig(n,t);this._currentRequestURL=r.url;var s=this._reader=new self.MSStreamReader;s.onprogress=this._msrOnProgress.bind(this),s.onload=this._msrOnLoad.bind(this),s.onerror=this._msrOnError.bind(this);var o=this._xhr=new XMLHttpRequest;if(o.open("GET",r.url,!0),o.responseType="ms-stream",o.onreadystatechange=this._xhrOnReadyStateChange.bind(this),o.onerror=this._xhrOnError.bind(this),e.withCredentials&&(o.withCredentials=!0),"object"===a(r.headers)){var u=r.headers;for(var l in u)u.hasOwnProperty(l)&&o.setRequestHeader(l,u[l])}this._isReconnecting?this._isReconnecting=!1:this._status=d.LoaderStatus.kConnecting,o.send()}},{key:"abort",value:function(){this._internalAbort(),this._status=d.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){var t=e.target;if(2===t.readyState)if(t.status>=200&&t.status<=299){if(this._status=d.LoaderStatus.kBuffering,void 0!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}var n=t.getResponseHeader("Content-Length");if(null!=n&&null==this._contentLength){var r=parseInt(n);r>0&&(this._contentLength=r,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else{if(this._status=d.LoaderStatus.kError,!this._onError)throw new c.RuntimeException("MSStreamLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(d.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else if(3===t.readyState&&t.status>=200&&t.status<=299){this._status=d.LoaderStatus.kBuffering;var s=t.response;this._reader.readAsArrayBuffer(s)}}},{key:"_xhrOnError",value:function(e){this._status=d.LoaderStatus.kError;var t=d.LoaderErrors.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type};if(!this._onError)throw new c.RuntimeException(i.msg);this._onError(t,i)}},{key:"_msrOnProgress",value:function(e){var t=e.target,i=t.result;if(null==i)return void this._doReconnectIfNeeded();var n=i.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=i.byteLength;var r=this._totalRange.from+this._receivedLength;this._receivedLength+=n.byteLength,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),i.byteLength>=this._bufferLimit&&(h.default.v(this.TAG,"MSStream buffer exceeded max size near "+(r+n.byteLength)+", reconnecting..."),this._doReconnectIfNeeded())}},{key:"_doReconnectIfNeeded",value:function(){if(null==this._contentLength||this._receivedLength<this._contentLength){this._isReconnecting=!0,this._lastTimeBufferSize=0,this._internalAbort();var e={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,e,!0)}}},{key:"_msrOnLoad",value:function(e){this._status=d.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)}},{key:"_msrOnError",value:function(e){this._status=d.LoaderStatus.kError;var t=0,i=null;if(this._contentLength&&this._receivedLength<this._contentLength?(t=d.LoaderErrors.EARLY_EOF,i={code:-1,msg:"MSStream meet Early-Eof"}):(t=d.LoaderErrors.EARLY_EOF,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new c.RuntimeException(i.msg);this._onError(t,i)}}]),t}(d.BaseLoader);i.default=f},{"../utils/exception.js":41,"../utils/logger.js":42,"./loader.js":25}],32:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}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)}Object.defineProperty(i,"__esModule",{value:!0});var o="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},u=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(n)},l=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}
- }(),h=e("../utils/logger.js"),d=n(h),c=e("./speed-sampler.js"),f=n(c),_=e("./loader.js"),p=e("../utils/exception.js"),m=function(e){function t(e,i){r(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"xhr-range-loader"));return n.TAG="RangeLoader",n._seekHandler=e,n._config=i,n._needStash=!1,n._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],n._currentChunkSizeKB=384,n._currentSpeedNormalized=0,n._zeroSpeedChunkCount=0,n._xhr=null,n._speedSampler=new f.default,n._requestAbort=!1,n._waitForTotalLength=!1,n._totalLengthReceived=!1,n._currentRequestURL=null,n._currentRedirectedURL=null,n._currentRequestRange=null,n._totalLength=null,n._contentLength=null,n._receivedLength=0,n._lastTimeLoaded=0,n}return a(t,e),l(t,null,[{key:"isSupported",value:function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return d.default.w("RangeLoader",e.message),!1}}}]),l(t,[{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),u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"open",value:function(e,t){this._dataSource=e,this._range=t,this._status=_.LoaderStatus.kConnecting;var i=!1;void 0!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(i=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||i?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,i=t+e;null!=this._contentLength&&i-this._range.from>=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)}},{key:"_internalOpen",value:function(e,t){this._lastTimeLoaded=0;var i=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?i=this._currentRedirectedURL:void 0!=e.redirectedURL&&(i=e.redirectedURL));var n=this._seekHandler.getConfig(i,t);this._currentRequestURL=n.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",n.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&&(r.withCredentials=!0),"object"===o(n.headers)){var s=n.headers;for(var a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a,s[a])}r.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=_.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.target;if(2===t.readyState){if(void 0!=t.responseURL){var i=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&i!==this._currentRedirectedURL&&(this._currentRedirectedURL=i,this._onURLRedirect&&this._onURLRedirect(i))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=_.LoaderStatus.kBuffering}else{if(this._status=_.LoaderStatus.kError,!this._onError)throw new p.RuntimeException("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(_.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}},{key:"_onProgress",value:function(e){if(this._status!==_.LoaderStatus.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var 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)}var n=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(n)}}},{key:"_normalizeSpeed",value:function(e){var t=this._chunkSizeKBList,i=t.length-1,n=0,r=0,s=i;if(e<t[0])return t[0];for(;r<=s;){if((n=r+Math.floor((s-r)/2))===i||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?r=n+1:s=n-1}}},{key:"_onLoad",value:function(e){if(this._status!==_.LoaderStatus.kError){if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;var t=this._speedSampler.lastSecondKBps;if(0===t&&++this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps),0!==t){var i=this._normalizeSpeed(t);this._currentSpeedNormalized!==i&&(this._currentSpeedNormalized=i,this._currentChunkSizeKB=i)}var n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;var s=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():s=!0,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),s&&(this._status=_.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}}},{key:"_onXhrError",value:function(e){this._status=_.LoaderStatus.kError;var t=0,i=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=_.LoaderErrors.EARLY_EOF,i={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=_.LoaderErrors.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new p.RuntimeException(i.msg);this._onError(t,i)}},{key:"currentSpeed",get:function(){return this._speedSampler.lastSecondKBps}}]),t}(_.BaseLoader);i.default=m},{"../utils/exception.js":41,"../utils/logger.js":42,"./loader.js":25,"./speed-sampler.js":28}],33:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s="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},a=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=e("events"),u=n(o),l=e("../utils/logger.js"),h=n(l),d=e("../utils/browser.js"),c=n(d),f=e("./player-events.js"),_=n(f),p=e("../core/transmuxer.js"),m=n(p),v=e("../core/transmuxing-events.js"),g=n(v),y=e("../core/mse-controller.js"),b=n(y),E=e("../core/mse-events.js"),S=n(E),k=e("./player-errors.js"),w=e("../config.js"),L=e("../utils/exception.js"),R=function(){function e(t,i){if(r(this,e),this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new u.default,this._config=(0,w.createDefaultConfig)(),"object"===(void 0===i?"undefined":s(i))&&Object.assign(this._config,i),"flv"!==t.type.toLowerCase())throw new L.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");!0===t.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),onvTimeUpdate:this._onvTimeUpdate.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=t,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null,this._processStateCount=0;var n=c.default.chrome&&(c.default.version.major<50||50===c.default.version.major&&c.default.version.build<2661);this._alwaysSeekKeyframe=!!(n||c.default.msedge||c.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1),this._streamTimer=null}return a(e,[{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.removeAllListeners(),this._emitter=null,this._processStateCount=0}},{key:"on",value:function(e,t){var i=this;e===_.default.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(function(){i._emitter.emit(_.default.MEDIA_INFO,i.mediaInfo)}):e===_.default.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(function(){i._emitter.emit(_.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._processStateCount=0,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),e.addEventListener("timeupdate",this.e.onvTimeUpdate),this._msectl=new b.default(this._config),this._msectl.on(S.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(S.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(S.default.SOURCE_OPEN,function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())}),this._msectl.on(S.default.ERROR,function(e){t._emitter.emit(_.default.ERROR,k.ErrorTypes.MEDIA_ERROR,k.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.removeEventListener("timeupdate",this.e.onvTimeUpdate),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null),this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=null)}},{key:"load",value:function(){var e=this;if(!this._mediaElement)throw new L.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new L.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");if(!this._hasPendingLoad){if(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened)return void(this._hasPendingLoad=!0);this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new m.default(this._mediaDataSource,this._config),this._transmuxer.on(g.default.INIT_SEGMENT,function(t,i){e._msectl.appendInitSegment(i)}),this._transmuxer.on(g.default.MEDIA_SEGMENT,function(t,i){if(e._msectl.appendMediaSegment(i),e._config.lazyLoad&&!e._config.isLive){var n=e._mediaElement.currentTime;i.info.endDts>=1e3*(n+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(h.default.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}}),this._transmuxer.on(g.default.LOADING_COMPLETE,function(){e._msectl.endOfStream(),e._emitter.emit(_.default.LOADING_COMPLETE)}),this._transmuxer.on(g.default.RECOVERED_EARLY_EOF,function(){e._emitter.emit(_.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(g.default.IO_ERROR,function(t,i){e._emitter.emit(_.default.ERROR,k.ErrorTypes.NETWORK_ERROR,t,i)}),this._transmuxer.on(g.default.DEMUX_ERROR,function(t,i){e._emitter.emit(_.default.ERROR,k.ErrorTypes.MEDIA_ERROR,t,{code:-1,msg:i})}),this._transmuxer.on(g.default.MEDIA_INFO,function(t){e._mediaInfo=t,e._emitter.emit(_.default.MEDIA_INFO,Object.assign({},t))}),this._transmuxer.on(g.default.STATISTICS_INFO,function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(_.default.STATISTICS_INFO,Object.assign({},e._statisticsInfo))}),this._transmuxer.on(g.default.RECOMMEND_SEEKPOINT,function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)}),this._transmuxer.open()}}},{key:"unload",value:function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"resume",value:function(e){if(e&&(this._mediaDataSource.url=e),this._config.isLive){var t=this._mediaElement;this.unload(),this.detachMediaElement(),this.attachMediaElement(t),this.load(),this.play()}else{var i=function(e,t){return(Array(t).join("0")+e).slice(-t)},n=this._mediaDataSource.url,r=this._mediaElement.currentTime,s=n.indexOf("starttime=")+10,a=n.substring(s,s+15),o=(n.substring(0,s),n.substring(s+15,n.length),a.substring(0,4)),u=a.substring(4,6),l=a.substring(6,8),h=a.substring(9,11),d=a.substring(11,13),c=a.substring(13,15),f=new Date(o,u,l,h,d,c,0),_=Date.parse(f);_+=1e3*r;var p=new Date(_),m=i(p.getFullYear(),4)+i(p.getMonth(),2)+i(p.getDate(),2)+"T"+i(p.getHours(),2)+i(p.getMinutes(),2)+i(p.getSeconds(),2);n=n.replace(a,m),console.log("zlplayer resume playback currenttime "+this._mediaElement.currentTime+" timestamp "+_+" with url"+n);var v=this._mediaDataSource;this._config;v.url=n;var g=this._mediaElement;this.unload(),this.detachMediaElement(),this.attachMediaElement(g),this.load(),this.play()}}},{key:"_fillStatisticsInfo",value:function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e}},{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){r,i=s;break}}i>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(h.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}},{key:"_onmseBufferFull",value:function(){h.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}},{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(){var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1;if(this._config.lazyLoad)for(var n=0;n<t.length;n++){var r=t.start(n),s=t.end(n);if(e>=r&&e<s){e>=s-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(h.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(e>=n&&e<r)return!0}return!1}},{key:"_internalSeek",value:function(e){var t=this._isTimepointBuffered(e),i=!1,n=0;if(e<1&&this._mediaElement.buffered.length>0){var r=this._mediaElement.buffered.start(0);(r<1&&e<r||c.default.safari)&&(i=!0,n=c.default.safari?.1:r)}if(i)this._requestSetTime=!0,this._mediaElement.currentTime=n;else if(t){if(this._alwaysSeekKeyframe){var s=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=s?s.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else 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(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var 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))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},{key:"_checkAndResumeStuckPlayback",value:function(e){var t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){var i=t.buffered;if(i.length>0&&t.currentTime<i.start(0))return h.default.w(this.TAG,"Playback seems stuck at "+t.currentTime+", seek to "+i.start(0)),this._requestSetTime=!0,void(this._mediaElement.currentTime=i.start(0))}if(this._config.isLive&&this._receivedCanPlay){if(t.readyState>2&&this._config.isLive){var n=t.buffered;if(n.length>0){var r=n.end(n.length-1);r>this._mediaElement.currentTime+3&&this._mediaElement.playbackRate<1.2?(console.log("checked buffer is more than 3s, play fast to reduce delay"),this._mediaElement.playbackRate=1.5):r<this._mediaElement.currentTime+1&&this._mediaElement.playbackRate>1.2&&(console.log("checked buffer is less than 1 s, play with normal speed"),this._mediaElement.playbackRate=1)}}if(this._streamTimeFlag=(new Date).getTime(),!this._streamTimer&&this._config.isLive&&this._mediaElement.readyState>2&&(this._streamTimer=setInterval(function(){(new Date).getTime()-this._streamTimeFlag>5e3&&(console.warn("zlplayer: stream timeout(5000ms) replay it"),this._emitter.emit(_.default.ERROR,k.ErrorTypes.MEDIA_ERROR,k.ErrorDetails.NEED_REPLAY,"stream timeout need replay"))}.bind(this),3e3)),++this._processStateCount>10&&(console.warn("zlplayer: checked play stucked"),this._config.isLive)){var s=this._mediaElement.buffered;if(s.length>0){var a=s.end(s.length-1);a>this._mediaElement.currentTime+1&&(console.log("zlplayer: seek to buffered time "+a),this._mediaElement.currentTime=a)}}}}},{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)return void(this._requestSetTime=!1);if(t<1&&i.length>0){var n=i.start(0);if(n<1&&t<n||c.default.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=c.default.safari?.1:n)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){var r=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=r&&(this._requestSetTime=!0,this._mediaElement.currentTime=r.dts/1e3)}return void(null!=this._progressChecker&&this._checkProgressAndResume())}}},{key:"_onvCanPlay",value:function(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}},{key:"_onvStalled",value:function(e){this._checkAndResumeStuckPlayback(!0)}},{key:"_onvProgress",value:function(e){this._checkAndResumeStuckPlayback()}},{key:"_onvTimeUpdate",value:function(e){this._processStateCount=0}},{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}();i.default=R},{"../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":40,"../utils/exception.js":41,"../utils/logger.js":42,"./player-errors.js":35,"./player-events.js":36,events:2}],34:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s="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},a=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=e("events"),u=n(o),l=e("./player-events.js"),h=n(l),d=e("../config.js"),c=e("../utils/exception.js"),f=function(){function e(t,i){if(r(this,e),this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new u.default,this._config=(0,d.createDefaultConfig)(),"object"===(void 0===i?"undefined":s(i))&&Object.assign(this._config,i),"flv"===t.type.toLowerCase())throw new c.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(t.hasOwnProperty("segments"))throw new c.InvalidArgumentException("NativePlayer("+t.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=t,this._mediaElement=null}return a(e,[{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===h.default.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(function(){i._emitter.emit(h.default.MEDIA_INFO,i.mediaInfo)}):e===h.default.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(function(){i._emitter.emit(h.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,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 c.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}},{key:"unload",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),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(h.default.MEDIA_INFO,this.mediaInfo)}},{key:"_reportStatisticsInfo",value:function(){this._emitter.emit(h.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=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}},{key:"statisticsInfo",get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();i=r.totalVideoFrames,n=r.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e}}]),e}();i.default=f},{"../config.js":5,"../utils/exception.js":41,"./player-events.js":36,events:2}],35:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ErrorDetails=i.ErrorTypes=void 0;var n=e("../io/loader.js"),r=e("../demux/demux-errors.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(r);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:s.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:s.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:s.default.CODEC_UNSUPPORTED,NEED_REPLAY:"NeedReplay"}},{"../demux/demux-errors.js":17,"../io/loader.js":25}],36:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info"};i.default=n},{}],37:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function e(){n(this,e)}return r(e,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}}]),e}();i.default=s},{}],38:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function e(){n(this,e)}return r(e,null,[{key:"init",value:function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(var t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=e.constants={};i.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),i.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),i.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSC=i.STCO=i.STTS,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.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]),i.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]),i.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.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),i[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(t){var i=e.box(e.types.ftyp,e.constants.FTYP),n=e.moov(t),r=new Uint8Array(i.byteLength+n.byteLength);return r.set(i,0),r.set(n,i.byteLength),r}},{key:"moov",value:function(t){var i=e.mvhd(t.timescale,t.duration),n=e.trak(t),r=e.mvex(t);return e.box(e.types.moov,i,n,r)}},{key:"mvhd",value:function(t,i){
- return e.box(e.types.mvhd,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,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(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"tkhd",value:function(t){var i=t.id,n=t.duration,r=t.presentWidth,s=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))}},{key:"mdhd",value:function(t){var i=t.timescale,n=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}},{key:"hdlr",value:function(t){var i=null;return i="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,i)}},{key:"minf",value:function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))}},{key:"dinf",value:function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))}},{key:"stsd",value:function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))}},{key:"mp3",value:function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types[".mp3"],r)}},{key:"mp4a",value:function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types.mp4a,r,e.esds(t))}},{key:"esds",value:function(t){var i=t.config||[],n=i.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)}},{key:"avc1",value:function(t){var i=t.avcc,n=t.codecWidth,r=t.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>>8&255,255&n,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,s,e.box(e.types.avcC,i))}},{key:"mvex",value:function(t){return e.box(e.types.mvex,e.trex(t))}},{key:"trex",value:function(t){var i=t.id,n=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,n)}},{key:"moof",value:function(t,i){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,i))}},{key:"mfhd",value:function(t){var i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,i)}},{key:"traf",value:function(t,i){var n=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),s=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),a=e.sdtp(t),o=e.trun(t,a.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,s,o,a)}},{key:"sdtp",value:function(t){for(var i=t.samples||[],n=i.length,r=new Uint8Array(4+n),s=0;s<n;s++){var a=i[s].flags;r[s+4]=a.isLeading<<6|a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return e.box(e.types.sdtp,r)}},{key:"trun",value:function(t,i){var n=t.samples||[],r=n.length,s=12+16*r,a=new Uint8Array(s);i+=8+s,a.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var o=0;o<r;o++){var u=n[o].duration,l=n[o].size,h=n[o].flags,d=n[o].cts;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.isNonSync,0,0,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*o)}return e.box(e.types.trun,a)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();s.init(),i.default=s},{}],39:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("../utils/logger.js"),o=n(a),u=e("./mp4-generator.js"),l=n(u),h=e("./aac-silent.js"),d=n(h),c=e("../utils/browser.js"),f=n(c),_=e("../core/media-segment-info.js"),p=e("../utils/exception.js"),m=function(){function e(t){r(this,e),this.TAG="MP4Remuxer",this._config=t,this._isLive=!0===t.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new _.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new _.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!f.default.chrome||!(f.default.version.major<50||50===f.default.version.major&&f.default.version.build<2661)),this._fillSilentAfterSeek=f.default.msedge||f.default.msie,this._mp3UseMpegAudio=!f.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return s(e,[{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}},{key:"insertDiscontinuity",value:function(){this._audioNextDts=this._videoNextDts=void 0}},{key:"seek",value:function(e){this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}},{key:"remux",value:function(e,t){if(!this._onMediaSegment)throw new p.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)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",r="",i=new Uint8Array):i=l.default.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=l.default.generateInitSegment(t)}if(!this._onInitSegment)throw new p.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:"_remuxAudio",value:function(e){if(null!=this._audioMeta){var t=e,i=t.samples,n=void 0,r=-1,s=-1,a=this._audioMeta.refSampleDuration,u="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,h=this._dtsBaseInited&&void 0===this._audioNextDts,c=!1;if(i&&0!==i.length){var p=0,m=null,v=0;u?(p=0,v=t.length):(p=8,v=8+t.length);var g=i[0].dts-this._dtsBase;if(this._audioNextDts)n=g-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())n=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(c=!0);else{var y=this._audioSegmentInfoList.getLastSampleBefore(g);if(null!=y){var b=g-(y.originalDts+y.duration);b<=3&&(b=0);var E=y.dts+y.duration+b;n=g-E}else n=0}if(c){var S=g-n,k=this._videoSegmentInfoList.getLastSegmentBefore(g);if(null!=k&&k.beginDts<S){var w=d.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(w){var L=k.beginDts,R=S-k.beginDts;o.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+L+", duration: "+R),i.unshift({unit:w,dts:L,pts:L}),v+=w.byteLength}}else c=!1}for(var A=[],O=0;O<i.length;O++){var x=i[O],T=x.unit,C=x.dts-this._dtsBase,B=C-n;this.lastAudioDts||(this.lastAudioDts=C),C-this.lastAudioDts>3e3&&this.meanAudioDuration>0&&(C=this.lastAudioDts+this.meanAudioDuration,B=C),this.lastAudioDts=C,-1===r&&(r=B);var D=0;if(this.meanAudioDuration||(this.meanAudioDuration=0),O!==i.length-1){D=i[O+1].dts-this._dtsBase-n-B}else D=A.length>=1?A[A.length-1].duration:Math.floor(a);D<1e3&&D>0?this.meanAudioDuration=(this.meanAudioDuration+D)/2:D=this.meanAudioDuration;var I=!1,M=null;if(D>1.5*a&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!f.default.safari){I=!0;var j=Math.abs(D-a),P=Math.ceil(j/a),U=B+a;o.default.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: "+(B+D)+" ms, expected: "+(B+Math.round(a))+" ms, delta: "+Math.round(j)+" ms, generate: "+P+" frames");var N=d.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==N&&(o.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),N=T),M=[];for(var F=0;F<P;F++){var z=Math.round(U);if(M.length>0){var G=M[M.length-1];G.duration=z-G.dts}var V={dts:z,pts:z,cts:0,unit:N,size:N.byteLength,duration:0,originalDts:C,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};M.push(V),v+=T.byteLength,U+=a}var H=M[M.length-1];H.duration=B+D-H.dts,D=Math.round(a)}A.push({dts:B,pts:B,cts:0,unit:x.unit,size:x.unit.byteLength,duration:D,originalDts:C,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),I&&A.push.apply(A,M)}u?m=new Uint8Array(v):(m=new Uint8Array(v),m[0]=v>>>24&255,m[1]=v>>>16&255,m[2]=v>>>8&255,m[3]=255&v,m.set(l.default.types.mdat,4));for(var q=0;q<A.length;q++){var K=A[q].unit;m.set(K,p),p+=K.byteLength}var W=A[A.length-1];s=W.dts+W.duration,this._audioNextDts=s;var X=new _.MediaSegmentInfo;X.beginDts=r,X.endDts=s,X.beginPts=r,X.endPts=s,X.originalBeginDts=A[0].originalDts,X.originalEndDts=W.originalDts+W.duration,X.firstSample=new _.SampleInfo(A[0].dts,A[0].pts,A[0].duration,A[0].originalDts,!1),X.lastSample=new _.SampleInfo(W.dts,W.pts,W.duration,W.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(X),t.samples=A,t.sequenceNumber++;var Y=null;Y=u?new Uint8Array:l.default.moof(t,r),t.samples=[],t.length=0;var Z={type:"audio",data:this._mergeBoxes(Y,m).buffer,sampleCount:A.length,info:X};u&&h&&(Z.timestampOffset=r),this._onMediaSegment("audio",Z)}}}},{key:"_remuxVideo",value:function(e){if(null!=this._videoMeta){var t=e,i=t.samples,n=void 0,r=-1,s=-1,a=-1,o=-1;if(i&&0!==i.length){var u=8,h=8+e.length,d=new Uint8Array(h);d[0]=h>>>24&255,d[1]=h>>>16&255,d[2]=h>>>8&255,d[3]=255&h,d.set(l.default.types.mdat,4);var c=i[0].dts-this._dtsBase;if(this._videoNextDts)n=c-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())n=0;else{var f=this._videoSegmentInfoList.getLastSampleBefore(c);if(null!=f){var p=c-(f.originalDts+f.duration);p<=3&&(p=0);var m=f.dts+f.duration+p;n=c-m}else n=0}for(var v=new _.MediaSegmentInfo,g=[],y=0;y<i.length;y++){this.meanVideoDuration||(this.meanVideoDuration=0);var b=i[y],E=b.dts-this._dtsBase,S=b.isKeyframe,k=E-n,w=b.cts,L=k+w;this.lastVideoDts||(this.lastVideoDts=E),E-this.lastVideoDts>3e3&&this.meanVideoDuration>0&&(E=this.lastVideoDts+this.meanVideoDuration,k=E,L=k+w),this.lastVideoDts=E,-1===r&&(r=k,a=L);var R=0;if(y!==i.length-1){R=i[y+1].dts-this._dtsBase-n-k}else R=g.length>=1?g[g.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(R<1e3&&R>0?this.meanVideoDuration=(this.meanVideoDuration+R)/2:R=this.meanVideoDuration,S){var A=new _.SampleInfo(k,L,R,b.dts,!0);A.fileposition=b.fileposition,v.appendSyncPoint(A)}g.push({dts:k,pts:L,cts:w,units:b.units,size:b.length,isKeyframe:S,duration:R,originalDts:E,flags:{isLeading:0,dependsOn:S?2:1,isDependedOn:S?1:0,hasRedundancy:0,isNonSync:S?0:1}})}for(var O=0;O<g.length;O++)for(var x=g[O].units;x.length;){var T=x.shift(),C=T.data;d.set(C,u),u+=C.byteLength}var B=g[g.length-1];if(s=B.dts+B.duration,o=B.pts+B.duration,this._videoNextDts=s,v.beginDts=r,v.endDts=s,v.beginPts=a,v.endPts=o,v.originalBeginDts=g[0].originalDts,v.originalEndDts=B.originalDts+B.duration,v.firstSample=new _.SampleInfo(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,g[0].isKeyframe),v.lastSample=new _.SampleInfo(B.dts,B.pts,B.duration,B.originalDts,B.isKeyframe),this._isLive||this._videoSegmentInfoList.append(v),t.samples=g,t.sequenceNumber++,this._forceFirstIDR){var D=g[0].flags;D.dependsOn=2,D.isNonSync=0}var I=l.default.moof(t,r);t.samples=[],t.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(I,d).buffer,sampleCount:g.length,info:v})}}}},{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}();i.default=m},{"../core/media-segment-info.js":8,"../utils/browser.js":40,"../utils/exception.js":41,"../utils/logger.js":42,"./aac-silent.js":37,"./mp4-generator.js":38}],40:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={};!function(){var 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)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},s={};if(r.browser){s[r.browser]=!0;var a=r.majorVersion.split(".");s.version={major:parseInt(r.majorVersion,10),string:r.version},a.length>1&&(s.version.minor=parseInt(a[1],10)),a.length>2&&(s.version.build=parseInt(a[2],10))}r.platform&&(s[r.platform]=!0),(s.chrome||s.opr||s.safari)&&(s.webkit=!0),(s.rv||s.iemobile)&&(s.rv&&delete s.rv,r.browser="msie",s.msie=!0),s.edge&&(delete s.edge,r.browser="msedge",s.msedge=!0),s.opr&&(r.browser="opera",s.opera=!0),s.safari&&s.android&&(r.browser="android",s.android=!0),s.name=r.browser,s.platform=r.platform;for(var o in n)n.hasOwnProperty(o)&&delete n[o];Object.assign(n,s)}(),i.default=n},{}],41:[function(e,t,i){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(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 s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=i.RuntimeException=function(){function e(t){s(this,e),this._message=t}return a(e,[{key:"toString",value:function(){return this.name+": "+this.message}},{key:"name",get:function(){return"RuntimeException"}},{key:"message",get:function(){return this._message}}]),e}();i.IllegalStateException=function(e){function t(e){return s(this,t),n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),a(t,[{key:"name",get:function(){return"IllegalStateException"}}]),t}(o),i.InvalidArgumentException=function(e){function t(e){return s(this,t),n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),a(t,[{key:"name",get:function(){return"InvalidArgumentException"}}]),t}(o),i.NotImplementedException=function(e){function t(e){return s(this,t),n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),a(t,[{key:"name",get:function(){return"NotImplementedException"}}]),t}(o)},{}],42:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("events"),a=function(e){return e&&e.__esModule?e:{default:e}}(s),o=function(){function e(){n(this,e)}return r(e,null,[{key:"e",value:function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",n),e.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))}},{key:"i",value:function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",n),e.ENABLE_INFO&&(console.info?console.info(n):console.log(n))}},{key:"w",value:function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",n),e.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))}},{key:"d",value:function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",n),e.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))}},{key:"v",value:function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",n),e.ENABLE_VERBOSE&&console.log(n)}}]),e}();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.default,i.default=o},{events:2}],43:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("events"),o=n(a),u=e("./logger.js"),l=n(u),h=function(){function e(){r(this,e)}return s(e,null,[{key:"getConfig",value:function(){return{globalTag:l.default.GLOBAL_TAG,forceGlobalTag:l.default.FORCE_GLOBAL_TAG,enableVerbose:l.default.ENABLE_VERBOSE,enableDebug:l.default.ENABLE_DEBUG,enableInfo:l.default.ENABLE_INFO,enableWarn:l.default.ENABLE_WARN,enableError:l.default.ENABLE_ERROR,enableCallback:l.default.ENABLE_CALLBACK}}},{key:"applyConfig",value:function(e){l.default.GLOBAL_TAG=e.globalTag,l.default.FORCE_GLOBAL_TAG=e.forceGlobalTag,l.default.ENABLE_VERBOSE=e.enableVerbose,l.default.ENABLE_DEBUG=e.enableDebug,l.default.ENABLE_INFO=e.enableInfo,l.default.ENABLE_WARN=e.enableWarn,l.default.ENABLE_ERROR=e.enableError,l.default.ENABLE_CALLBACK=e.enableCallback}},{key:"_notifyChange",value:function(){var t=e.emitter;if(t.listenerCount("change")>0){var i=e.getConfig();t.emit("change",i)}}},{key:"registerListener",value:function(t){e.emitter.addListener("change",t)}},{key:"removeListener",value:function(t){e.emitter.removeListener("change",t)}},{key:"addLogListener",value:function(t){l.default.emitter.addListener("log",t),l.default.emitter.listenerCount("log")>0&&(l.default.ENABLE_CALLBACK=!0,e._notifyChange())}},{key:"removeLogListener",value:function(t){l.default.emitter.removeListener("log",t),0===l.default.emitter.listenerCount("log")&&(l.default.ENABLE_CALLBACK=!1,e._notifyChange())}},{key:"forceGlobalTag",get:function(){return l.default.FORCE_GLOBAL_TAG},set:function(t){l.default.FORCE_GLOBAL_TAG=t,e._notifyChange()}},{key:"globalTag",get:function(){return l.default.GLOBAL_TAG},set:function(t){l.default.GLOBAL_TAG=t,e._notifyChange()}},{key:"enableAll",get:function(){return l.default.ENABLE_VERBOSE&&l.default.ENABLE_DEBUG&&l.default.ENABLE_INFO&&l.default.ENABLE_WARN&&l.default.ENABLE_ERROR},set:function(t){l.default.ENABLE_VERBOSE=t,l.default.ENABLE_DEBUG=t,l.default.ENABLE_INFO=t,l.default.ENABLE_WARN=t,l.default.ENABLE_ERROR=t,e._notifyChange()}},{key:"enableDebug",get:function(){return l.default.ENABLE_DEBUG},set:function(t){l.default.ENABLE_DEBUG=t,e._notifyChange()}},{key:"enableVerbose",get:function(){return l.default.ENABLE_VERBOSE},set:function(t){l.default.ENABLE_VERBOSE=t,e._notifyChange()}},{key:"enableInfo",get:function(){return l.default.ENABLE_INFO},set:function(t){l.default.ENABLE_INFO=t,e._notifyChange()}},{key:"enableWarn",get:function(){return l.default.ENABLE_WARN},set:function(t){l.default.ENABLE_WARN=t,e._notifyChange()}},{key:"enableError",get:function(){return l.default.ENABLE_ERROR},set:function(t){l.default.ENABLE_ERROR=t,e._notifyChange()}}]),e}();h.emitter=new o.default,i.default=h},{"./logger.js":42,events:2}],44:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(){function t(){n(this,t)}return r(t,null,[{key:"install",value:function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(void 0===e||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(void 0!==n&&null!==n)for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])}return t},"function"!=typeof self.Promise&&e("es6-promise").polyfill()}}]),t}();s.install(),i.default=s},{"es6-promise":1}],45:[function(e,t,i){"use strict";function n(e,t,i){var n=e;if(t+i<n.length){for(;i--;)if(128!=(192&n[++t]))return!1;return!0}return!1}function r(e){for(var t=[],i=e,r=0,s=e.length;r<s;)if(i[r]<128)t.push(String.fromCharCode(i[r])),++r;else{if(i[r]<192);else if(i[r]<224){if(n(i,r,1)){var a=(31&i[r])<<6|63&i[r+1];if(a>=128){t.push(String.fromCharCode(65535&a)),r+=2;continue}}}else if(i[r]<240){if(n(i,r,2)){var o=(15&i[r])<<12|(63&i[r+1])<<6|63&i[r+2];if(o>=2048&&55296!=(63488&o)){t.push(String.fromCharCode(65535&o)),r+=3;continue}}}else if(i[r]<248&&n(i,r,3)){var u=(7&i[r])<<18|(63&i[r+1])<<12|(63&i[r+2])<<6|63&i[r+3];if(u>65536&&u<1114112){u-=65536,t.push(String.fromCharCode(u>>>10|55296)),t.push(String.fromCharCode(1023&u|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")}Object.defineProperty(i,"__esModule",{value:!0}),i.default=r},{}]},{},[22])(22)});
- /*
- *@author liuguifng
- *@date 2018.02.06
- *@package
- *@access public
- *
- */
- class Logger {
- constructor(name, writedb, maxcount) {
- this._name = name ? name : 'ZLLogger';
- this._maxcount = maxcount ? maxcount : 1024 * 1024;
- if (writedb) {
- let result = indexedDB.open(this._name, 1);
- result.onerror = function (event) {
- console.error('ZLLogger open db error');
- };
- result.onsuccess = function (event) {
- // Do something with request.result!
- this._dataBase = event.target.result;
- this._isValid = true;
- }.bind(this);
- result.onupgradeneeded = function (e) {
- let db = e.target.result;
- if (!db.objectStoreNames.contains(this._name)) {
- let store = db.createObjectStore(this._name);
- store.createIndex('name', 'name');
- store.createIndex('tag', 'tag');
- store.createIndex('level', 'level');
- store.createIndex('time', 'time');
- store.createIndex('info', 'info');
- }
- }.bind(this);
- }
- else {
- this._isValid = true;
- }
- }
- write(tag, level, info, showconsole) {
-
- if (!this._isValid) {
- console.warn('invalid ZLLogger');
- return;
- }
- let timeNow = new Date();
- if (this._dataBase) {
- let objectStore = this._dataBase.transaction(this._name, 'readwrite').objectStore(this._name);
- if (objectStore) {
- let countRequest = objectStore.count();
- countRequest.onsuccess = function () {
- if (countRequest.result >= this._maxcount) {
- let keyRangeValue = IDBKeyRange.upperBound((new Date().getTime()));
- let nRemovedCount = 0;
- objectStore.openCursor(keyRangeValue).onsuccess = function (event) {
- let cursor = event.target.result;
- if (cursor) {
- objectStore.delete(cursor.key);
- nRemovedCount++;
- if (nRemovedCount < 100) {
- cursor.continue();
- }
- }
- };
- }
- }.bind(this);
-
- objectStore.put({name: this._name, tag: tag, level: level, time: timeNow.toString(), info: info}, timeNow.getTime());
- }
- }
- if (showconsole) {
- let logfunc = console.log;
- if (level === 'warn') {
- logfunc = console.warn;
- }
- else if (level === 'error') {
- logfunc = console.error;
- }
- logfunc(`[${this._name}][${tag}][${level}][${timeNow.toString()}] ${info}`);
- }
- }
-
- query(timebegin, timeend) {
- if (!this._isValid) {
- console.warn('invalid ZLLogger');
- return;
- }
- let keyRangeValue = IDBKeyRange.bound(timebegin, timeend, true, true);
- let objectStore = this._dataBase.transaction(this._name).objectStore(this._name);
- objectStore.openCursor(keyRangeValue).onsuccess = function (event) {
- let cursor = event.target.result;
- if (cursor) {
- console.log(JSON.stringify(cursor.value));
- cursor.continue();
- }
- };
- }
- clear() {
- console.warn('clear log');
- if (this._dataBase) {
- let store = this._dataBase.transaction(this._name, 'readwrite').objectStore(this._name);
- store.clear();
- }
- }
- }
- /*
- * Copyright (C) 2016 Bilibili. All Rights Reserved.
- *
- * @author zheng qian <xqq@xqq.im>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- let Browser = {};
- function detect() {
- // modified from jquery-browser-plugin
- let ua = self.navigator.userAgent.toLowerCase();
- let match = /(edge)\/([\w.]+)/.exec(ua) ||
- /(opr)[\/]([\w.]+)/.exec(ua) ||
- /(chrome)[ \/]([\w.]+)/.exec(ua) ||
- /(iemobile)[\/]([\w.]+)/.exec(ua) ||
- /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) ||
- /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua) ||
- /(webkit)[ \/]([\w.]+)/.exec(ua) ||
- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
- /(msie) ([\w.]+)/.exec(ua) ||
- ua.indexOf('trident') >= 0 && /(rv)(?::| )([\w.]+)/.exec(ua) ||
- ua.indexOf('compatible') < 0 && /(firefox)[ \/]([\w.]+)/.exec(ua) ||
- [];
- let platform_match = /(ipad)/.exec(ua) ||
- /(ipod)/.exec(ua) ||
- /(windows phone)/.exec(ua) ||
- /(iphone)/.exec(ua) ||
- /(kindle)/.exec(ua) ||
- /(android)/.exec(ua) ||
- /(windows)/.exec(ua) ||
- /(mac)/.exec(ua) ||
- /(linux)/.exec(ua) ||
- /(cros)/.exec(ua) ||
- [];
- let matched = {
- browser: match[5] || match[3] || match[1] || '',
- version: match[2] || match[4] || '0',
- majorVersion: match[4] || match[2] || '0',
- platform: platform_match[0] || ''
- };
- let browser = {};
- if (matched.browser) {
- browser[matched.browser] = true;
- let versionArray = matched.majorVersion.split('.');
- browser.version = {
- major: parseInt(matched.majorVersion, 10),
- string: matched.version
- };
- if (versionArray.length > 1) {
- browser.version.minor = parseInt(versionArray[1], 10);
- }
- if (versionArray.length > 2) {
- browser.version.build = parseInt(versionArray[2], 10);
- }
- }
- if (matched.platform) {
- browser[matched.platform] = true;
- }
- if (browser.chrome || browser.opr || browser.safari) {
- browser.webkit = true;
- }
- // MSIE. IE11 has 'rv' identifer
- if (browser.rv || browser.iemobile) {
- if (browser.rv) {
- delete browser.rv;
- }
- let msie = 'msie';
- matched.browser = msie;
- browser[msie] = true;
- }
- // Microsoft Edge
- if (browser.edge) {
- delete browser.edge;
- let msedge = 'msedge';
- matched.browser = msedge;
- browser[msedge] = true;
- }
- // Opera 15+
- if (browser.opr) {
- let opera = 'opera';
- matched.browser = opera;
- browser[opera] = true;
- }
- // Stock android browsers are marked as Safari
- if (browser.safari && browser.android) {
- let android = 'android';
- matched.browser = android;
- browser[android] = true;
- }
- browser.name = matched.browser;
- browser.platform = matched.platform;
- for (let key in Browser) {
- if (Browser.hasOwnProperty(key)) {
- delete Browser[key];
- }
- }
- Object.assign(Browser, browser);
- }
- detect();
- //export default Browser;
- /*
- *@author liuguifng
- *@date 2017.08.15
- *@package
- *@access public
- *
- */
- function setCss3(obj, attrObj) {
- for (let i in attrObj) {
- let newi = i;
- if (newi.indexOf('-') > 0) {
- let num = newi.indexOf('-');
- newi = newi.replace(newi.substr(num, 2), newi.substr(num + 1, 1).toUpperCase());
- }
- obj.style[newi] = attrObj[i];
- newi = newi.replace(newi.charAt(0), newi.charAt(0).toUpperCase());
- obj.style['webkit' + newi] = attrObj[i];
- obj.style['moz' + newi] = attrObj[i];
- obj.style['o' + newi] = attrObj[i];
- obj.style['ms' + newi] = attrObj[i];
- }
- }
- function controlbar(videoElement, shownTime) {
- this.videoElement = videoElement;
- this.shownTime = shownTime;
- this.totolTime = 0;
- this.currentTime = 0;
- this.buffTime = 0;
- this.speed = 1.0;
- //控制条框架
- this.frameDiv = document.createElement('div');
- this.frameDiv.style.top = this.videoElement.offsetHeight;
- this.frameDiv.style.left = this.videoElement.left;
- this.frameDiv.style.backgroundColor = 'rgba(100, 100, 100, 0.5)';
- this.frameDiv.style.zIndex = 200;
- this.frameDiv.style.width = this.videoElement.offsetWidth;
- this.frameDiv.style.height = '30px';
- this.frameDiv.style.position = 'absolute';
- this.frameDiv.style.float = 'left';
- //控制条播放/暂停按钮
- this.btnPlay = document.createElement('img');
- this.btnPlay.style.width = this.frameDiv.style.height;
- this.btnPlay.style.height = this.frameDiv.style.height;
- this.btnPlay.style.float = 'left';
- this.btnPlay.src = zlplayer.resPath + 'res/play.png';
- this.btnPlay.onclick = function () {
- videoElement.paused ? videoElement.play() : videoElement.pause();
- };
- this.frameDiv.appendChild(this.btnPlay);
- //控制条进度框架
- this.progressBoxDiv = document.createElement('div');
- this.progressBoxDiv.style.width = (parseInt(this.frameDiv.style.width) - 2 * parseInt(this.btnPlay.style.height) - 70) + 'px';
- this.progressBoxDiv.style.height = this.frameDiv.style.height;
- this.progressBoxDiv.style.float = 'left';
- this.progressBoxDiv.style.display = 'inline-block';
- this.progressBoxDiv.style.verticalAlign = 'center';
- this.frameDiv.appendChild(this.progressBoxDiv);
- //控制条播放进度
- this.progressPlayDiv = document.createElement('div');
- this.progressPlayDiv.style.width = '0px';
- this.progressPlayDiv.style.height = this.progressBoxDiv.style.height;
- this.progressPlayDiv.style.backgroundColor = 'rgba(10, 10, 10, 0.8)';
- this.progressPlayDiv.style.float = 'left';
- this.progressBoxDiv.appendChild(this.progressPlayDiv);
-
- //进度条拖拽按钮
- this.progressHandle = document.createElement('div');
- this.progressHandle.style.width = '8px';
- this.progressHandle.style.height = this.progressBoxDiv.style.height;
- this.progressHandle.style.backgroundColor = 'rgba(10, 10, 10, 1)';
- this.progressHandle.style.float = 'left';
- this.progressBoxDiv.appendChild(this.progressHandle);
- //进度条缓冲进度
- this.progressBufDiv = document.createElement('div');
- this.progressBufDiv.style.width = '0px';
- this.progressBufDiv.style.height = this.progressBoxDiv.style.height;
- this.progressBufDiv.style.backgroundColor = 'rgba(155, 155, 155, 0.8)';
- this.progressBufDiv.style.float = 'left';
- this.progressBoxDiv.appendChild(this.progressBufDiv);
- //时间
- this.timeText = document.createElement('span');
- this.timeText.innerText = '00:00/00:00';
- this.timeText.style.height = this.frameDiv.style.height;
- this.timeText.style.width = '90px';
- this.timeText.style.float = 'left';
- this.timeText.style.color = 'rgb(255,255,255)';
- this.timeText.style.display = 'inline-block';
- this.timeText.style.textAlign = 'center';
- this.timeText.style.lineHeight = this.timeText.style.height;
- this.frameDiv.appendChild(this.timeText);
- /*
- //速度
- this.speedText = document.createElement('sapn');
- this.speedText.innerText = 'x1.0';
- this.speedText.style.height = this.frameDiv.style.height;
- this.speedText.style.width = '30px';
- this.speedText.style.backgroundColor = 'rgba(100, 100, 100, 0)';
- this.speedText.style.color = 'rgb(100,100,100)';
- this.speedText.style.float = 'left';
- this.speedText.style.display = 'inline-block';
- this.speedText.style.textAlign = 'center';
- this.speedText.style.lineHeight = this.timeText.style.height;
- this.frameDiv.appendChild(this.speedText);
- */
- //音频按钮
- this.btnSound = document.createElement('img');
- this.btnSound.style.height = this.frameDiv.style.height;
- this.btnSound.style.width = this.frameDiv.style.height;
- this.btnSound.style.float = 'right';
- this.btnSound.src = zlplayer.resPath + 'res/sound.png';
-
- this.btnSound.onclick = function () {
- if (videoElement.muted) {
- videoElement.muted = false;
- if (!videoElement.muted) {
- this.btnSound.src = zlplayer.resPath + 'res/sound.png';
- }
- }
- else {
- videoElement.muted = true;
- this.btnSound.src = zlplayer.resPath + 'res/mute.png';
- }
- }.bind(this);
-
- videoElement.addEventListener('canplay', function () {
- if (videoElement.muted) {
- this.btnSound.src = zlplayer.resPath + 'res/mute.png';
- }
- else {
- this.btnSound.src = zlplayer.resPath + 'res/sound.png';
- }
- this.resize();
- }.bind(this));
- //全屏按钮
- this.btnFullScreen = document.createElement('img');
- this.btnFullScreen.style.height = this.frameDiv.style.height;
- this.btnFullScreen.style.width = this.frameDiv.style.height;
- this.btnFullScreen.style.float = 'right';
- this.btnFullScreen.src = zlplayer.resPath + 'res/fullscreen.png';
- this.btnFullScreen.onclick = function () {
- let e = document.createEvent('MouseEvent');
- e.initEvent('dblclick', false, false);
- videoElement.dispatchEvent(e);
- };
- this.frameDiv.appendChild(this.btnFullScreen);
- this.frameDiv.appendChild(this.btnSound);
- window.addEventListener('resize', function () {
- this.resize();
- }.bind(this));
- videoElement.addEventListener('loadedmetadata', function () {
- let duration = videoElement.duration;
- this.updateTime(0, 0, duration);
- }.bind(this));
- videoElement.addEventListener('play', function () {
- this.btnPlay.src = zlplayer.resPath + 'res/pause.png';
- }.bind(this));
- videoElement.addEventListener('pause', function () {
- this.btnPlay.src = zlplayer.resPath + 'res/play.png';
- }.bind(this));
- videoElement.addEventListener('ended', function () {
- this.btnPlay.src = zlplayer.resPath + 'res/play.png';
- }.bind(this));
- videoElement.addEventListener('timeupdate', function () {
- let currentTime = videoElement.currentTime;
- let duration = videoElement.duration;
- if (videoElement.buffered.length > 0) {
- let bufferd = videoElement.buffered.end(0);
- this.updateTime(currentTime, bufferd, duration);
- }
- if (currentTime > 1.0 && currentTime < 2.0) {
- this.resize();
- }
- }.bind(this));
- let timerShown = null;
- videoElement.addEventListener('mouseleave', function (ev) {
- timerShown = setTimeout(function () {
- if (this.frameDiv.style.display != 'none') {
- this.frameDiv.style.display = 'none';
- }
- }.bind(this), this.shownTime);
- }.bind(this));
- videoElement.addEventListener('mousemove', function (ev) {
- if (this.frameDiv.style.display == 'none') {
- this.frameDiv.style.display = '';
- }
- if (timerShown) {
- clearTimeout(timerShown);
- timerShown = null;
- }
- }.bind(this));
- document.addEventListener('fullscreenchange', function () {
- setTimeout(() => {
- videoElement.controls = document.fullScreen;
- this.resize();
- }, 300);
- }.bind(this));
- document.addEventListener('webkitfullscreenchange', function () {
- setTimeout(() => {
- videoElement.controls = document.fullScreen;
- this.resize();
- }, 300);
- }.bind(this));
- document.addEventListener('mozfullscreenchange', function () {
- setTimeout(() => {
- videoElement.controls = document.fullScreen;
- this.resize();
- }, 300);
- }.bind(this));
- this.frameDiv.onmousemove = function () {
- if (timerShown) {
- clearTimeout(timerShown);
- timerShown = null;
- }
- };
- this.frameDiv.onmouseleave = function () {
- if (!timerShown) {
- timerShown = setTimeout(function () {
- if (this.frameDiv.style.display != 'none') {
- this.frameDiv.style.display = 'none';
- }
- }.bind(this), this.shownTime);
- }
- }.bind(this);
- let handle = this.progressHandle;
- let box = this.progressBoxDiv;
- let controler = this;
- let drag = false;
- let buffBar = this.progressBufDiv;
- let playProgress = this.progressPlayDiv;
- let textSpan = this.timeText;
- function getPoint(obj) {
- let t = obj.offsetTop;
- let l = obj.offsetLeft;
- //判断是否有父容器,如果存在则累加其边距
- while ((obj = obj.offsetParent)) {
- t += obj.offsetTop;
- l += obj.offsetLeft;
- }
- return {top: t, left: l};
- }
- box.onmousedown = function (ev) {
- let evPtX = ev.pageX - getPoint(box).left;
- if ((evPtX > handle.offsetLeft && evPtX < buffBar.offsetLeft) || videoElement.paused) {
- return;
- }
- if (evPtX >= (buffBar.offsetLeft + parseInt(buffBar.style.width))) {
- return;
- }
- let duration = videoElement.duration;
- if (isNaN(duration) || duration == Infinity) {
- return;
- }
- let currentTime = parseInt(evPtX / (textSpan.offsetLeft - box.offsetLeft) * duration);
- videoElement.currentTime = currentTime;
- };
-
- /*
- handle.onmousedown = function(ev) {
- if (videoElement.paused) {
- return;
- }
- videoElement.pause();
- drag = true;
- box.onmousemove = function(event) {
- let evPtX = event.layerX - box.offsetLeft;
- let duration = videoElement.duration;
- let currentTime = parseInt(evPtX/(textSpan.offsetLeft - box.offsetLeft) * duration );
- let bufferd = videoElement.buffered.end(0);
- controler.updateTime(currentTime, bufferd, duration);
- };
- box.onmouseup = function(event) {
- box.onmousemove = null;
- box.onmouseup = null;
- drag = false;
- videoElement.play();
- let duration = videoElement.duration;
- let evPtX = event.layerX - box.offsetLeft;
- let currentTime = parseInt(evPtX/(textSpan.offsetLeft - box.offsetLeft) * duration );
- videoElement.currentTime = currentTime;
- };
- box.onmouseleave = function() {
- if (drag) {
- box.onmousemove = null;
- box.onmouseup = null;
- drag = false;
- videoElement.play();
- videoElement.currentTime = controler.currentTime;
- }
- };
- };
- */
- this.show();
- }
- controlbar.prototype.updateTime = function (currentTime, buffTime, totalTime) {
- if (totalTime < 0 || isNaN(totalTime) || totalTime == Infinity) {
- totalTime = currentTime;
- buffTime = 0;
- }
- this.currentTime = currentTime;
- this.buffTime = buffTime;
- this.totalTime = totalTime;
-
- this.timeText.innerText = parseInt(currentTime / 60) + ':' + parseInt(currentTime % 60) + '/' + parseInt(totalTime / 60) + ':' + parseInt(totalTime % 60);
- this.progressPlayDiv.style.width = parseInt((this.progressBoxDiv.offsetWidth - this.progressHandle.offsetWidth) * currentTime / totalTime) + 'px';
- this.progressBufDiv.style.width = buffTime - currentTime > 0 ? parseInt((this.progressBoxDiv.offsetWidth - this.progressHandle.offsetWidth) * (buffTime - currentTime) / totalTime) + 'px' : '0px';
- };
- controlbar.prototype.resize = function () {
- let isVertical = this.videoElement.rotate == 90 || this.videoElement.rotate == 270;
- this.frameDiv.style.width = (isVertical ? this.videoElement.offsetHeight : this.videoElement.offsetWidth) + 'px';
- this.frameDiv.style.top = (isVertical ? this.videoElement.offsetLeft + this.videoElement.offsetWidth - 30 : this.videoElement.offsetTop + this.videoElement.offsetHeight - 30) + 'px';
- this.frameDiv.style.left = this.videoElement.offsetLeft + 'px';
- this.progressBoxDiv.style.width = (parseInt(this.frameDiv.style.width) - 2 * parseInt(this.btnPlay.style.height) - 130) + 'px';
- };
- controlbar.prototype.show = function () {
- if (this.videoElement.parentNode) {
- this.videoElement.parentNode.appendChild(this.frameDiv);
- this.resize();
- }
- };
- controlbar.prototype.hide = function () {
- if (this.videoElement.parentNode && this.frameDiv.parentNode == this.videoElement.parentNode) {
- this.videoElement.parentNode.removeChild(this.frameDiv);
- this.resize();
- }
- };
- let zlplayer = function (videoElement, config) {
-
- flvjs.LoggingControl.enableAll = false;
- flvjs.LoggingControl.enableError = true;
- this.isFullScreen = false;
- this.canvas = document.createElement('canvas');
- this.canvas.style.display = 'none';
- //TODU: check video and config valid
- if (!config.username || !config.password || config.username.length == 0) {
- config.username = 'admin';
- config.password = '123456';
- }
- //in url, parse username and password in url
- let posStart = config.url.indexOf('//') + 2;
- let posEnd = config.url.indexOf('@');
- if (posEnd >= 0) {
- let usrInfo = config.url.substring(posStart, posEnd);
- let posSplit = usrInfo.indexOf(':');
- if (posSplit > 0) {
- //no userinfo in config use parsed info
- if (config.username.length == 0 && config.password.length == 0) {
- config.username = usrInfo.substring(0, posSplit);
- config.password = usrInfo.substring(posSplit + 1);
- }
- config.url = config.url.substring(0, posStart) + config.url.substring(posEnd + 1);
- }
- }
-
- this.flvSrc = {
- type: typeof(config.type) == 'undefined' ? 'flv' : config.type,
- isLive: config.isLive,
- hasAudio: typeof(config.hasAudio) == 'undefined' ? !config.isLive : config.hasAudio,
- url: config.url,
- fixAudioTimestampGap: false
- };
- this.enableFullScreen = config.enableFullScreen;
- this.enableFillWindow = config.enableFillWindow;
- this.maxRelexRgnPtCount = config.relexRgnPtCount;
- this.useCustomFullScreen = config.useCustomFullScreen;
- this.enableControlbar = typeof(config.enableControls) == 'undefined' ? true : config.enableControls;
- let liveConfig = {
- enableWorker: true,
- enableStashBuffer: true,
- stashInitialSize: 256,
- lazyLoad: false,
- autoCleanupSourceBuffer: config.autoCleanupSourceBuffer == undefined ? true : config.autoCleanupSourceBuffer,
- autoCleanupMinBackwardDuration: 1.5,
- autoCleanupMaxBackwardDuration: 2.2,
- username: config.username,
- password: config.password,
- server: config.server
- };
- let playbackConfig = {
- enableWorker: true,
- lazyLoad: true,
- enableStashBuffer: true,
- autoCleanupSourceBuffer: false,
- autoCleanupMinBackwardDuration: 5,
- autoCleanupMaxBackwardDuration: 10,
- username: config.username,
- password: config.password,
- seekType: 'param',
- date: config.date,
- auth: config.auth,
- server: config.server
- };
- let streamConfig = null;
- if (config.isLive) {
- streamConfig = liveConfig;
- } else {
- streamConfig = playbackConfig;
- }
- this.streamConfig = streamConfig;
- this.videoElement = videoElement;
- if (videoElement.parentNode) {
- if (videoElement.parentNode.style.width == 'auto') {
- videoElement.parentNode.style.width = '576px';
- videoElement.widthX = 95;
- }
- if (videoElement.parentNode.style.height == 'auto') {
- videoElement.parentNode.style.height = '704px';
- videoElement.heightX = 95;
- }
- }
- if (videoElement.style.width == '' && !videoElement.widthX) {
- videoElement.style.width = '100%';
- }
- if (videoElement.style.height == '' && !videoElement.heightX) {
- videoElement.style.height = '100%';
- }
-
- if ((videoElement.style.width.indexOf('%') > 0 || videoElement.style.height.indexOf('%') >= 0) && (!videoElement.widthX || !videoElement.heightX)) {
- if (videoElement.style.width.indexOf('%') >= 0) {
- videoElement.widthX = parseInt(videoElement.style.width);
- if (config.rotate && videoElement.rotate == 90 || videoElement.rotate == 270) {
- videoElement.style.width = videoElement.parentNode.offsetWidth * videoElement.widthX / 100.0 + 'px';
- }
- }
- if (videoElement.style.height.indexOf('%') >= 0) {
- videoElement.heightX = parseInt(videoElement.style.height);
- if (config.rotate && videoElement.rotate == 90 || videoElement.rotate == 270) {
- videoElement.style.height = videoElement.parentNode.offsetHeight * videoElement.heightX / 100.0 + 'px';
- }
- }
- }
-
- this.videoElement.controls = false;
- this.videoElement.muted = true;
- if (config.enableFilter && config.filter) {
- this.filter = config.filter;
- if (this.videoElement.parentNode) {
- this.videoElement.parentNode.appendChild(this.canvas);
- }
- this.canvas.width = this.videoElement.offsetWidth;
- this.canvas.height = this.videoElement.offsetHeight;
- this.canvas.style.zIndex = 100;
- this.canvas.style.display = '';
- this.canvas.style.position = 'absolute';
- this.canvas.style.left = `${this.videoElement.offsetLeft}px`;
- this.canvas.style.top = `${this.videoElement.offsetTop}px`;
-
- this.canvas.addEventListener('mousemove', function (event) {
- let eventMove = document.createEvent('MouseEvent');
- eventMove.initMouseEvent('mousemove', true, true, window, 0,
- event.screenX, event.screenY, event.clientX, event.clientY, false, false, false, false, 0, null);
- videoElement.dispatchEvent(eventMove);
- });
-
- this.canvas.addEventListener('mouseleave', function (event) {
- let eventMove = document.createEvent('MouseEvents');
- eventMove.initMouseEvent('mouseleave', true, false);
- videoElement.dispatchEvent(eventMove);
- });
- videoElement.addEventListener('canplay', function () {
- this.canvasInterval = setInterval(zlplayer.prototype.drawCanvasFrame.bind(this), 25);
- }.bind(this));
- videoElement.addEventListener('ended', function () {
- if (this.canvasInterval) {
- clearInterval(this.canvasInterval);
- this.canvasInterval = null;
- }
- }.bind(this));
- }
- if (!config.isLive && this.enableControlbar) {
- this.controlbar = new controlbar(this.videoElement, 5000);
- }
-
- window.addEventListener('resize', this.onBodyResize.bind(this));
-
- let flvPlayer = flvjs.createPlayer(this.flvSrc, this.streamConfig);
-
- flvPlayer.on('error', function (type, reason, desc) {
- switch (type) {
- case 'MediaError':
- if (reason == 'NeedReplay') {
- let ctx = this.canvas.getContext('2d');
- this.canvas.width = this.videoElement.offsetWidth;
- this.canvas.height = this.videoElement.offsetHeight;
- ctx.drawImage(this.videoElement, 0, 0, this.canvas.width, this.canvas.height);
- let image = this.canvas.toDataURL('image/png');
- this.videoElement.poster = image;
- //this.resume(); 去掉,改由外面用户自己重新打开 v1.5.1
- }
- break;
- case 'NetworkError':
- if (desc.code == -999) {
- let ctx = this.canvas.getContext('2d');
- this.canvas.width = this.videoElement.offsetWidth;
- this.canvas.height = this.videoElement.offsetHeight;
- ctx.drawImage(this.videoElement, 0, 0, this.canvas.width, this.canvas.height);
- let image = this.canvas.toDataURL('image/png');
- this.videoElement.poster = image;
- //this.resume(); 去掉,改由外面用户自己重新打开 v1.5.1
- }
- break;
- default:
- this.videoElement.poster = '#000000';
- }
- zlplayer.logger.write('zlplayer', 'error', `play error : type[${type}] reason[${reason}]desc[${JSON.stringify(desc)}]`);
- }.bind(this));
- flvPlayer.attachMediaElement(this.videoElement);
- this.flvPlayer = flvPlayer;
- if (config.enableFillWindow) {
- setCss3(this.videoElement, {'object-fit': 'fill'});
- }
- if (config.rotate) {
- this.rotate(config.rotate);
- }
- //去除右键事件
- videoElement.addEventListener('contextmenu', function (e) {
- e.preventDefault();
- });
- //双击全屏/取消全屏
- videoElement.addEventListener('dblclick', function () {
- if (!this.enableFullScreen) {
- return;
- }
- //自己实现全屏(铺满整个window可视区域)
- if (this.useCustomFullScreen) {
- this.isFullScreen = !this.isFullScreen;
- if (this.isFullScreen) {
- this.videoElement.style.width = '100%';
- this.videoElement.style.height = '100%';
- this.videoElement.style.position = 'absolute';
- this.videoElement.style.zIndex = 9999;
- setCss3(this.videoElement, {'object-fit': 'contain'});
- }
- else
- {
- this.videoElement.style.position = 'static';
- this.videoElement.style.zIndex = 0;
- setCss3(this.videoElement, {'object-fit': 'fill'});
- }
- this.onBodyResize();
- if (this.controlbar) {
- this.controlbar.resize();
- }
- return;
- }
- //使用原生的全屏
- let videoElement = this.videoElement;
- if (videoElement.fullscreenElement) {
- if (videoElement.mozCancelFullScreen) {
- videoElement.mozCancelFullScreen();
- }
- else {
- videoElement.webkitCancelFullscreen();
- }
- this.isFullScreen = false;
- } else {
- if (videoElement.mozRequestFullScreen) {
- videoElement.mozRequestFullScreen();
- }
- else
- {
- videoElement.webkitRequestFullScreen();
- }
- this.isFullScreen = true;
- }
- }.bind(this));
-
- //*报警记录中的窗口自动竖向拉长 comment by liuguifang at 20180711
- if (Browser.safari) {
- // 规避了safari 播放时会白屏(resize或点击其他控件失去焦点后恢复)
- videoElement.addEventListener('canplay', function () {
- videoElement.style.width = (parseInt(videoElement.style.width) - 2) + 'px';
- this.onBodyResize();
- }.bind(this));
- }
-
- return this;
- };
- zlplayer.version = '2.0.16';
- zlplayer.logger = new Logger('zlplayer-log');
- zlplayer.playerMap = new Map();
- zlplayer.resPath = '../js/plugin/';
- /**
- *
- 创建播放器并绑定video dom
- *
- @method +createPlayer
- *
- @for zlplayer
- *
- @param {videoElement object} 播放器绑定的video dom
- *
- @param {config object} 播放器配置
- *
- @return {FLVPlayer} 播放器对象
- */
- zlplayer.createPlayer = function (videoElement, config) {
- let player = new zlplayer(videoElement, config);
- zlplayer.playerMap.set(player, player);
- return player;
- };
- /**
- *
- 销毁某个播放器
- *
- @method +destroyPlayer
- *
- @for zlplayer
- *
- @param {zlplayer object} 播放器对象
-
- @return {void}
- */
- zlplayer.destroyPlayer = function (player) {
- if (player) {
- player.stop();
- if (player.isDrawingRgn) {
- player.stopRelexRgn();
- }
- }
- zlplayer.playerMap.delete(player);
- player = null;
- };
- /**
- *
- 销毁所有播放器
- *
- @method +clearPlayer
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.clearPlayer = function () {
- for (let player of zlplayer.playerMap.values()) {
- if (player) {
- player.stop();
- player = null;
- }
- }
- zlplayer.playerMap.clear();
- };
- /**
- *
- 开始播放
- *
- @method -play
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.play = function () {
- zlplayer.logger.write('zlplayer', 'debug', `play config :${JSON.stringify(this.streamConfig)}`);
- this.flvPlayer.load();
- this.flvPlayer.play();
- if (this.controlbar) {
- this.controlbar.show();
- }
- };
- /**
- *
- 停止播放
- *
- @method -play
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.stop = function () {
- if (this.flvPlayer) {
- this.videoElement.poster = '#000000';
- this.flvPlayer.unload();
- this.flvPlayer.destroy();
- this.flvPlayer = null;
- }
- this.clearRelexRgn();
- if (this.controlbar) {
- this.controlbar.hide();
- }
- if (this.canvasInterval) {
- clearInterval(this.canvasInterval);
- this.canvasInterval = null;
- }
- if (this.canvas) {
- this.canvas.style.display = 'none';
- if (this.canvas.parentNode == this.videoElement.parentNode && this.videoElement.parentNode) {
- this.videoElement.parentNode.removeChild(this.canvas);
- }
- }
- if (this.rgnCanvas) {
- this.rgnCanvas.style.display = 'none';
- if (this.rgnCanvas.parentNode == this.videoElement.parentNode && this.videoElement.parentNode) {
- this.videoElement.parentNode.removeChild(this.rgnCanvas);
- }
- }
- zlplayer.logger.write('zlplayer', 'debug', `stop config :${JSON.stringify(this.streamConfig)}`);
- };
- zlplayer.prototype.resume = function () {
- //in url, parse username and password in url
- let posStart = this.flvSrc.url.indexOf('//') + 2;
- let posEnd = this.flvSrc.url.indexOf('@');
- if (posEnd >= 0) {
- let usrInfo = this.flvSrc.url.substring(posStart, posEnd);
- let posSplit = usrInfo.indexOf(':');
- if (posSplit > 0) {
- this.flvSrc.url = this.flvSrc.url.substring(0, posStart) + this.flvSrc.url.substring(posEnd + 1);
- }
- }
- if (this.flvPlayer) {
- this.flvPlayer.resume(this.flvSrc.url);
- }
- };
- /**
- *
- 旋转
- *
- @method -rotate
- *
- @param deg 角度
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.rotate = function (deg) {
- if (this.videoElement.rotate != deg) {
- if (deg == 90 || deg == 180 || deg == 270 || deg == 360 || deg == 0) {
- if (deg == 360) {
- deg = 0;
- }
- if (270 == this.videoElement.rotate) {
- this.videoElement.rotate = -90;
- }
- this.videoElement.rotate = deg;
- }
- }
- if (this.onBodyResize) {
- this.onBodyResize();
- }
- };
- /**
- *
- 设置事件回调
- *
- @method -setEventCb
- *
- @for zlplayer
- *
- @param {eventCb cb function} function(type,reason,desc)
- *
- @return {void}
- */
- zlplayer.prototype.setEventCb = function (eventCb) {
- if (this.flvPlayer) {
- this.flvPlayer.on('error', eventCb);
- }
- };
- zlplayer.prototype.on = function (name, func) {
- if (this.flvPlayer) {
- if (name == 'error') {
- this.flvPlayer.on('error', func);
- }
- }
- };
- /**
- *
- 抓图
- *
- @method -capture
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.capture = function () {
- //draw image
- if (!this.canvas) {
- this.canvas = document.createElement('canvas');
- this.canvas.display = 'none';
- }
- let ctx = this.canvas.getContext('2d');
- this.canvas.width = this.videoElement.videoWidth;
- this.canvas.height = this.videoElement.videoHeight;
- ctx.drawImage(this.videoElement, 0, 0, this.canvas.width, this.canvas.height);
-
- //create image link and sava file
- let image = this.canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream');
- this.onBodyResize();
- return image;
- };
- /**
- *
- 开始录像
- *
- @method -startRecord
- *
- @for zlplayer
- *
- @return {image object}
- */
- zlplayer.prototype.startRecord = function () {
- //safari not support 'captureStream'
- if (this.recoding) {
- return;
- }
- if (this.flvPlayer) {
- this.videoElement.captureStream = this.videoElement.captureStream || this.videoElement.mozCaptureStream;
- if (!this.videoElement.captureStream) {
- alert('需要您的浏览器支持,Chrome 需要开启“实验性网络平台”选项\n(浏览器地址栏输入: chrome://flags/#enable-experimental-web-platform-features 点击“enable”或者“开启”), Safari,Edge,IE等不支持');
- return;
- }
- let options = {mimeType: 'video/webm'};
- if (!this.mediaRecorder) {
- this.mediaRecorder = new MediaRecorder(this.videoElement.captureStream(), options);
- this.mediaRecorder.onstop = function () { console.log('player stoped'); };
- this.mediaRecorder.ondataavailable = function (event) {
- if (event.data && event.data.size > 0 && this.recordedBlobs) {
- this.recordedBlobs.push(event.data);
- }
- }.bind(this);
- }
-
- this.recordedBlobs = new Array();
- }
- this.mediaRecorder.start(10);
- this.recoding = true;
- };
- /**
- *
- 停止录像
- *
- @method -stopRecord
- *
- @for zlplayer
- *
- @return {blob object}
- */
- zlplayer.prototype.stopRecord = function () {
- if (!this.recoding) {
- return;
- }
- this.mediaRecorder.stop();
- this.recoding = false;
- if (this.recordedBlobs && this.recordedBlobs.length > 0) {
- let blob = new Blob(this.recordedBlobs, {type: 'video/webm'});
- this.recordedBlobs = null;
- return blob;
- }
- return null;
- };
- /**
- *
- 调整宽高(主要是旋转后的调整)
- *
- @method -onBodyResize
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.onBodyResize = function () {
- let element = this.videoElement;
- if (!element) {
- return;
- }
- let showRgn = this.isFullScreen && this.useCustomFullScreen ? {width: window.innerWidth, height: window.innerHeight}
- : {width: this.videoElement.parentNode.offsetWidth, height: this.videoElement.parentNode.offsetHeight};
- let isVertical = element.rotate && element.rotate == 90 || element.rotate == 270;
- if (element.widthX) {
- if (isVertical) {
- element.style.height = showRgn.width * element.widthX / 100.0 + 'px';
- }
- else {
- element.style.width = showRgn.width * element.widthX / 100.0 + 'px';
- }
- }
- if (element.heightX) {
- if (isVertical) {
- element.style.width = showRgn.height * element.heightX / 100.0 + 'px';
- }
- else {
- element.style.height = showRgn.height * element.heightX / 100.0 + 'px';
- }
- }
- let xOffset = 0;
- if (element.rotate && element.rotate == 90) {
- xOffset = (parseInt(element.offsetHeight) - parseInt(element.offsetWidth)) / 2;
- }
- else if (element.rotate && element.rotate == 270) {
- xOffset = (parseInt(element.offsetWidth) - parseInt(element.offsetHeight)) / 2;
- }
- setCss3(element, {'transform': `rotate(${element.rotate}deg) translate(${-xOffset}px, ${-xOffset}px)`});
-
- if (this.isDrawingRgn) {
- if (this.rgnCanvas) {
- this.rgnCanvas.width = isVertical ? element.offsetHeight : element.offsetWidth;
- this.rgnCanvas.height = isVertical ? element.offsetWidth : element.offsetHeight;
- this.rgn.cx = isVertical ? element.offsetHeight : element.offsetWidth;
- this.rgn.cy = isVertical ? element.offsetWidth : element.offsetHeight;
- }
- setTimeout(function () {
- if (this.rgn && this.rgn.points.length) {
- this.onUpdateRgn();
- }
- }.bind(this), 100);
- }
- if (this.controlbar) {
- this.controlbar.resize();
- }
- if (this.canvas) {
- this.canvas.style.top = `${element.offsetTop}px`;
- this.canvas.style.left = `${element.offsetLeft}px`;
- this.canvas.width = isVertical ? element.offsetHeight : element.offsetWidth;
- this.canvas.height = isVertical ? element.offsetWidth : element.offsetHeight;
- }
- };
- /**
- *
- 开始绘制区域
- *
- @method -startRelexRgn
- *
- @for zlplayer
- *
- @param {minPoints integer , rgn min point count}
- *
- @param {maxPoints integer , rgn max point count}
- *
- @param {initRgn rgn Object }
- *
- @return {void}
- */
- zlplayer.prototype.startRelexRgn = function (minPoints, maxPoints, initRgn) {
- if (this.isDrawingRgn) {
- this.stopRelexRgn();
- }
- if (minPoints) {
- this.minRelexRgnPtCount = minPoints;
- }
- if (maxPoints) {
- this.maxRelexRgnPtCount = maxPoints;
- if (minPoints > maxPoints) {
- this.minRelexRgnPtCount = maxPoints;
- }
- }
- if (!this.minRelexRgnPtCount) {
- this.minRelexRgnPtCount = 3;
- }
- if (!this.maxRelexRgnPtCount) {
- this.maxRelexRgnPtCount = 8;
- }
- this.isRgnEditing = false;
- this.isRgnComplete = false;
- if (!this.rgnCanvas) {
- this.rgnCanvas = document.createElement('canvas');
- if (this.videoElement.parentNode) {
- this.videoElement.parentNode.appendChild(this.rgnCanvas);
- }
- }
- this.rgnCanvas.width = this.videoElement.offsetWidth;
- this.rgnCanvas.height = this.videoElement.offsetHeight;
- this.rgnCanvas.style.zIndex = 100;
- this.rgnCanvas.style.display = '';
- this.rgnCanvas.style.position = 'absolute';
- this.rgnCanvas.style.left = this.videoElement.offsetLeft + 'px';
- this.rgnCanvas.style.top = this.videoElement.offsetTop + 'px';
- this.rgn = {};
- this.rgn.origin = initRgn && initRgn.origin ? initRgn.origin : 'left-top';
- this.rgn.cx = this.videoElement.offsetWidth;
- this.rgn.cy = this.videoElement.offsetHeight;
- this.rgn.points = [];
- this.rgn.minPoints = this.minRelexRgnPtCount;
- this.rgn.maxPoints = this.maxRelexRgnPtCount;
- if (!this.isDrawingRgn) {
- this.isDrawingRgn = true;
- }
- this.isRgnComplete = this.isRgnEditing = initRgn && initRgn.points && initRgn.points.length;
- this.isInitRgn = initRgn && initRgn.points && initRgn.points.length;
-
- //点击增加一个点 或者 闭合后编辑区域
- this.rgnCanvas.onclick = function (event) {
- let ox = event.offsetX;
- let oy = event.offsetY;
- if (!this.isDrawingRgn) {
- return;
- }
- if (this.rgn.maxPoints > this.rgn.points.length && !this.isRgnComplete) {
- if (this.rgn) {
- let newPt = {xaxis: ox / this.rgnCanvas.width, yaxis: oy / this.rgnCanvas.height};
- this.rgn.points.push(newPt);
- }
- }
- if (this.rgn.points.length >= this.rgn.maxPoints && !this.isRgnComplete)
- {
- this.isRgnComplete = true;
- this.isRgnEditing = true;
- }
- if (this.isDrawingRgn) {
- this.onUpdateRgn();
- }
- let ctx = this.rgnCanvas.getContext('2d');
- ctx.strokeStyle = 'red';
- ctx.lineWidth = 2.0;
- ctx.lineCap = 'round';
- ctx.lineJoin = 'round';
- //ctx.beginPath();
- ctx.moveTo(ox, oy);
- ctx.lineTo(ox, oy);
- //ctx.closePath();
- ctx.stroke();
- }.bind(this);
- //如果拖动光标,且光标在控制点上时,拖动区域
- this.rgnCanvas.onmousemove = function (event) {
- function hitPoint(ptSrc, ptDst) {
- if (ptSrc && ptDst) {
- let distance = Math.sqrt((ptSrc.xaxis - ptDst.xaxis) * (ptSrc.xaxis - ptDst.xaxis) + (ptSrc.yaxis - ptDst.yaxis) * (ptSrc.yaxis - ptDst.yaxis));
- //console.log(`distance is ${distance}`);
- return distance < 12;
- }
- return false;
- }
- if (this.isRgnEditing && event.buttons) {
- //两个点是否命中点
-
- //光标的点与区域的控制点基本命中时移动控制点到光标位置
- for (let i = 0; i < this.rgn.points.length; i++) {
- let ox = this.rgn.points[i].xaxis * this.rgn.cx;
- let oy = this.rgn.points[i].yaxis * this.rgn.cy;
- if (hitPoint({xaxis: event.offsetX, yaxis: event.offsetY}, {xaxis: ox, yaxis: oy})) {
- this.rgn.points[i].xaxis = event.offsetX / this.rgn.cx;
- this.rgn.points[i].yaxis = event.offsetY / this.rgn.cy;
- setTimeout(function () {
- this.onUpdateRgn();
- }.bind(this), 50);
- break;
- }
- }
- }
- }.bind(this);
-
- //右键,取消/结束区域绘制 变为可编辑状态
- this.rgnCanvas.oncontextmenu = function (event) {
- this.ptMouse = null;
- if (this.rgn.points.length < this.rgn.minPoints) {
- //no more pts to draw a rgn
- this.rgn.points = [];
- }
- else {
- this.isRgnComplete = true;
- this.isRgnEditing = true;
- }
-
- if (this.isDrawingRgn) {
- this.onUpdateRgn();
- }
-
- return false;
- }.bind(this);
-
- //更新绘图区域
- this.onUpdateRgn = function () {
- let ctx = this.rgnCanvas.getContext('2d');
- ctx.clearRect(0, 0, this.videoElement.offsetWidth, this.videoElement.offsetHeight);
- ctx.strokeStyle = 'red';
- ctx.fillStyle = 'yellow';
- ctx.lineWidth = 2.0;
- ctx.lineCap = 'round';
- ctx.lineJoin = 'round';
- if (this.rgn && this.rgn.points.length) {
- ctx.beginPath();
- /*this.rgn.points.forEach(function(pt){
- ctx.arc (pt.xaxis, pt.yaxis, 4, 0, 2 * Math.PI, false);
- });
- ctx.fill();*/
- //连接每一个点
- let ptLast = null;
- let ptFirst = this.rgn.points[0];
- for (let i = 0; i < this.rgn.points.length; i++) {
- let pt = Object.assign({}, this.rgn.points[i]);
- if (!ptLast) {
- ptLast = pt;
- }
- let penPt = {xaxis: ptLast.xaxis * this.rgn.cx, yaxis: ptLast.yaxis * this.rgn.cy};
- ctx.moveTo(penPt.xaxis, penPt.yaxis);
- penPt = {xaxis: pt.xaxis * this.rgn.cx, yaxis: pt.yaxis * this.rgn.cy};
- ctx.lineTo(penPt.xaxis, penPt.yaxis);
- ptLast = pt;
- //编辑的时候显示可拖动的点
- if (this.isRgnEditing) {
- ctx.moveTo(penPt.xaxis, penPt.yaxis);
- ctx.arc(penPt.xaxis, penPt.yaxis, 4, 0, Math.PI * 2, true);
- }
- }
- //结束后连接起始点与结束点
- if (this.isRgnComplete) {
- let penPt = {xaxis: ptLast.xaxis * this.rgn.cx, yaxis: ptLast.yaxis * this.rgn.cy};
- ctx.moveTo(penPt.xaxis, penPt.yaxis);
- ptLast = ptFirst;
- penPt = {xaxis: ptLast.xaxis * this.rgn.cx, yaxis: ptLast.yaxis * this.rgn.cy};
- ctx.lineTo(penPt.xaxis, penPt.yaxis);
- }
- else
- {
- /*
- //连接光标的弹簧线
- if (this.ptMouse) {
- ctx.lineWidth = 1.0;
- //ctx.strokeStyle = "yellow";
- let ptEnd = this.rgn.points[this.rgn.points.length-1];
- ctx.moveTo(ptEnd.xaxis*this.rgn.cx, ptEnd.yaxis*this.rgn.cy);
- ctx.lineTo(this.ptMouse.xaxis, this.ptMouse.yaxis);
- }*/
- }
- ctx.closePath();
- ctx.stroke();
- }
- }.bind(this);
- //显示设置的区域
- if (initRgn && initRgn.points) {
- for (let i = 0; i < initRgn.points.length; i++) {
- let ox = initRgn.points[i].xaxis / initRgn.cx;
- let oy = initRgn.points[i].yaxis / initRgn.cy;
- if ('left-bottom' == initRgn.origin) {
- oy = 1 - oy;
- }
- else if ('right-top' == initRgn.origin) {
- ox = 1 - ox;
- }
- else if ('right-bottom' == initRgn.origin) {
- ox = 1 - ox;
- oy = 1 - oy;
- }
- this.rgn.points.push({xaxis: ox, yaxis: oy});
- this.onUpdateRgn();
- }
- }
- };
- /**
- *
- 停止绘制区域
- *
- @method -stopRelexRgn
- *
- @for zlplayer
- *
- @param {callback cb function} function(player, rgns)
- *
- @return {void}
- */
- zlplayer.prototype.stopRelexRgn = function (callback) {
- this.isRgnComplete = true;
- this.isRgnEditing = false;
- this.isInitRgn = false;
- this.onUpdateRgn();
- //回调区域
- if (callback && this.rgn && this.rgn.points) {
- let rgnResult = {};
- rgnResult.points = [];
- rgnResult.cx = this.rgn.cx;
- rgnResult.cy = this.rgn.cy;
- rgnResult.minPoints = this.rgn.minPoints;
- rgnResult.maxPoints = this.rgn.maxPoints;
- for (let i = this.rgn.points.length - 1; i >= 0; i--) {
- let pt = {};
- pt.xaxis = parseInt(this.rgn.points[i].xaxis * this.rgn.cx);
- pt.yaxis = parseInt(this.rgn.points[i].yaxis * this.rgn.cy);
-
- let originDirect = this.rgn.origin;
- if (originDirect) {
- //origin direction is 'left-top'
- if ('left-bottom' == originDirect) {
- pt.yaxis = this.rgn.cy - pt.yaxis;
- }
- else if ('right-top' == originDirect) {
- pt.xaxis = this.rgn.cx - pt.xaxis;
- }
- else if ('right-bottom' == originDirect) {
- pt.xaxis = this.rgn.cx - pt.xaxis;
- pt.yaxis = this.rgn.cy - pt.yaxis;
- }
- }
- rgnResult.origin = this.rgn.origin;
- rgnResult.points.push(pt);
- }
- callback(this, rgnResult);
- }
- };
- /**
- *
- 清除绘制区域
- *
- @method -clearRelexRgn
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.clearRelexRgn = function () {
- this.isRgnComplete = true;
- this.isDrawingRgn = false;
- this.isInitRgn = false;
- this.rgn = null;
- this.ptMouse = null;
- if (this.rgnCanvas) {
- this.rgnCanvas.style.display = 'none';
- }
- };
- /**
- *
- canvas 绘制视频帧
- *
- @method -drawCanvasFrame
- *
- @for zlplayer
- *
- @return {void}
- */
- zlplayer.prototype.drawCanvasFrame = function () {
- let ctx = this.canvas.getContext('2d');
- ctx.filter = this.filter;
- ctx.drawImage(this.videoElement, 0, 0, this.canvas.width, this.canvas.height);
- };
|