!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(i,d){if(!t[i]){if(!e[i]){varl="function"==typeofrequire&&require;if(!d&&l)returnl(i,!0);if(a)returna(i,!0);varu=newError("Cannot find module '"+i+"'");throwu.code="MODULE_NOT_FOUND",u}varo=t[i]={exports:{}};e[i][0].call(o.exports,function(t){varr=e[i][1][t];returnn(r?r:t)},o,o.exports,s,e,t,r)}returnt[i].exports}for(vara="function"==typeofrequire&&require,i=0;i<r.length;i++)n(r[i]);returnn}({1:[function(s,i,o){functione(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functiont(e){return"function"==typeofe}functiona(e){return"number"==typeofe}functionr(e){return"object"==typeofe&&null!==e}functionn(e){returnvoid0===e}i.exports=e,e.EventEmitter=e,e.prototype._events=void0,e.prototype._maxListeners=void0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!a(e)||0>e||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},e.prototype.emit=function(l){vars,e,u,i,a,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:i=Array.prototype.slice.call(arguments,1),e.apply(this,i)}elseif(r(e))for(i=Array.prototype.slice.call(arguments,1),o=e.slice(),u=o.length,a=0;u>a;a++)o[a].apply(this,i);return!0},e.prototype.addListener=function(i,a){vars;if(!t(a))throwTypeError("listener must be a function");returnthis._events||(this._events={}),this._events.newListener&&this.emit("newListener",i,t(a.listener)?a.listener:a),this._events[i]?r(this._events[i])?this._events[i].push(a):this._events[i]=[this._events[i],a]:this._events[i]=a,r(this._events[i])&&!this._events[i].warned&&(s=n(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[i].length>s&&(this._events[i].warned=!0,"function"==typeofconsole.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(n,e){functionr(){this.removeListener(n,r),i||(i=!0,e.apply(this,arguments))}if(!t(e))throwTypeError("listener must be a function");vari=!1;returnr.listener=e,this.on(n,r),this},e.prototype.removeListener=function(i,n){vare,s,o,a;if(!t(n))throwTypeError("listener must be a function");if(!this._events||!this._events[i])returnthis;if(e=this._events[i],o=e.length,s=-1,e===n||t(e.listener)&&e.listener===n)deletethis._events[i],this._events.removeListener&&this.emit("removeListener",i,n);elseif(r(e)){for(a=o;a-->0;)if(e[a]===n||e[a].listener&&e[a].listener===n){s=a;break}if(0>s)returnthis;1===e.length?(e.length=0,deletethis._events[i]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",i,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(){vari,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)i=0;else{varo=this.hls.nextLoadLevel,l=this.levels[o],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*l.bitrate/(1e3*s)+1:0}if(t=this.getBufferRange(this.media.currentTime+i),t&&(t=this.followingBufferRange(t))){this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:t.start,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED;vara=this.fragCurrent;a&&a.loader&&a.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,i=!1;r.levels.forEach(function(t){e=t.audioCodec,e&&(-1!==e.indexOf("mp4a.40.2")&&(n=!0),-1!==e.indexOf("mp4a.40.5")&&(i=!0))}),this.audioCodecSwitch=n&&i,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,i=s.level,o=this.levels[i],l=n.totalduration,a=0;if(t.logger.log("level "+i+" loaded ["+n.startSN+","+n.endSN+"],duration:"+l),this.levelLastLoaded=i,n.live){vard=o.details;d?(u.default.mergeDetails(d,n),a=n.fragments[0].start,n.PTSKnown?t.logger.log("live playlist sliding:"+a.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:i}),this.startFragRequested===!1){if(n.live){varf=void0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*n.targetduration;this.startPosition=Math.max(0,a+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(i){varn=this.f
break;case11:e=[15,11];break;case12:e=[64,33];break;case13:e=[160,99];break;case14:e=[4,3];break;case15:e=[3,2];break;case16:e=[2,1];break;case255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}e&&(c=e[0]/e[1])}return{width:Math.ceil((16*(i+1)-2*s-2*d)*c),height:(2-n)*(a+1)*16-(n?2:4)*(f+h)}}},{key:"readSliceType",value:function(){returnthis.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=a},{"../utils/logger":36}],18:[function(r,s,t){"use strict";functionn(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}vari=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"),a=function(){functiont(i){n(this,t),this._hasTimeStamp=!1;for(varl,u,d,f,h,s,o,a,r=0;;)if(o=this.readUTF(i,r,3),r+=3,"ID3"===o)r+=3,l=127&i[r++],u=127&i[r++],d=127&i[r++],f=127&i[r++],h=(l<<21)+(u<<14)+(d<<7)+f,s=r+h,this._parseID3Frames(i,r,s),r=s;else{if("3DI"!==o)returnr-=3,a=r,void(a&&(this.hasTimeStamp||e.logger.warn("ID3 tag found, but no timestamp"),this._length=a,this._payload=i.subarray(0,a)));r+=7,e.logger.log("3DI footer found, end: "+r)}}returni(t,[{key:"readUTF",value:function(n,e,i){vart="",r=e,a=e+i;dot+=String.fromCharCode(n[r++]);while(a>r);returnt}},{key:"_parseID3Frames",value:function(r,t,a){for(vari,s,o,l,n;a>=t+8;)switch(i=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,i){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=a},{"../utils/logger":36}],19:[function(t,v,i){"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(i,"__esModule",{value:!0});varh=t("./adts"),c=n(h),l=t("../events"),a=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,i,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;f
vare={},r=e.attrs=newi.default(n[1]);e.url=this.resolve(n[2],u);vars=r.decimalResolution("RESOLUTION");s&&(e.width=s.width,e.height=s.height),e.bitrate=r.decimalInteger("BANDWIDTH"),e.name=r.NAME;vart=r.CODECS;if(t){t=t.split(",");for(varo=0;o<t.length;o++){vara=t[o];-1!==a.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(a):e.audioCodec=a}}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,a,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("@");a=1===c.length?s:parseInt(c[1]),s=parseInt(c[0])+a,t&&!t.url&&(t.byteRangeStartOffset=a,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:a,byteRangeEndOffset:s,decryptdata:u,programDateTime:f},n.fragments.push(t),o+=v,a=null,f=null}break;case"KEY":varR=e[1],p=newi.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,a=o.responseText,r=o.responseURL,l=this.id,d=this.id2,i=this.hls;if(void0===r&&(r=this.url),n.tload=performance.now(),n.mtime=newDate(o.getResponseHeader("Last-Modified")),0===a.indexOf("#EXTM3U"))if(a.indexOf("#EXTINF:")>0)if(null===this.id)i.trigger(t.default.MANIFEST_LOADED,{levels:[{url:r}],url:r,stats:n});else{varf=this.parseLevelPlaylist(a,r,l);n.tparsed=performance.now(),i.trigger(t.default.LEVEL_LOADED,{details:f,level:l,id:d,stats:n})}elses=this.parseMasterPlaylist(a,r),s.length?i.trigger(t.default.MANIFEST_LOADED,{levels:s,url:r,stats:n}):i.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"});elsei.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(i){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:i.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}(a.default);s.default=u},{"../errors":20,"../event-handler":21,"../events":22,"../utils/attr-list":33,"../utils/url":37}],30:[function(i,a,e){"use strict";functiont(e,t){if(!(eins