!function(e){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=e();elseif("function"==typeofdefine&&define.amd)define([],e);else{vart;t="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,t.Hls=e()}}(function(){returnfunctions(e,t,r){functionn(a,d){if(!t[a]){if(!e[a]){varl="function"==typeofrequire&&require;if(!d&&l)returnl(a,!0);if(i)returni(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];returnn(r?r:t)},o,o.exports,s,e,t,r)}returnt[a].exports}for(vari="function"==typeofrequire&&require,a=0;a<r.length;a++)n(r[a]);returnn}({1:[function(s,a,o){functione(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functiont(e){return"function"==typeofe}functioni(e){return"number"==typeofe}functionr(e){return"object"==typeofe&&null!==e}functionn(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(!i(e)||0>e||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},e.prototype.emit=function(l){vars,e,u,a,i,o;if(this._events||(this._events={}),"error"===l&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(s=arguments[1],sinstanceofError)throws;throwTypeError('Uncaught, unspecified "error" event.')}if(e=this._events[l],n(e))return!1;if(t(e))switch(arguments.length){case1:e.call(this);break;case2:e.call(this,arguments[1]);break;case3:e.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),e.apply(this,a)}elseif(r(e))for(a=Array.prototype.slice.call(arguments,1),o=e.slice(),u=o.length,i=0;u>i;i++)o[i].apply(this,a);return!0},e.prototype.addListener=function(a,i){vars;if(!t(i))throwTypeError("listener must be a function");returnthis._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,t(i.listener)?i.listener:i),this._events[a]?r(this._events[a])?this._events[a].push(i):this._events[a]=[this._events[a],i]:this._events[a]=i,r(this._events[a])&&!this._events[a].warned&&(s=n(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[a].length>s&&(this._events[a].warned=!0,"function"==typeofconsole.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(n,e){functionr(){this.removeListener(n,r),a||(a=!0,e.apply(this,arguments))}if(!t(e))throwTypeError("listener must be a function");vara=!1;returnr.listener=e,this.on(n,r),this},e.prototype.removeListener=function(a,n){vare,s,o,i;if(!t(n))throwTypeError("listener must be a function");if(!this._events||!this._events[a])returnthis;if(e=this._events[a],o=e.length,s=-1,e===n||t(e.listener)&&e.listener===n)deletethis._events[a],this._events.removeListener&&this.emit("removeListener",a,n);elseif(r(e)){for(i=o;i-->0;)if(e[i]===n||e[i].listener&&e[i].listener===n){s=i;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,n)}returnthis},e.prototype.removeAllListeners=function(r){varn,e;if(!this._events)returnthis;if(!this._events.removeListener)return0===arguments.length?this._events={}:this._events[r]&&deletethis._events[r],this;if(0===arguments.length){for(ninthis._events)"removeListener"!==n&&this.removeAllListeners(n);returnthis.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[r],t(e))this.removeListener(r,e);elseif(e)for(;e.length;)this.removeListener(r,e[e.length-1]);returndeletethis._events[r],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.prototype.listenerCount=function(r){if(this._events){vare=this._events[r];if(t(e))return1;if(e)returne.length}return0},e.listenerCount=function(e,t){returne.listenerCount(t)}},{}]
this.nextLoadPosition=this.startPosition),this.state===e.WAITING_LEVEL&&(this.state=e.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===e.KEY_LOADING&&(this.state=e.IDLE,this.tick())}},{key:"onFragLoaded",value:function(a){varn=this.fragCurrent;if(this.state===e.FRAG_LOADING&&n&&a.frag.level===n.level&&a.frag.sn===n.sn)if(this.fragBitrateTest===!0)this.state=e.IDLE,this.fragBitrateTest=!1,a.stats.tparsed=a.stats.tbuffered=performance.now(),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:a.stats,frag:n});else{this.state=e.PARSING,this.stats=a.stats;vars=this.levels[this.level],o=s.details,d=o.totalduration,f=n.start,l=n.level,u=n.sn,i=s.audioCodec||this.config.defaultAudioCodec;this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),void0===i&&(i=this.lastAudioCodec),i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingAppending=0,t.logger.log("Demuxing "+u+" of ["+o.startSN+" ,"+o.endSN+"],level "+l),this.demuxer.push(a.payload,i,s.videoCodec,f,n.cc,l,u,d,n.decryptdata)}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(l){if(this.state===e.PARSING){vars,n,a=l.tracks;if(n=a.audio){varo=this.levels[this.level].audioCodec;if(o&&this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch){varu=navigator.userAgent.toLowerCase();1!==n.metadata.channelCount&&-1===u.indexOf("android")&&-1===u.indexOf("firefox")&&(o="mp4a.40.5")}n.levelCodec=o}if(n=a.video,n&&(n.levelCodec=this.levels[this.level].videoCodec),l.unique){vari={codec:"",levelCodec:""};for(sinl.tracks)n=a[s],i.container=n.container,i.codec&&(i.codec+=",",i.levelCodec+=","),n.codec&&(i.codec+=n.codec),n.levelCodec&&(i.levelCodec+=n.levelCodec);a={audiovideo:i}}this.hls.trigger(r.default.BUFFER_CODECS,a);for(sina){n=a[s],t.logger.log("track:"+s+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");vard=n.initSegment;d&&(this.pendingAppending++,this.hls.trigger(r.default.BUFFER_APPENDING,{type:s,data:d}))}this.tick()}}},{key:"onFragParsingData",value:function(n){varo=this;if(this.state===e.PARSING){this.tparse2=Date.now();vara=this.levels[this.level],i=this.fragCurrent;t.logger.log("parsed "+n.type+",PTS:["+n.startPTS.toFixed(3)+","+n.endPTS.toFixed(3)+"],DTS:["+n.startDTS.toFixed(3)+"/"+n.endDTS.toFixed(3)+"],nb:"+n.nb);varu=l.default.updateFragPTS(a.details,i.sn,n.startPTS,n.endPTS),s=this.hls;s.trigger(r.default.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:u}),[n.data1,n.data2].forEach(function(e){e&&(o.pendingAppending++,s.trigger(r.default.BUFFER_APPENDING,{type:n.type,data:e}))}),this.nextLoadPosition=n.endPTS,this.bufferRange.push({type:n.type,start:n.startPTS,end:n.endPTS,frag:i}),this.tick()}elset.logger.warn("not in PARSING state but "+this.state+", ignoring FRAG_PARSING_DATA event")}},{key:"onFragParsed",value:function(){this.state===e.PARSING&&(this.stats.tparsed=performance.now(),this.state=e.PARSED,this._checkAppendedParsed())}},{key:"onBufferAppended",value:function(){switch(this.state){casee.PARSING:casee.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===e.PARSED&&0===this.pendingAppending){vara=this.fragCurrent,n=this.stats;a&&(this.fragPrevious=a,n.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*n.length/(n.tbuffered-n.tfirst)),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:n,frag:a}),t.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=e.IDLE),this.tick()}}},{key:"onError",value:function(a){switch(a.details){casen.ErrorDetails.FRAG_LOAD_ERROR:casen.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!a.fatal){vari=this.fragLoadError;if(i?i++:i=1,i<=this.config.fragLoadingMaxRetry){this.fragLoadError=i,a.frag.loadCounter=0;vars=Math.min(Math.pow(2,i-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_RE
s={data:[],size:0}}s&&(s.data.push(n.subarray(a,t+188)),s.size+=t+188-a)}elseif(u===f){if(d){if(o&&(this._parseAACPES(this._parsePES(o)),E&&this._aacTrack.codec&&(-1===h||this._avcTrack.codec)))returnvoidthis.remux(n);o={data:[],size:0}}o&&(o.data.push(n.subarray(a,t+188)),o.size+=t+188-a)}elseu===g&&(d&&(l&&this._parseID3PES(this._parsePES(l)),l={data:[],size:0}),l&&(l.data.push(n.subarray(a,t+188)),l.size+=t+188-a));elsed&&(a+=n[a]+1),0===u?this._parsePAT(n,a):u===this._pmtId&&(this._parsePMT(n,a),v=this.pmtParsed=!0,h=this._avcTrack.id,f=this._aacTrack.id,g=this._id3Track.id)}elsethis.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});s&&this._parseAVCPES(this._parsePES(s)),o&&this._parseAACPES(this._parsePES(o)),l&&this._parseID3PES(this._parsePES(l)),this.remux(null)}},{key:"remux",value:function(e){this.remuxer.remux(this._aacTrack,this._avcTrack,this._id3Track,this._txtTrack,this.timeOffset,this.contiguous,e)}},{key:"destroy",value:function(){this.switchLevel(),this._initPTS=this._initDTS=void0,this._duration=0}},{key:"_parsePAT",value:function(e,t){this._pmtId=(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(r,t){vara,i,s,n;for(a=(15&r[t+1])<<8|r[t+2],i=t+3+a-4,s=(15&r[t+10])<<8|r[t+11],t+=12+s;i>t;){switch(n=(31&r[t+1])<<8|r[t+2],r[t]){case15:this._aacTrack.id=n;break;case21:this._id3Track.id=n;break;case27:this._avcTrack.id=n;break;default:e.logger.log("unkown stream type:"+r[t])}t+=((15&r[t+3])<<8|r[t+4])+5}}},{key:"_parsePES",value:function(o){vare,i,h,d,u,l,n,r,t,f=0,s=o.data;if(e=s[0],h=(e[0]<<16)+(e[1]<<8)+e[2],1===h){for(d=(e[4]<<8)+e[5],i=e[7],192&i&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,n>4294967295&&(n-=8589934592),64&i?(r=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,r>4294967295&&(r-=8589934592)):r=n),u=e[8],t=u+9,o.size-=t,l=newUint8Array(o.size);s.length;){e=s.shift();vara=e.byteLength;if(t){if(t>a){t-=a;continue}e=e.subarray(t),a-=t,t=0}l.set(e,f),f+=a}return{data:l,pts:n,dts:r,len:d}}returnnull}},{key:"_parseAVCPES",value:function(n){vart,y,i,l,f=this,r=this._avcTrack,u=r.samples,m=this._parseAVCNALu(n.data),d=[],o=!1,c=!1,g=0;if(0===m.length&&u.length>0){varv=u[u.length-1],h=v.units.units[v.units.units.length-1],p=newUint8Array(h.data.byteLength+n.data.byteLength);p.set(h.data,0),p.set(n.data,h.data.byteLength),h.data=p,v.units.length+=n.data.byteLength,r.len+=n.data.byteLength}n.data=null;vara="";m.forEach(function(e){switch(e.type){case1:i=!0,o&&(a+="NDR ");break;case5:i=!0,o&&(a+="IDR "),c=!0;break;case6:i=!0,o&&(a+="SEI "),t=news.default(e.data),t.readUByte();varb=t.readUByte();if(4===b){varp=0;dop=t.readUByte();while(255===p);varR=t.readUByte();if(181===R){var_=t.readUShort();if(49===_){varA=t.readUInt();if(1195456820===A){varL=t.readUByte();if(3===L){varv=t.readUByte(),E=t.readUByte(),T=31&v,h=[v,E];for(l=0;T>l;l++)h.push(t.readUByte()),h.push(t.readUByte()),h.push(t.readUByte());f._txtTrack.samples.push({type:3,pts:n.pts,bytes:h})}}}}}break;case7:if(i=!0,o&&(a+="SPS "),!r.sps){t=news.default(e.data);vary=t.readSPS();r.width=y.width,r.height=y.height,r.sps=[e.data],r.timescale=f.remuxer.timescale,r.duration=f.remuxer.timescale*f._duration;vark=e.data.subarray(1,4),m="avc1.";for(l=0;3>l;l++){varu=k[l].toString(16);u.length<2&&(u="0"+u),m+=u}r.codec=m}break;case8:i=!0,o&&(a+="PPS "),r.pps||(r.pps=[e.data]);break;case9:i=!1,o&&(a+="AUD ");break;default:i=!1,a+="unknown NAL "+e.type+" "}i&&(d.push(e),g+=e.data.byteLength)}),(o||a.length)&&e.logger.log(a),d.length&&(c===!0||r.sps)&&(y={units:{units:d,length:g},pts:n.pts,dts:n.dts,key:c},u.push(y),r.len+=g,r.nbNalu+=d.length)}},{key:"_parseAVCNALu",value:function(r){for(vari,n,s,p,a,l,t=0,h=r.byteLength,e=0,d=[];h>t;)switch(i=r[t++],e){case0:0===i&&(e=1);break;case1:e=0===i?2:0;break;case2:case3:if(0===i)e=3;elseif(1===i&&h>t){if(p=31&r[t],a)s={data:r.subarray(a,t-e-1),type:l},d.push(s);else