!function(t){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=t();elseif("function"==typeofdefine&&define.amd)define([],t);else{vare;"undefined"!=typeofwindow?e=window:"undefined"!=typeofglobal?e=global:"undefined"!=typeofself&&(e=self),e.Hls=t()}}(function(){returnfunctions(e,t,r){functioni(a,d){if(!t[a]){if(!e[a]){varl="function"==typeofrequire&&require;if(!d&&l)returnl(a,!0);if(n)returnn(a,!0);varu=newError("Cannot find module '"+a+"'");throwu.code="MODULE_NOT_FOUND",u}varo=t[a]={exports:{}};e[a][0].call(o.exports,function(t){varr=e[a][1][t];returni(r?r:t)},o,o.exports,s,e,t,r)}returnt[a].exports}for(varn="function"==typeofrequire&&require,a=0;a<r.length;a++)i(r[a]);returni}({1:[function(s,a,o){functione(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functiont(e){return"function"==typeofe}functionn(e){return"number"==typeofe}functionr(e){return"object"==typeofe&&null!==e}functioni(e){returnvoid0===e}a.exports=e,e.EventEmitter=e,e.prototype._events=void0,e.prototype._maxListeners=void0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!n(e)||0>e||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},e.prototype.emit=function(u){varo,a,n,s,e,l;if(this._events||(this._events={}),"error"===u&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(o=arguments[1],oinstanceofError)throwo;throwTypeError('Uncaught, unspecified "error" event.')}if(a=this._events[u],i(a))return!1;if(t(a))switch(arguments.length){case1:a.call(this);break;case2:a.call(this,arguments[1]);break;case3:a.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,s=newArray(n-1),e=1;n>e;e++)s[e-1]=arguments[e];a.apply(this,s)}elseif(r(a)){for(n=arguments.length,s=newArray(n-1),e=1;n>e;e++)s[e-1]=arguments[e];for(l=a.slice(),n=l.length,e=0;n>e;e++)l[e].apply(this,s)}return!0},e.prototype.addListener=function(a,n){vars;if(!t(n))throwTypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,t(n.listener)?n.listener:n),this._events[a]?r(this._events[a])?this._events[a].push(n):this._events[a]=[this._events[a],n]:this._events[a]=n,r(this._events[a])&&!this._events[a].warned){vars;s=i(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[a].length>s&&(this._events[a].warned=!0,"function"==typeofconsole.trace)}returnthis},e.prototype.on=e.prototype.addListener,e.prototype.once=function(i,e){functionr(){this.removeListener(i,r),a||(a=!0,e.apply(this,arguments))}if(!t(e))throwTypeError("listener must be a function");vara=!1;returnr.listener=e,this.on(i,r),this},e.prototype.removeListener=function(a,i){vare,s,o,n;if(!t(i))throwTypeError("listener must be a function");if(!this._events||!this._events[a])returnthis;if(e=this._events[a],o=e.length,s=-1,e===i||t(e.listener)&&e.listener===i)deletethis._events[a],this._events.removeListener&&this.emit("removeListener",a,i);elseif(r(e)){for(n=o;n-->0;)if(e[n]===i||e[n].listener&&e[n].listener===i){s=n;break}if(0>s)returnthis;1===e.length?(e.length=0,deletethis._events[a]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",a,i)}returnthis},e.prototype.removeAllListeners=function(e){vari,r;if(!this._events)returnthis;if(!this._events.removeListener)return0===arguments.length?this._events={}:this._events[e]&&deletethis._events[e],this;if(0===arguments.length){for(iinthis._events)"removeListener"!==i&&this.removeAllListeners(i);returnthis.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],t(r))this.removeListener(e,r);elsefor(;r.length;)this.removeListener(e,r[r.length-1]);returndeletethis._events[e],this},e.prototype.listeners=function(e){varr;returnr=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.listenerCount=function(e,r){vari;returni=e._events&&e._events[r]?t(e._events[r])?1:e._events[r].length:0}},{}],2:[func
casei.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!a.fatal){varn=this.fragLoadError;if(n?n++:n=1,n<=this.config.fragLoadingMaxRetry){this.fragLoadError=n,a.frag.loadCounter=0;vars=Math.min(Math.pow(2,n-1)*this.config.fragLoadingRetryDelay,64e3);t.logger.warn("mediaController: frag loading failed, retry in "+s+" ms"),this.retryDate=performance.now()+s,this.state=e.FRAG_LOADING_WAITING_RETRY}elset.logger.error("mediaController: "+a.details+" reaches max retry, redispatch as fatal ..."),a.fatal=!0,this.hls.trigger(r.default.ERROR,a),this.state=e.ERROR}break;casei.ErrorDetails.FRAG_LOOP_LOADING_ERROR:casei.ErrorDetails.LEVEL_LOAD_ERROR:casei.ErrorDetails.LEVEL_LOAD_TIMEOUT:casei.ErrorDetails.KEY_LOAD_ERROR:casei.ErrorDetails.KEY_LOAD_TIMEOUT:t.logger.warn("mediaController: "+a.details+" while loading frag,switch to "+(a.fatal?"ERROR":"IDLE")+" state ..."),this.state=a.fatal?e.ERROR:e.IDLE}}},{key:"onSBUpdateEnd",value:function(){if(this.state===e.APPENDING&&0===this.mp4segments.length){vara=this.fragCurrent,i=this.stats;a&&(this.fragPrevious=a,i.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*i.length/(i.tbuffered-i.tfirst)),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:i,frag:a}),t.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=e.IDLE)}this.tick()}},{key:"_checkBuffer",value:function(){vare=this.media;if(e){varu=e.readyState;if(u){vars=this.seekAfterBuffered;if(s)e.duration>=s&&(e.currentTime=s,this.seekAfterBuffered=void0);else{vara=e.currentTime,o=this.bufferInfo(a,0),f=!(e.paused||e.ended||e.seeking||3>u),l=.2,d=a>e.playbackRate*this.lastCurrentTime;if(this.stalled&&d&&(this.stalled=!1),o.len<=l&&(d||!f?l=0:(t.logger.log("playback seems stuck"),this.stalled||(this.hls.trigger(r.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0)),o.len<=l)){varn=o.nextStart,h=n-a;n&&h<this.config.maxSeekHole&&h>.005&&!e.seeking&&(t.logger.log("adjust currentTime from "+a+" to "+n),e.currentTime=n)}}}}}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"onSBUpdateError",value:function(a){t.logger.error("sourceBuffer error:"+a),this.state=e.ERROR,this.hls.trigger(r.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1,frag:this.fragCurrent})}},{key:"timeRangesToString",value:function(t){for(varr="",i=t.length,e=0;i>e;e++)r+="["+t.start(e)+","+t.end(e)+"]";returnr}},{key:"onMediaSourceOpen",value:function(){t.logger.log("media source opened"),this.hls.trigger(r.default.MEDIA_ATTACHED),this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvmetadata=this.onMediaMetadata.bind(this),this.onvended=this.onMediaEnded.bind(this);vare=this.media;e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("loadedmetadata",this.onvmetadata),e.addEventListener("ended",this.onvended),this.levels&&this.config.autoStartLoad&&this.startLoad(),this.mediaSource.removeEventListener("sourceopen",this.onmso)}},{key:"onMediaSourceClose",value:function(){t.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){t.logger.log("media source ended")}},{key:"currentLevel",get:function(){if(this.media){vare=this.getBufferRange(this.media.currentTime);if(e)returne.frag.level}return-1}},{key:"nextBufferRange",get:function(){returnthis.media?this.followingBufferRange(this.getBufferRange(this.media.currentTime)):null}},{key:"nextLevel",get:function(){vare=this.nextBufferRange;returne?e.frag.level:-1}}]),a}(o.default);s.default=_,h.exports=s.default},{"../demux/demuxer":13,"../errors":17,"../event-handler":18,"../events":19,"../helper/level-helper":20,"../utils/binary-search":28,"../utils/logger":29}],6:[function(n,t,e){"use strict";functionr(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});vari=function(){functione(i,r){for(vart=0;t<r.length;t++){vare=r[t];e
this.lastAacPTS=h}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(e){returne.length>=564&&71===e[0]&&71===e[188]&&71===e[376]?!0:!1}}]),t}();i.default=u,o.exports=i.default},{"../errors":17,"../events":19,"../utils/logger":29,"./adts":10,"./exp-golomb":14}],17:[function(i,a,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});vart={NETWORK_ERROR:"hlsNetworkError",MEDIA_ERROR:"hlsMediaError",OTHER_ERROR:"hlsOtherError"};e.ErrorTypes=t;varr={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError"};e.ErrorDetails=r},{}],18:[function(n,t,e){"use strict";functionr(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});vari=function(){functione(i,r){for(vart=0;t<r.length;t++){vare=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"ine&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}returnfunction(t,r,i){returnr&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){functione(n){r(this,e),this.hls=n,this.onEvent=this.onEvent.bind(this);for(vari=arguments.length,a=Array(i>1?i-1:0),t=1;i>t;t++)a[t-1]=arguments[t];this.handledEvents=a,this.useGenericHandler=!0,this.registerListeners()}returni(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{key:"isEventHandler",value:function(){return"object"==typeofthis.handledEvents&&this.handledEvents.length&&"function"==typeofthis.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if("hlsEventGeneric"===e)thrownewError("Forbidden event name: "+e);this.hls.on(e,this.onEvent)}.bind(this))}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)}.bind(this))}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){varr=function(t,r){vare="on"+t.replace("hls","");if("function"!=typeofthis[e])thrownewError("Event "+t+" has no generic handler in this "+this.constructor.name+" class (tried "+e+")");returnthis[e].bind(this,r)};r.call(this,e,t).call()}}]),e}();e.default=a,t.exports=e.default},{}],19:[function(t,e,r){"use strict";e.exports={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVEL_SWITCH:"hlsLevelSwitch",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded"}},{}],20:[function(r,i,e){"use strict";functiona(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});varn=function(){functione(i,r){for(vart=0;t<r.length;t++){vare=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"ine&&(e.writable=!0),Object
videoCodec:t.codec,videoWidth:t.width,videoHeight:t.height}),this.ISGenerated=!0,void0===this._initPTS&&(this._initPTS=l[0].pts-n*a,this._initDTS=l[0].dts-n*a)):i.config&&t.sps&&t.pps&&(u.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,{audioMoov:r.default.initSegment([i]),audioCodec:i.codec,audioChannelCount:i.channelCount,videoMoov:r.default.initSegment([t]),videoCodec:t.codec,videoWidth:t.width,videoHeight:t.height}),this.ISGenerated=!0,void0===this._initPTS&&(this._initPTS=Math.min(l[0].pts,o[0].pts)-n*a,this._initDTS=Math.min(l[0].dts,o[0].dts)-n*a))}},{key:"remuxVideo",value:function(a,w,k){varA,l,g,L,v,d,S,T,R,f,_,c,o,i,s,p=8,E=this.PES_TIMESCALE,h=this.PES2MP4SCALEFACTOR,u=[];for(d=newUint8Array(a.len+4*a.nbNalu+8),A=newDataView(d.buffer),A.setUint32(0,d.byteLength),d.set(r.default.types.mdat,4);a.samples.length;){for(l=a.samples.shift(),L=0;l.units.units.length;)v=l.units.units.shift(),A.setUint32(p,v.data.byteLength),p+=4,d.set(v.data,p),p+=v.data.byteLength,L+=4+v.data.byteLength;if(_=l.pts-this._initDTS,c=l.dts-this._initDTS,c=Math.min(_,c),void0!==f){o=this._PTSNormalize(_,f),i=this._PTSNormalize(c,f);vary=(i-f)/h;0>=y&&(t.logger.log("invalid sample duration at PTS/DTS: "+l.pts+"/"+l.dts+":"+y),y=1),g.duration=y}else{varn,m=this.nextAvcDts;o=this._PTSNormalize(_,m),i=this._PTSNormalize(c,m),n=Math.round((i-m)/90),(k||Math.abs(n)<600)&&n&&(n>1?t.logger.log("AVC:"+n+" ms hole between fragments detected,filling it"):-1>n&&t.logger.log("AVC:"+-n+" ms overlapping between fragments detected"),i=m,o=Math.max(o-n,i),t.logger.log("Video/PTS/DTS adjusted: "+o+"/"+i+",delta:"+n)),T=Math.max(0,o),R=Math.max(0,i)}g={size:L,duration:0,cts:(o-i)/h,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},s=g.flags,l.key===!0?(s.dependsOn=2,s.isNonSync=0):(s.dependsOn=1,s.isNonSync=1),u.push(g),f=i}varb=0;u.length>=2&&(b=u[u.length-2].duration,g.duration=b),this.nextAvcDts=i+b*h,a.len=0,a.nbNalu=0,u.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(s=u[0].flags,s.dependsOn=2,s.isNonSync=0),a.samples=u,S=r.default.moof(a.sequenceNumber++,R/h,a),a.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{moof:S,mdat:d,startPTS:T/E,endPTS:(o+h*b)/E,startDTS:R/E,endDTS:this.nextAvcDts/E,type:"video",nb:u.length})}},{key:"remuxAudio",value:function(i,k,S){varL,f,s,d,u,R,A,_,h,l,E,o,n,T=8,c=this.PES_TIMESCALE,p=this.PES2MP4SCALEFACTOR,g=[],b=[];for(i.samples.forEach(function(e){void0===l||e.pts>l?(b.push(e),l=e.pts):t.logger.warn("dropping past audio frame")});b.length;){if(f=b.shift(),d=f.unit,l=f.pts-this._initDTS,E=f.dts-this._initDTS,void0!==h)o=this._PTSNormalize(l,h),n=this._PTSNormalize(E,h),s.duration=(n-h)/p,s.duration<0&&(t.logger.log("invalid AAC sample duration at PTS:"+f.pts+":"+s.duration),s.duration=0);else{vara,m=this.nextAacPts;if(o=this._PTSNormalize(l,m),n=this._PTSNormalize(E,m),a=Math.round(1e3*(o-m)/c),(S||Math.abs(a)<600)&&a){if(a>0)t.logger.log(a+" ms hole between AAC samples detected,filling it");elseif(-12>a){t.logger.log(-a+" ms overlapping between AAC samples detected, drop frame"),i.len-=d.byteLength;continue}o=n=m}A=Math.max(0,o),_=Math.max(0,n),u=newUint8Array(i.len+8),L=newDataView(u.buffer),L.setUint32(0,u.byteLength),u.set(r.default.types.mdat,4)}u.set(d,T),T+=d.byteLength,s={size:d.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},g.push(s),h=n}vary=0,v=g.length;v>=2&&(y=g[v-2].duration,s.duration=y),v&&(this.nextAacPts=o+p*y,i.len=0,i.samples=g,R=r.default.moof(i.sequenceNumber++,_/p,i),i.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{moof:R,mdat:u,startPTS:A/c,endPTS:this.nextAacPts/c,startDTS:_/c,endDTS:(n+p*y)/c,type:"audio",nb:v}))}},{key:"remuxID3",value:function(r,a){vart,n=r.samples.length;if(n){for(vari=0;n>i;i++)t=r.samples[i],t.pts=(t.pts-this._initPTS)/this.PES_TIMESCALE,t.dts=(t.dts-this._initDTS)/this.PES_TIMESCALE;this.observer.trigger(e.default.FRAG_PARSING_METADATA,{samples:r.samples})}r.samples=[],a=a}},{key:"_PTSNormalize",value:function(e,t){varr;if(void0===t)retu