!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.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){vara,n,t;if(n=this.getBufferRange(this.media.currentTime),n&&n.start>1&&(this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:n.start-1}),this.state=e.PAUSED),this.media.paused)a=0;else{varo=this.hls.nextLoadLevel,l=this.levels[o],s=this.fragLastKbps;a=s&&this.fragCurrent?this.fragCurrent.duration*l.bitrate/(1e3*s)+1:0}if(t=this.getBufferRange(this.media.currentTime+a),t&&(t=this.followingBufferRange(t))){this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:t.start,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED;vari=this.fragCurrent;i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold}}},{key:"onMediaAttached",value:function(t){vare=this.media=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended),this.levels&&this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onMediaDetaching",value:function(){vare=this.media;e&&e.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);varr=this.levels;r&&r.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void0})}),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeking",value:function(){if(this.state===e.FRAG_LOADING){if(0===s.default.bufferInfo(this.media,this.media.currentTime,this.config.maxBufferHole).len){t.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");varr=this.fragCurrent;r&&(r.loader&&r.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=e.IDLE}}elsethis.state===e.ENDED&&(this.state=e.IDLE);this.media&&(this.lastCurrentTime=this.media.currentTime),void0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){this.tick()}},{key:"onMediaEnded",value:function(){t.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){t.logger.log("trigger BUFFER_RESET"),this.hls.trigger(r.default.BUFFER_RESET),this.bufferRange=[],this.stalled=!1}},{key:"onManifestParsed",value:function(r){vare,n=!1,a=!1;r.levels.forEach(function(t){e=t.audioCodec,e&&(-1!==e.indexOf("mp4a.40.2")&&(n=!0),-1!==e.indexOf("mp4a.40.5")&&(a=!0))}),this.audioCodecSwitch=n&&a,this.audioCodecSwitch&&t.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startLevelLoaded=!1,this.startFragRequested=!1,this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onLevelLoaded",value:function(s){varn=s.details,a=s.level,o=this.levels[a],l=n.totalduration,i=0;if(t.logger.log("level "+a+" loaded ["+n.startSN+","+n.endSN+"],duration:"+l),this.levelLastLoaded=a,n.live){vard=o.details;d?(u.default.mergeDetails(d,n),i=n.fragments[0].start,n.PTSKnown?t.logger.log("live playlist sliding:"+i.toFixed(3)):t.logger.log("live playlist - outdated PTS, unknown sliding")):(n.PTSKnown=!1,t.logger.log("live playlist - first load, unknown sliding"))}elsen.PTSKnown=!1;if(o.details=n,this.hls.trigger(r.default.LEVEL_UPDATED,{details:n,level:a}),this.startFragRequested===!1){if(n.live){varf=void0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*n.targetduration;this.startPosition=Math.max(0,i+l-f)}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.f
}e&&(c=e[0]/e[1])}return{width:Math.ceil((16*(a+1)-2*s-2*d)*c),height:(2-n)*(i+1)*16-(n?2:4)*(f+h)}}},{key:"readSliceType",value:function(){returnthis.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=i},{"../utils/logger":36}],18:[function(r,s,t){"use strict";functionn(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}vara=function(){functione(n,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(n,e.key,e)}}returnfunction(t,r,n){returnr&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});vare=r("../utils/logger"),i=function(){functiont(a){n(this,t),this._hasTimeStamp=!1;for(varl,u,d,f,h,s,o,i,r=0;;)if(o=this.readUTF(a,r,3),r+=3,"ID3"===o)r+=3,l=127&a[r++],u=127&a[r++],d=127&a[r++],f=127&a[r++],h=(l<<21)+(u<<14)+(d<<7)+f,s=r+h,this._parseID3Frames(a,r,s),r=s;else{if("3DI"!==o)returnr-=3,i=r,void(i&&(this.hasTimeStamp||e.logger.warn("ID3 tag found, but no timestamp"),this._length=i,this._payload=a.subarray(0,i)));r+=7,e.logger.log("3DI footer found, end: "+r)}}returna(t,[{key:"readUTF",value:function(n,e,a){vart="",r=e,i=e+a;dot+=String.fromCharCode(n[r++]);while(i>r);returnt}},{key:"_parseID3Frames",value:function(r,t,i){for(vara,s,o,l,n;i>=t+8;)switch(a=this.readUTF(r,t,4),t+=4,s=r[t++]<<24+r[t++]<<16+r[t++]<<8+r[t++],l=r[t++]<<8+r[t++],o=t,a){case"PRIV":if("com.apple.streaming.transportStreamTimestamp"===this.readUTF(r,t,44)){t+=44,t+=4;varu=1&r[t++];this._hasTimeStamp=!0,n=((r[t++]<<23)+(r[t++]<<15)+(r[t++]<<7)+r[t++])/45,u&&(n+=47721858.84),n=Math.round(n),e.logger.trace("ID3 timestamp found: "+n),this._timeStamp=n}}}},{key:"hasTimeStamp",get:function(){returnthis._hasTimeStamp}},{key:"timeStamp",get:function(){returnthis._timeStamp}},{key:"length",get:function(){returnthis._length}},{key:"payload",get:function(){returnthis._payload}}]),t}();t.default=i},{"../utils/logger":36}],19:[function(t,v,a){"use strict";functionn(e){returne&&e.__esModule?e:{default:e}}functionu(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}varf=function(){functione(n,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(n,e.key,e)}}returnfunction(t,r,n){returnr&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});varh=t("./adts"),c=n(h),l=t("../events"),i=n(l),d=t("./exp-golomb"),s=n(d),e=t("../utils/logger"),r=t("../errors"),o=function(){functiont(e,r){u(this,t),this.observer=e,this.remuxerClass=r,this.lastCC=0,this.remuxer=newthis.remuxerClass(e)}returnf(t,[{key:"switchLevel",value:function(){this.pmtParsed=!1,this._pmtId=-1,this.lastAacPTS=null,this.aacOverFlow=null,this._avcTrack={container:"video/mp2t",type:"video",id:-1,sequenceNumber:0,samples:[],len:0,nbNalu:0},this._aacTrack={container:"video/mp2t",type:"audio",id:-1,sequenceNumber:0,samples:[],len:0},this._id3Track={type:"id3",id:-1,sequenceNumber:0,samples:[],len:0},this._txtTrack={type:"text",id:-1,sequenceNumber:0,samples:[],len:0},this.remuxer.switchLevel()}},{key:"insertDiscontinuity",value:function(){this.switchLevel(),this.remuxer.insertDiscontinuity()}},{key:"push",value:function(n,R,L,_,p,m,E,A){vars,o,l,t,d,u,y,a,c=n.length,b=this.remuxer.passthrough;this.audioCodec=R,this.videoCodec=L,this.timeOffset=_,this._duration=A,this.contiguous=!1,p!==this.lastCC?(e.logger.log("discontinuity detected"),this.insertDiscontinuity(),this.lastCC=p):m!==this.lastLevel?(e.logger.log("level switch detected"),this.switchLevel(),this.lastLevel=m):E===this.lastSN+1&&(this.contiguous=!0),this.lastSN=E,this.contiguous||(this.aacOverFlow=null);varg=this.pmtParsed,h=this._avcTrack.id,f=this._aacTrack.id,v=this._id3Track.id;for(c-=c%188,t=0;c>t;t+=188)if(71===n[t]){if(d=!!(64&n[t+1]),u=((31&n[t+1])<<8)+n[t+2],y=(48&n[t+3])>>4,y>1){if(a=t+5+n[t+4],a===t+188)continue}elsea=t+4;if(g)if(u===h){if(d){if(s&&(this._parseAVCPES(this._parsePES(s)),b&&this._avc
e.name=r.NAME;vart=r.CODECS;if(t){t=t.split(",");for(varo=0;o<t.length;o++){vari=t[o];-1!==i.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(i):e.audioCodec=i}}l.push(e)}returnl}},{key:"avc1toavcoti",value:function(r){vare,t=r.split(".");returnt.length>2?(e=t.shift()+".",e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).substr(-4)):e=r,e}},{key:"cloneObj",value:function(e){returnJSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(L,l,A){vare,b,s,i,g=0,o=0,n={url:l,fragments:[],live:!0,startSN:0},r={method:null,key:null,iv:null,uri:null},E=0,f=null,t=null;for(b=/(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.*))|(?:#EXT(INF):([\d\.]+)[^\r\n]*([\r\n]+[^#|\r\n]+)?)|(?:#EXT-X-(BYTERANGE):([\d]+[@[\d]*)]*[\r\n]+([^#|\r\n]+)?|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.*))/g;null!==(e=b.exec(L));)switch(e.shift(),e=e.filter(function(e){returnvoid0!==e}),e[0]){case"MEDIA-SEQUENCE":g=n.startSN=parseInt(e[1]);break;case"TARGETDURATION":n.targetduration=parseFloat(e[1]);break;case"ENDLIST":n.live=!1;break;case"DIS":E++;break;case"BYTERANGE":varc=e[1].split("@");i=1===c.length?s:parseInt(c[1]),s=parseInt(c[0])+i,t&&!t.url&&(t.byteRangeStartOffset=i,t.byteRangeEndOffset=s,t.url=this.resolve(e[2],l));break;case"INF":varv=parseFloat(e[1]);if(!isNaN(v)){varu,m=g++;if(r.method&&r.uri&&!r.iv){u=this.cloneObj(r);for(vary=newUint8Array(16),d=12;16>d;d++)y[d]=m>>8*(15-d)&255;u.iv=y}elseu=r;vark=e[2]?this.resolve(e[2],l):null;t={url:k,duration:v,start:o,sn:m,level:A,cc:E,byteRangeStartOffset:i,byteRangeEndOffset:s,decryptdata:u,programDateTime:f},n.fragments.push(t),o+=v,i=null,f=null}break;case"KEY":varR=e[1],p=newa.default(R),h=p.enumeratedString("METHOD"),_=p.URI,S=p.hexadecimalInteger("IV");h&&(r={method:null,key:null,iv:null,uri:null},_&&"AES-128"===h&&(r.method=h,r.uri=this.resolve(_,l),r.key=null,r.iv=S));break;case"PROGRAM-DATE-TIME":f=newDate(Date.parse(e[1]))}returnt&&!t.url&&(n.fragments.pop(),o-=t.duration),n.totalduration=o,n.endSN=g-1,n}},{key:"loadsuccess",value:function(u,n){vars,o=u.currentTarget,i=o.responseText,r=o.responseURL,l=this.id,d=this.id2,a=this.hls;if(void0===r&&(r=this.url),n.tload=performance.now(),n.mtime=newDate(o.getResponseHeader("Last-Modified")),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0)if(null===this.id)a.trigger(t.default.MANIFEST_LOADED,{levels:[{url:r}],url:r,stats:n});else{varf=this.parseLevelPlaylist(i,r,l);n.tparsed=performance.now(),a.trigger(t.default.LEVEL_LOADED,{details:f,level:l,id:d,stats:n})}elses=this.parseMasterPlaylist(i,r),s.length?a.trigger(t.default.MANIFEST_LOADED,{levels:s,url:r,stats:n}):a.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no level found in manifest"});elsea.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(a){varr,n;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0):(r=e.ErrorDetails.LEVEL_LOAD_ERROR,n=!1),this.loader&&this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:n,url:this.url,loader:this.loader,response:a.currentTarget,level:this.id,id:this.id2})}},{key:"loadtimeout",value:function(){varr,n;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_TIMEOUT,n=!0):(r=e.ErrorDetails.LEVEL_LOAD_TIMEOUT,n=!1),this.loader&&this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:n,url:this.url,loader:this.loader,level:this.id,id:this.id2})}}]),r}(i.default);s.default=u},{"../errors":20,"../event-handler":21,"../events":22,"../utils/attr-list":33,"../utils/url":37}],30:[function(a,i,e){"use strict";functiont(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}varr=function(){functione(n,r){for(vart=0;t<r.length;t++){vare=r[t];e.enumerable=e.enumerable||!1,e.configurable=