!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.Hls=e()}}(function(){return function e(t,r,a){function i(s,o){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(n)return n(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=r[s]={exports:{}};t[s][0].call(d.exports,function(e){var r=t[s][1][e];return i(r?r:e)},d,d.exports,e,t,r,a)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s0&&this._events[e].length>r&&(this._events[e].warned=!0,"function"==typeof console.trace)),this},a.prototype.on=a.prototype.addListener,a.prototype.once=function(e,t){function r(){this.removeListener(e,r),a||(a=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var a=!1;return r.listener=t,this.on(e,r),this},a.prototype.removeListener=function(e,t){var r,a,n,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],n=r.length,a=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(o=n;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){a=o;break}if(a<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},a.prototype.removeAllListeners=function(e){var t,r;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(r=this._events[e],i(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},a.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},a.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},a.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,r){var a=arguments[3],i=arguments[4],n=arguments[5],s=JSON.stringify;t.exports=function(e){for(var t,r=Object.keys(n),o=0,l=r.length;o500*r.duration){var i=e.levels,n=Math.max(1,1e3*r.loaded/a),s=Math.max(r.loaded,Math.round(r.duration*i[r.level].bitrate/8)),o=t.currentTime,l=(s-r.loaded)/n,d=c.default.bufferInfo(t,o,e.config.maxBufferHole).end-o;if(d<2*r.duration&&l>d){var f=void 0,h=void 0;for(h=r.level-1;h>=0&&(f=r.duration*i[h].bitrate/(6.4*n),!(f=0;l--){var u=o[l],d=u.details,f=d?d.totalduration/d.fragments.length:t,h=void 0;h=l<=e?n*r:s*r;var c=o[l].bitrate,v=c*f/h;if(g.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+l+"/"+Math.round(h)+"/"+c+"/"+f+"/"+i+"/"+v),h>c&&(!v||v=0)return f;g.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var h=a.maxStarvationDelay;if(0===d){var v=this.bitrateTestDelay;v&&(h-=v,g.logger.trace("bitrate test took "+Math.round(1e3*v)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*h)+" ms"))}return f=this.findBestLevel(n,s,u,t,d+h,a.abrBandWidthFactor,a.abrBandWidthUpFactor,r),Math.max(f,0)}}]),t}(f.default);r.default=m},{"../errors":21,"../event-handler":22,"../events":23,"../helper/buffer-helper":24,"../utils/logger":38,"./ewma-bandwidth-estimator":6}],4:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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 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(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;rthis._msDuration&&(h.logger.log("Updating mediasource duration to "+this._levelDuration),t.duration=this._levelDuration,this._msDuration=this._levelDuration)}}}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;if(r)for(var a in r)t+=r[a].buffered.length;this.appended=t,this.hls.trigger(u.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.sourceBuffer,r=this.segments;if(t){if(this.media.error)return r=[],void h.logger.error("trying to append although a media error occured, flush segment and abort");for(var a in t)if(t[a].updating)return;if(r.length){var i=r.shift();try{t[i.type].appendBuffer(i.data),this.appendError=0,this.appended++}catch(t){h.logger.error("error while trying to append buffer:"+t.message),r.unshift(i);var n={type:c.ErrorTypes.MEDIA_ERROR};if(22===t.code)return this.segments=[],n.details=c.ErrorDetails.BUFFER_FULL_ERROR,void e.trigger(u.default.ERROR,n);if(this.appendError?this.appendError++:this.appendError=1,n.details=c.ErrorDetails.BUFFER_APPEND_ERROR,n.frag=this.fragCurrent,this.appendError>e.config.appendErrorMaxRetry)return h.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],n.fatal=!0,void e.trigger(u.default.ERROR,n);n.fatal=!1,e.trigger(u.default.ERROR,n)}}}}},{key:"flushBuffer",value:function(e,t){var r,a,i,n,s,o;if(this.flushBufferCounter.5)return this.flushBufferCounter++,h.logger.log("flush "+l+" ["+s+","+o+"], of ["+i+","+n+"], pos:"+this.media.currentTime),r.remove(s,o),!1}else h.logger.warn("abort flushing too many retries");return h.logger.log("buffer flushed"),!0}}]),t}(f.default);r.default=v},{"../errors":21,"../event-handler":22,"../events":23,"../utils/logger":38}],5:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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 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(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;rthis.autoLevelCapping&&this.hls.streamController.nextLevelSwitch(),this.autoLevelCapping=this.hls.autoLevelCapping)}}},{key:"getMaxLevel",value:function(e){var t=void 0,r=void 0,a=void 0,i=this.mediaWidth,n=this.mediaHeight,s=0,o=0;for(r=0;r<=e&&(a=this.levels[r],t=r,s=a.width,o=a.height,!(i<=s||n<=o));r++);return t}},{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}},{key:"mediaWidth",get:function(){var e=void 0;return this.media&&(e=this.media.width||this.media.clientWidth||this.media.offsetWidth,e*=this.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e=void 0;return this.media&&(e=this.media.height||this.media.clientHeight||this.media.offsetHeight,e*=this.contentScaleFactor),e}}]),t}(f.default);r.default=h},{"../event-handler":22,"../events":23}],6:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();r.default=l},{"../utils/ewma":37}],7:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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 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(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=0&&e1e3){var i=r.urlId;this.hls.trigger(u.default.LEVEL_LOADING,{url:r.url[i],level:e,id:i})}}else this.hls.trigger(u.default.ERROR,{type:c.ErrorTypes.OTHER_ERROR,details:c.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(e){if(!e.fatal){var t=e.details,r=this.hls,a=void 0,i=void 0,n=!1;switch(t){case c.ErrorDetails.FRAG_LOAD_ERROR:case c.ErrorDetails.FRAG_LOAD_TIMEOUT:case c.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case c.ErrorDetails.KEY_LOAD_ERROR:case c.ErrorDetails.KEY_LOAD_TIMEOUT:a=e.frag.level;break;case c.ErrorDetails.LEVEL_LOAD_ERROR:case c.ErrorDetails.LEVEL_LOAD_TIMEOUT:a=e.level,n=!0}if(void 0!==a)if(i=this._levels[a],i.urlIde&&(this._level===e&&void 0!==t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,void 0===this._startLevel&&(this._startLevel=e),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){return void 0===this._startLevel?this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return this._manualLevel!==-1?this._manualLevel:this.hls.abrController.nextAutoLevel},set:function(e){this.level=e,this._manualLevel===-1&&(this.hls.abrController.nextAutoLevel=e)}}]),t}(f.default);r.default=v},{"../errors":21,"../event-handler":22,"../events":23,"../utils/logger":38}],8:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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 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(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r0?(v.logger.log("configure startPosition @"+r),this.lastPaused||(v.logger.log("resuming video"),t.play())):this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=this.startFragRequested?R.IDLE:R.STARTING,this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else v.logger.warn("cannot start loading as manifest not parsed yet"),this.state=R.STOPPED}},{key:"stopLoad",value:function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=R.STOPPED}},{key:"tick",value:function(){this.ticks++,1===this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){var e,t,r,a=this.hls,i=a.config,n=this.media,s=n&&n.seeking;switch(this.state){case R.ERROR:case R.PAUSED:break;case R.STARTING:var o=a.startLevel;o===-1&&(o=0,this.fragBitrateTest=!0),this.level=a.nextLoadLevel=o,this.state=R.WAITING_LEVEL,this.loadedmetadata=!1;break;case R.IDLE:if(!n&&(this.startFragRequested||!i.startFragPrefetch))break;e=this.loadedmetadata?n.currentTime:this.nextLoadPosition,t=a.nextLoadLevel;var l,u=m.default.bufferInfo(n,e,i.maxBufferHole),d=u.len,h=u.end,c=this.fragPrevious;if(l=this.levels[t].hasOwnProperty("bitrate")?Math.max(8*i.maxBufferSize/this.levels[t].bitrate,i.maxBufferLength):i.maxBufferLength, l=Math.min(l,i.maxMaxBufferLength),dk&&(n.currentTime=k)}if(r.PTSKnown&&h>b)break;if(this.startFragRequested&&!r.PTSKnown){if(c){var S=c.sn+1;S>=r.startSN&&S<=r.endSN&&(A=g[S-r.startSN],v.logger.log("live playlist, switching playlist, load frag with next SN: "+A.sn))}A||(A=g[Math.min(y-1,Math.round(y/2))],v.logger.log("live playlist, switching playlist, unknown, load middle frag : "+A.sn))}}else hb-e||s)&&(e=0),A=p.default.search(g,function(t){return t.start+t.duration-e<=h?1:t.start-e>h?-1:0})):A=g[y-1]}(),A){if(E=A.start,c&&A.level===c.level&&A.sn===c.sn){if(!(A.sni.maxBufferHole&&c.dropped?(A=g[D-1],v.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this"),c.loadCounter--):(A=g[D+1],v.logger.log("SN just loaded, load next one: "+A.sn)),!A)break}if(null!=A.decryptdata.uri&&null==A.decryptdata.key)v.logger.log("Loading key for "+A.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+t),this.state=R.KEY_LOADING,a.trigger(f.default.KEY_LOADING,{frag:A});else{if(v.logger.log("Loading "+A.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+t+", currentTime:"+e.toFixed(3)+",bufferEnd:"+h.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,A.loadCounter){A.loadCounter++;var O=i.fragLoadingLoopThreshold;if(A.loadCounter>O&&Math.abs(this.fragLoadIdx-A.loadIdx)=x||s)&&(v.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=R.IDLE);break;case R.STOPPED:case R.FRAG_LOADING:case R.PARSING:case R.PARSED:case R.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"getBufferRange",value:function(e){var t,r,a=this.bufferRange;if(a)for(t=a.length-1;t>=0;t--)if(r=a[t],e>=r.start&&e<=r.end)return r;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(e){var t=this.media;if(t)for(var r=t.buffered,a=0;a=r.start(a)&&e<=r.end(a))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var e,t,r=this.media;if(r&&r.seeking===!1&&(t=r.currentTime,t>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=t),this.isBuffered(t)?e=this.getBufferRange(t):this.isBuffered(t+.1)&&(e=this.getBufferRange(t+.1)),e)){var a=e.frag;a!==this.fragPlaying&&(this.fragPlaying=a,this.hls.trigger(f.default.FRAG_CHANGED,{frag:a}))}}},{key:"immediateLevelSwitch",value:function(){if(v.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e=this.media,t=void 0;e?(t=e.paused,e.pause()):t=!0,this.previouslyPaused=t}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=R.PAUSED,this.hls.trigger(f.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY})}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1;var e=this.media;e&&e.readyState&&(e.currentTime-=1e-4,this.previouslyPaused||e.play())}},{key:"nextLevelSwitch",value:function(){var e=this.media;if(e&&e.readyState){var t=void 0,r=void 0,a=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferRange(e.currentTime),r&&r.start>1&&(this.state=R.PAUSED,this.hls.trigger(f.default.BUFFER_FLUSHING,{startOffset:0,endOffset:r.start-1})),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}if(a=this.getBufferRange(e.currentTime+t),a&&(a=this.followingBufferRange(a))){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.state=R.PAUSED,this.hls.trigger(f.default.BUFFER_FLUSHING,{startOffset:a.start,endOffset:Number.POSITIVE_INFINITY})}}}},{key:"onMediaAttached",value:function(e){var t=this.media=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(v.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void 0})}),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===R.FRAG_LOADING){if(0===m.default.bufferInfo(this.media,this.media.currentTime,this.config.maxBufferHole).len){v.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=R.IDLE}}else this.state===R.ENDED&&(this.state=R.IDLE);this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){this.tick()}},{key:"onMediaEnded",value:function(){v.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){v.logger.log("trigger BUFFER_RESET"),this.hls.trigger(f.default.BUFFER_RESET),this.bufferRange=[],this.stalled=!1}},{key:"onManifestParsed",value:function(e){var t,r=!1,a=!1;e.levels.forEach(function(e){t=e.audioCodec,t&&(t.indexOf("mp4a.40.2")!==-1&&(r=!0),t.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=r&&a,this.audioCodecSwitch&&v.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startLevelLoaded=!1,this.startFragRequested=!1;var i=this.config;i.autoStartLoad&&this.hls.startLoad(i.startPosition)}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,a=this.levels[r],i=t.totalduration,n=0;if(v.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),this.levelLastLoaded=r,t.live){var s=a.details;s?(b.default.mergeDetails(s,t),n=t.fragments[0].start,t.PTSKnown?v.logger.log("live playlist sliding:"+n.toFixed(3)):v.logger.log("live playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,v.logger.log("live playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(a.details=t,this.hls.trigger(f.default.LEVEL_UPDATED,{details:t,level:r}),this.startFragRequested===!1){if(this.startPosition===-1){var o=t.startTimeOffset;if(isNaN(o))if(t.live){var l=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;this.startPosition=Math.max(0,n+i-l)}else this.startPosition=0;else v.logger.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o}this.nextLoadPosition=this.startPosition}this.state===R.WAITING_LEVEL&&(this.state=R.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===R.KEY_LOADING&&(this.state=R.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===R.FRAG_LOADING&&t&&r.level===t.level&&r.sn===t.sn){var a=e.stats,i=this.levels[t.level],n=i.details;if(v.logger.log("Loaded "+t.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+t.level),this.fragBitrateTest=!1,r.bitrateTest===!0&&this.hls.nextLoadLevel)this.state=R.IDLE,this.startFragRequested=!1,a.tparsed=a.tbuffered=performance.now(),this.hls.trigger(f.default.FRAG_BUFFERED,{stats:a,frag:t}),this.tick();else{this.state=R.PARSING,this.stats=a;var s=n.totalduration,o=void 0===t.startDTS||isNaN(t.startDTS)?t.start:t.startDTS,l=t.level,u=t.sn,d=i.audioCodec||this.config.defaultAudioCodec;this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),void 0===d&&(d=this.lastAudioCodec),d&&(d=d.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5")),this.pendingAppending=0,v.logger.log("Parsing "+u+" of ["+n.startSN+" ,"+n.endSN+"],level "+l+", cc "+t.cc);var h=this.demuxer;h&&h.push(e.payload,d,i.videoCodec,o,t.cc,l,u,s,t.decryptdata)}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){if(this.state===R.PARSING){var t,r,a=e.tracks;if(r=a.audio){var i=this.levels[this.level].audioCodec,n=navigator.userAgent.toLowerCase();i&&this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),i=i.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==r.metadata.channelCount&&n.indexOf("firefox")===-1&&(i="mp4a.40.5"),n.indexOf("android")!==-1&&(i="mp4a.40.2",v.logger.log("Android: force audio codec to"+i)),r.levelCodec=i}if(r=a.video,r&&(r.levelCodec=this.levels[this.level].videoCodec),e.unique){var s={codec:"",levelCodec:""};for(t in e.tracks)r=a[t],s.container=r.container,s.codec&&(s.codec+=",",s.levelCodec+=","),r.codec&&(s.codec+=r.codec),r.levelCodec&&(s.levelCodec+=r.levelCodec);a={audiovideo:s}}this.hls.trigger(f.default.BUFFER_CODECS,a);for(t in a){r=a[t],v.logger.log("track:"+t+",container:"+r.container+",codecs[level/parsed]=["+r.levelCodec+"/"+r.codec+"]");var o=r.initSegment;o&&(this.pendingAppending++,this.hls.trigger(f.default.BUFFER_APPENDING,{type:t,data:o}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this;if(this.state===R.PARSING){this.tparse2=Date.now();var r=this.levels[this.level],a=this.fragCurrent;v.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0));var i=b.default.updateFragPTSDTS(r.details,a.sn,e.startPTS,e.endPTS,e.startDTS,e.endDTS),n=this.hls;n.trigger(f.default.LEVEL_PTS_UPDATED,{details:r.details,level:this.level,drift:i}),"video"===e.type&&(a.dropped=e.dropped),[e.data1,e.data2].forEach(function(r){r&&(t.pendingAppending++,n.trigger(f.default.BUFFER_APPENDING,{type:e.type,data:r}))}),this.nextLoadPosition=e.endPTS,this.bufferRange.push({type:e.type,start:e.startPTS,end:e.endPTS,frag:a}),this.tick()}else v.logger.warn("not in PARSING state but "+this.state+", ignoring FRAG_PARSING_DATA event")}},{key:"onFragParsed",value:function(){this.state===R.PARSING&&(this.stats.tparsed=performance.now(),this.state=R.PARSED,this._checkAppendedParsed())}},{key:"onBufferAppended",value:function(){switch(this.state){case R.PARSING:case R.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===R.PARSED&&0===this.pendingAppending){var e=this.fragCurrent,t=this.stats;e&&(this.fragPrevious=e,t.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*t.length/(t.tbuffered-t.tfirst)),this.hls.trigger(f.default.FRAG_BUFFERED,{stats:t,frag:e}),v.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=R.IDLE),this.tick()}}},{key:"onError",value:function(e){var t=this.media,r=t&&this.isBuffered(t.currentTime)&&this.isBuffered(t.currentTime+.4),a=e.frag||this.fragCurrent;switch(e.details){case _.ErrorDetails.FRAG_LOAD_ERROR:case _.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!e.fatal){var i=this.fragLoadError;if(i?i++:i=1,i<=this.config.fragLoadingMaxRetry||r){this.fragLoadError=i,a.loadCounter=0;var n=Math.min(Math.pow(2,i-1)*this.config.fragLoadingRetryDelay,64e3);v.logger.warn("mediaController: frag loading failed, retry in "+n+" ms"),this.retryDate=performance.now()+n,this.state=R.FRAG_LOADING_WAITING_RETRY}else v.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.trigger(f.default.ERROR,e),this.state=R.ERROR}break;case _.ErrorDetails.FRAG_LOOP_LOADING_ERROR:e.fatal||(r?(this._reduceMaxMaxBufferLength(a.duration),this.state=R.IDLE):a.autoLevel&&0!==a.level||(e.fatal=!0,this.hls.trigger(f.default.ERROR,e),this.state=R.ERROR));break;case _.ErrorDetails.LEVEL_LOAD_ERROR:case _.ErrorDetails.LEVEL_LOAD_TIMEOUT:case _.ErrorDetails.KEY_LOAD_ERROR:case _.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==R.ERROR&&(this.state=e.fatal?R.ERROR:R.IDLE,v.logger.warn("mediaController: "+e.details+" while loading frag,switch to "+this.state+" state ..."));break;case _.ErrorDetails.BUFFER_FULL_ERROR:this.state!==R.PARSING&&this.state!==R.PARSED||(this._reduceMaxMaxBufferLength(a.duration),this.state=R.IDLE)}}},{key:"_reduceMaxMaxBufferLength",value:function(e){this.config.maxMaxBufferLength>=e&&(this.config.maxMaxBufferLength/=2,v.logger.warn("reduce max buffer length to "+this.config.maxMaxBufferLength+"s and switch to IDLE state"),this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold)}},{key:"_checkBuffer",value:function(){var e=this.media;if(e&&e.readyState){var t=e.currentTime,r=e.buffered;if(!this.loadedmetadata&&r.length){this.loadedmetadata=!0;var a=this.startPosition;if(!t&&t!==a&&a){v.logger.log("target start position:"+a);var i=r.start(0),n=r.end(0);(an)&&(a=i,v.logger.log("target start position not buffered, seek to buffered.start(0) "+i.toFixed(3))),v.logger.log("adjust currentTime from "+t.toFixed(3)+" to "+a.toFixed(3)),e.currentTime=a}}else{var s=m.default.bufferInfo(e,t,0),o=!(e.paused||e.ended||0===e.buffered.length),l=.4,u=t>e.playbackRate*this.lastCurrentTime;if(this.stalled&&u&&(this.stalled=!1,v.logger.log("playback not stuck anymore @"+t)),o&&s.len<=l&&(u?(l=0,this.seekHoleNudgeDuration=0):this.stalled?this.seekHoleNudgeDuration+=this.config.seekHoleNudgeDuration:(this.seekHoleNudgeDuration=0,v.logger.log("playback seems stuck @"+t),this.hls.trigger(f.default.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0),s.len<=l)){var d=s.nextStart,h=d-t;if(d&&h0){v.logger.log("adjust currentTime from "+e.currentTime.toFixed(3)+" to next buffered @ "+d.toFixed(3)+" + nudge "+this.seekHoleNudgeDuration);var c=d+this.seekHoleNudgeDuration-e.currentTime;e.currentTime=d+this.seekHoleNudgeDuration,this.hls.trigger(f.default.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:c})}}}}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=R.IDLE,this.tick()}},{key:"onBufferFlushed",value:function(){var e,t,r=[];for(t=0;t>7))^e]=e;for(t=r=0;!f[t];t^=a||1,r=v[r]||1)for(s=r^r<<1^r<<2^r<<3^r<<4,s=s>>8^255&s^99,f[t]=s,h[s]=t,n=c[i=c[a=c[t]]],l=16843009*n^65537*i^257*a^16843008*t,o=257*c[s]^16843008*s,e=0;e<4;e++)u[e][t]=o=o<<24^o>>>8,d[e][s]=l=l<<24^l>>>8;for(e=0;e<5;e++)u[e]=u[e].slice(0),d[e]=d[e].slice(0)}},{key:"decrypt",value:function(e,t,r,a,i,n){var s,o,l,u,d=this._key[1],f=e^d[0],h=a^d[1],c=r^d[2],v=t^d[3],g=d.length/4-2,p=4,y=this._tables[1],m=y[0],E=y[1],b=y[2],_=y[3],R=y[4];for(u=0;u>>24]^E[h>>16&255]^b[c>>8&255]^_[255&v]^d[p],o=m[h>>>24]^E[c>>16&255]^b[v>>8&255]^_[255&f]^d[p+1],l=m[c>>>24]^E[v>>16&255]^b[f>>8&255]^_[255&h]^d[p+2],v=m[v>>>24]^E[f>>16&255]^b[h>>8&255]^_[255&c]^d[p+3],p+=4,f=s,h=o,c=l;for(u=0;u<4;u++)i[(3&-u)+n]=R[f>>>24]<<24^R[h>>16&255]<<16^R[c>>8&255]<<8^R[255&v]^d[p++],s=f,f=h,h=c,c=v,v=s}}]),e}();r.default=n},{}],11:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r>8|e>>>24}},{key:"doDecrypt",value:function(e,t,r){var a,i,n,s,l,u,d,f,h,c=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),v=new o.default(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),p=new Int32Array(g.buffer);for(a=~~r[0],i=~~r[1],n=~~r[2],s=~~r[3],h=0;h>>5,h-=p,h>0&&g+p+h<=m);)for(y=R+v*c,E={unit:e.subarray(g+p,g+p+h),pts:y,dts:y},b.samples.push(E),b.len+=h,g+=h+p,v++;g>>6)+1,o=(60&t[r+2])>>>2,o>h.length-1?void e.trigger(Event.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o}):(u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,n.logger.log("manifest codec:"+a+",ADTS data:type:"+i+",sampleingIndex:"+o+"["+h[o]+"Hz],channelConfig:"+u),f.indexOf("firefox")!==-1?o>=6?(i=5,d=new Array(4),l=o-3):(i=2,d=new Array(2),l=o):f.indexOf("android")!==-1?(i=2,d=new Array(2),l=o):(i=5,d=new Array(4),a&&(a.indexOf("mp4a.40.29")!==-1||a.indexOf("mp4a.40.5")!==-1)||!a&&o>=6?l=o-3:((a&&a.indexOf("mp4a.40.2")!==-1&&o>=6&&1===u||!a&&1===u)&&(i=2,d=new Array(2)),l=o)),d[0]=i<<3,d[0]|=(14&o)>>1,d[1]|=(1&o)<<7,d[1]|=u<<3,5===i&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:h[o],channelCount:u,codec:"mp4a.40."+i})}}]),e}();r.default=o},{"../errors":21,"../utils/logger":38}],15:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r1?r-1:0),i=1;i1?r-1:0),i=1;i0&&null!=l&&null!=l.key&&"AES-128"===l.method){null==this.decrypter&&(this.decrypter=new v.default(this.hls));var u=this;this.decrypter.decrypt(e,l.key,l.iv,function(e){u.pushDecrypted(e,t,r,a,i,n,s,o)})}else this.pushDecrypted(e,t,r,a,i,n,s,o)}},{key:"onWorkerMessage",value:function(e){var t=e.data;switch(t.event){case o.default.FRAG_PARSING_INIT_SEGMENT:var r={};r.tracks=t.tracks,r.unique=t.unique,this.hls.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,r);break;case o.default.FRAG_PARSING_DATA:this.hls.trigger(o.default.FRAG_PARSING_DATA,{data1:new Uint8Array(t.data1),data2:new Uint8Array(t.data2),startPTS:t.startPTS,endPTS:t.endPTS,startDTS:t.startDTS,endDTS:t.endDTS,type:t.type,nb:t.nb,dropped:t.dropped});break;case o.default.FRAG_PARSING_METADATA:this.hls.trigger(o.default.FRAG_PARSING_METADATA,{samples:t.samples});break;case o.default.FRAG_PARSING_USERDATA:this.hls.trigger(o.default.FRAG_PARSING_USERDATA,{samples:t.samples});break;default:this.hls.trigger(t.event,t.data)}}}]),t}();r.default=p},{"../crypt/decrypter":12,"../demux/demuxer-inline":15,"../demux/demuxer-worker":16,"../errors":21,"../events":23,"../utils/logger":38,webworkify:2}],18:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;re?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),t=e-t,t>0?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(e){var t,r,a=8,i=8;for(t=0;t>4,y>1){if(m=v+5+e[v+4],m===v+188)continue}else m=v+4;if(R)if(p===A){if(g){if(l&&(this._parseAVCPES(this._parsePES(l)),b&&this._avcTrack.codec&&(L===-1||this._aacTrack.codec)))return void this.remux(e);l={data:[],size:0}}l&&(l.data.push(e.subarray(m,v+188)),l.size+=v+188-m)}else if(p===L){if(g){if(d&&(this._parseAACPES(this._parsePES(d)),b&&this._aacTrack.codec&&(A===-1||this._avcTrack.codec)))return void this.remux(e);d={data:[],size:0}}d&&(d.data.push(e.subarray(m,v+188)),d.size+=v+188-m)}else p===T&&(g&&(f&&this._parseID3PES(this._parsePES(f)),f={data:[],size:0}),f&&(f.data.push(e.subarray(m,v+188)),f.size+=v+188-m));else g&&(m+=e[m]+1),0===p?this._parsePAT(e,m):p===this._pmtId?(this._parsePMT(e,m),R=this.pmtParsed=!0,A=this._avcTrack.id,L=this._aacTrack.id,T=this._id3Track.id,_&&(h.logger.log("reparse from beginning"),_=!1,v=-188)):(h.logger.log("unknown PID found before PAT/PMT"),_=!0)}else this.observer.trigger(u.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});l&&this._parseAVCPES(this._parsePES(l)),d&&this._parseAACPES(this._parsePES(d)),f&&this._parseID3PES(this._parsePES(f)),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=void 0,this._duration=0}},{key:"_parsePAT",value:function(e,t){this._pmtId=(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(e,t){var r,a,i,n;for(r=(15&e[t+1])<<8|e[t+2],a=t+3+r-4,i=(15&e[t+10])<<8|e[t+11],t+=12+i;t4294967295&&(o-=8589934592),64&r?(l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,l>4294967295&&(l-=8589934592)):l=o),n=t[8],u=n+9,e.size-=u,s=new Uint8Array(e.size);f.length;){t=f.shift();var h=t.byteLength;if(u){if(u>h){u-=h;continue}t=t.subarray(u),h-=u,u=0}s.set(t,d),d+=h}return{data:s,pts:o,dts:l,len:i}}return null}},{key:"_parseAVCPES",value:function(e){var t,r,a,i,n=this,s=this._avcTrack,o=s.samples,l=this._parseAVCNALu(e.data),u=[],d=!1,c=!1,v=0;if(0===l.length&&o.length>0){var g=o[o.length-1],p=g.units.units[g.units.units.length-1],y=new Uint8Array(p.data.byteLength+e.data.byteLength);y.set(p.data,0),y.set(e.data,p.data.byteLength),p.data=y,g.units.length+=e.data.byteLength,s.len+=e.data.byteLength}e.data=null;var m="",E=function(){u.length&&(c===!0||s.sps&&(o.length||this.contiguous)?(r={units:{units:u,length:v},pts:e.pts,dts:e.dts,key:c},o.push(r),s.len+=v,s.nbNalu+=u.length):s.dropped++,u=[],v=0)}.bind(this);l.forEach(function(r){switch(r.type){case 1:a=!0,d&&(m+="NDR ");break;case 5:a=!0,d&&(m+="IDR "),c=!0;break;case 6:a=!0,d&&(m+="SEI "),t=new f.default(r.data),t.readUByte();var o=t.readUByte();if(4===o){var l=0;do l=t.readUByte();while(255===l);var h=t.readUByte();if(181===h){var g=t.readUShort();if(49===g){var p=t.readUInt();if(1195456820===p){var y=t.readUByte();if(3===y){var b=t.readUByte(),_=t.readUByte(),R=31&b,A=[b,_];for(i=0;i0){var y=this._avcTrack,m=y.samples;if(m.length){var E=m[m.length-1],b=E.units.units,_=b[b.length-1],R=new Uint8Array(_.data.byteLength+r);R.set(_.data,0),R.set(e.subarray(0,r),_.data.byteLength),_.data=R,E.units.length+=r,y.len+=r}}}n=o,s=i,u=0}else u=0}return n&&(a={data:e.subarray(n,l),type:s,state:u},d.push(a),this.avcNaluState=u),d}},{key:"_parseAACPES",value:function(e){var t,r,a,i,n,s,l,d,f,v=this._aacTrack,g=e.data,p=e.pts,y=0,m=this._duration,E=this.audioCodec,b=this.aacOverFlow,_=this.aacLastPTS;if(b){var R=new Uint8Array(b.byteLength+g.byteLength);R.set(b,0),R.set(g,b.byteLength),g=R}for(n=y,d=g.length;n1&&(h.logger.log("AAC: align PTS for overlapping frames by "+Math.round((T-p)/90)),p=T)}for(;n+5>>5,r-=s,r>0&&n+s+r<=d);)for(l=p+i*a,f={unit:g.subarray(n+s,n+s+r),pts:l,dts:l},v.samples.push(f),v.len+=r,n+=r+s,i++;n=564&&71===e[0]&&71===e[188]&&71===e[376]}}]),e}();r.default=v},{"../errors":21,"../events":23,"../utils/logger":38,"./adts":14,"./exp-golomb":18}],21:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",OTHER_ERROR:"otherError"},r.ErrorDetails={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",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",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",INTERNAL_EXCEPTION:"internalException"}},{}],22:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s=function(){function e(e,t){for(var r=0;r1?r-1:0),n=1;nd&&(l[u-1].end=e[o].end):l.push(e[o])}else l.push(e[o])}for(o=0,a=0,i=n=t;o=f&&t=0&&ot.endSN)return 0;if(o=r-t.startSN,l=t.fragments,u=l[o],!isNaN(u.startPTS)){var f=Math.abs(u.startPTS-a);isNaN(u.deltaPTS)?u.deltaPTS=f:u.deltaPTS=Math.max(f,u.deltaPTS),a=Math.min(a,u.startPTS),i=Math.max(i,u.endPTS),n=Math.min(n,u.startDTS),s=Math.max(s,u.endDTS)}var h=a-u.start;for(u.start=u.startPTS=a,u.endPTS=i,u.startDTS=n,u.endDTS=s,u.duration=i-a,d=o;d>0;d--)e.updatePTS(l,d,d-1);for(d=o;dt?i.start=a.start+a.duration:i.start=a.start-i.duration:r>t?(a.duration=s-a.start,a.duration<0&&n.logger.error("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):(i.duration=a.start-s,i.duration<0&&n.logger.error("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!"))}}]),e}();r.default=s},{"../utils/logger":38}],26:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r1?t-1:0),a=1;a1?t-1:0),a=1;a>8*(15-r)&255;return t}},{key:"fragmentDecryptdataFromLevelkey",value:function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&(r=this.cloneObj(e),r.iv=this.createInitializationVector(t)),r}},{key:"avc1toavcoti",value:function(e){var t,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(e,t,r){var a,i,n,s=0,o=0,l={version:null,type:null,url:t,fragments:[],live:!0,startSN:0},u={method:null,key:null,iv:null,uri:null},d=0,f=null,h=null,c=null,v=null,g=null,m=null;for(n=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT(INF):(\d+(?:\.\d+)?)(?:,(.*))?)|(?:(?!#)()(\S.+))|(?:#EXT-X-(BYTERANGE):(\d+(?:@\d+(?:\.\d+)?))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.+))|(?:#EXT-X-(VERSION):(\d+))|(?:(#)(.*):(.*))|(?:(#)(.*)))(?:.*)\r?\n?/g;null!==(i=n.exec(e));)switch(i.shift(),i=i.filter(function(e){return void 0!==e}),i[0]){case"VERSION":l.version=parseInt(i[1]);break;case"PLAYLIST-TYPE":l.type=i[1].toUpperCase();break;case"MEDIA-SEQUENCE":s=l.startSN=parseInt(i[1]);break;case"TARGETDURATION":l.targetduration=parseFloat(i[1]);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"DIS":d++;break;case"BYTERANGE":var E=i[1].split("@");m=1===E.length?g:parseInt(E[1]),g=parseInt(E[0])+m;break;case"INF":c=parseFloat(i[1]),v=i[2]?i[2]:null;break;case"":if(!isNaN(c)){var b=s++;a=this.fragmentDecryptdataFromLevelkey(u,b);var _=i[1]?this.resolve(i[1],t):null;h={url:_,duration:c,title:v,start:o,sn:b,level:r,cc:d,decryptdata:a,programDateTime:f},null!==m&&(h.byteRangeStartOffset=m,h.byteRangeEndOffset=g),l.fragments.push(h),o+=c,c=null,v=null,m=null,f=null}break;case"KEY":var R=i[1],A=new p.default(R),L=A.enumeratedString("METHOD"),T=A.URI,k=A.hexadecimalInteger("IV");L&&(u={method:null,key:null,iv:null,uri:null},T&&"AES-128"===L&&(u.method=L,u.uri=this.resolve(T,t),u.key=null,u.iv=k));break;case"START":var S=i[1],w=new p.default(S),D=w.decimalFloatingPoint("TIME-OFFSET");D&&(l.startTimeOffset=D);break;case"PROGRAM-DATE-TIME":f=new Date(Date.parse(i[1]));break;case"#":i.shift();break;default:y.logger.warn("line parsed but not handled: "+i)}return h&&!h.url&&(l.fragments.pop(),o-=h.duration),l.totalduration=o,l.endSN=s-1,l}},{key:"loadsuccess",value:function(e,t){var r,a=e.currentTarget,i=a.responseText,n=a.responseURL,s=this.id,o=this.id2,l=this.hls;if(this.loading=!1,void 0===n&&(n=this.url),t.tload=performance.now(),t.mtime=new Date(a.getResponseHeader("Last-Modified")),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0){var d=this.parseLevelPlaylist(i,n,s||0);d.tload=t.tload,null===s&&l.trigger(u.default.MANIFEST_LOADED,{levels:[{url:n,details:d}],url:n,stats:t}),t.tparsed=performance.now(),l.trigger(u.default.LEVEL_LOADED,{details:d,level:s||0,id:o,stats:t})}else r=this.parseMasterPlaylist(i,n),r.length?l.trigger(u.default.MANIFEST_LOADED,{levels:r,url:n,stats:t}):l.trigger(u.default.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest"});else l.trigger(u.default.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(e){var t,r;null===this.id?(t=h.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0):(t=h.ErrorDetails.LEVEL_LOAD_ERROR,r=!1),this.loader&&this.loader.abort(),this.loading=!1,this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:t,fatal:r,url:this.url,loader:this.loader,response:e.currentTarget,level:this.id,id:this.id2})}},{key:"loadtimeout",value:function(){var e,t;null===this.id?(e=h.ErrorDetails.MANIFEST_LOAD_TIMEOUT,t=!0):(e=h.ErrorDetails.LEVEL_LOAD_TIMEOUT,t=!1),this.loader&&this.loader.abort(),this.loading=!1,this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:e,fatal:t,url:this.url,loader:this.loader,level:this.id,id:this.id2})}}]),t}(f.default);r.default=m},{"../errors":21,"../event-handler":22,"../events":23,"../utils/attr-list":34,"../utils/logger":38,"../utils/url":39}],31:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r>24&255,t[1]=a>>16&255,t[2]=a>>8&255,t[3]=255&a,t.set(e,4),i=0,a=8;i>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,a){return e.box(e.types.moof,e.mfhd(t),e.traf(a,r))}},{key:"moov",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(a).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(a))}},{key:"mvhd",value:function(t,r){r*=t;var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,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]);return e.box(e.types.mvhd,a)}},{key:"sdtp",value:function(t){var r,a,i=t.samples||[],n=new Uint8Array(4+i.length);for(a=0;a>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(a));for(r=0;r>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(a));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height;return e.box(e.types.avc1,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,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}},{key:"mp4a",value:function(t){var r=t.audiosamplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"stsd",value:function(t){return"audio"===t.type?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,a=t.duration*t.timescale,i=t.width,n=t.height;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,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,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}},{key:"traf",value:function(t,r){var a=e.sdtp(t),i=t.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.trun(t,a.length+16+16+8+16+8+8),a)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var a,i,n,s,o,l,u=t.samples||[],d=u.length,f=12+16*d,h=new Uint8Array(f);for(r+=8+f,h.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),a=0;a>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*a);return e.box(e.types.trun,h)}},{key:"initSegment",value:function(t){e.types||e.init();var r,a=e.moov(t);return r=new Uint8Array(e.FTYP.byteLength+a.byteLength),r.set(e.FTYP),r.set(a,e.FTYP.byteLength),r}}]),e}();r.default=n},{}],32:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;rMath.pow(2,32)&&!function(){var t=function e(t,r){return r?e(r,t%r):t};e.timescale=e.audiosamplerate/t(e.audiosamplerate,1024)}(),l.logger.log("audio mp4 timescale :"+e.timescale),c.audio={container:"audio/mp4",codec:e.codec,initSegment:d.default.initSegment([e]),metadata:{channelCount:e.channelCount}},g&&(a=i=s[0].pts-h*r)),t.sps&&t.pps&&u.length&&(t.timescale=this.MP4_TIMESCALE,c.video={container:"video/mp4",codec:t.codec,initSegment:d.default.initSegment([t]),metadata:{width:t.width,height:t.height}},g&&(a=Math.min(a,u[0].pts-h*r),i=Math.min(i,u[0].dts-h*r))),Object.keys(c).length?(n.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,g&&(this._initPTS=a,this._initDTS=i)):n.trigger(o.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r){var a,i,n,s,u,f,h,c,v,g,p,y,m,E,b,_=8,R=this.PES_TIMESCALE,A=this.PES2MP4SCALEFACTOR,L=[],T=e.samples.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);for(T<0&&l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(T/90)+" ms to overcome this issue"),f=new Uint8Array(e.len+4*e.nbNalu+8),a=new DataView(f.buffer),a.setUint32(0,f.byteLength),f.set(d.default.types.mdat,4);e.samples.length;){for(i=e.samples.shift(),s=0;i.units.units.length;)u=i.units.units.shift(),a.setUint32(_,u.data.byteLength),_+=4,f.set(u.data,_),_+=u.data.byteLength,s+=4+u.data.byteLength;if(p=i.pts-this._initDTS,y=i.dts-this._initDTS+T,y=Math.min(p,y),void 0!==g){m=this._PTSNormalize(p,g),E=this._PTSNormalize(y,g);var k=(E-g)/A;k<=0&&(l.logger.log("invalid sample duration at PTS/DTS: "+i.pts+"/"+i.dts+":"+k),k=1),n.duration=k}else{var S=void 0,w=void 0;S=r?this.nextAvcDts:t*R,m=this._PTSNormalize(p,S),E=this._PTSNormalize(y,S),w=Math.round((E-S)/90),r&&w&&(w>1?l.logger.log("AVC:"+w+" ms hole between fragments detected,filling it"):w<-1&&l.logger.log("AVC:"+-w+" ms overlapping between fragments detected"),E=S,m=Math.max(m-w,E),l.logger.log("Video/PTS/DTS adjusted: "+m+"/"+E+",delta:"+w)),c=Math.max(0,m),v=Math.max(0,E)}n={size:s,duration:0,cts:(m-E)/A,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},b=n.flags,i.key===!0?(b.dependsOn=2,b.isNonSync=0):(b.dependsOn=1,b.isNonSync=1),L.push(n),g=E}var D=0;L.length>=2&&(D=L[L.length-2].duration,n.duration=D),this.nextAvcDts=E+D*A;var O=e.dropped;e.len=0,e.nbNalu=0,e.dropped=0,L.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(b=L[0].flags,b.dependsOn=2,b.isNonSync=0),e.samples=L,h=d.default.moof(e.sequenceNumber++,v/A,e),e.samples=[],this.observer.trigger(o.default.FRAG_PARSING_DATA,{data1:h,data2:f,startPTS:c/R,endPTS:(m+A*D)/R,startDTS:v/R,endDTS:this.nextAvcDts/R,type:"video",nb:L.length,dropped:O})}},{key:"remuxAudio",value:function(e,t,r){var a,i,n,s,u,f,h,c,v,g,p,y,m,E=8,b=this.PES_TIMESCALE,_=e.timescale,R=b/_,A=1024*e.timescale/e.audiosamplerate,L=[],T=[];for(e.samples.sort(function(e,t){return e.pts-t.pts}),T=e.samples;T.length;){if(i=T.shift(),s=i.unit,g=i.pts-this._initDTS,p=i.dts-this._initDTS,void 0!==v)y=this._PTSNormalize(g,v),m=this._PTSNormalize(p,v),n.duration=(m-v)/R,Math.abs(n.duration-A)>A/10&&l.logger.log("invalid AAC sample duration at PTS "+Math.round(g/90)+",should be 1024,found :"+Math.round(n.duration*e.audiosamplerate/e.timescale)),n.duration=A,y=m=A*R+v;else{var k=void 0,S=void 0;if(k=r?this.nextAacPts:t*b,y=this._PTSNormalize(g,k),m=this._PTSNormalize(p,k),S=Math.round(1e3*(y-k)/b),r&&S){if(S>0)l.logger.log(S+" ms hole between AAC samples detected,filling it");else if(S<-12){l.logger.log(-S+" ms overlapping between AAC samples detected, drop frame"),e.len-=s.byteLength;continue}y=m=k}if(h=Math.max(0,y),c=Math.max(0,m),!(e.len>0))return;u=new Uint8Array(e.len+8),a=new DataView(u.buffer),a.setUint32(0,u.byteLength),u.set(d.default.types.mdat,4)}u.set(s,E),E+=s.byteLength,n={size:s.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},L.push(n),v=m}var w=0,D=L.length;D>=2&&(w=L[D-2].duration,n.duration=w),D&&(this.nextAacPts=y+R*w,e.len=0,e.samples=L,f=d.default.moof(e.sequenceNumber++,c/R,e),e.samples=[],this.observer.trigger(o.default.FRAG_PARSING_DATA,{data1:f,data2:u,startPTS:h/b,endPTS:this.nextAacPts/b,startDTS:c/b,endDTS:(m+R*w)/b,type:"audio",nb:D}))}},{key:"remuxID3",value:function(e,t){var r,a=e.samples.length;if(a){for(var i=0;i4294967296;)e+=r;return e}},{key:"passthrough",get:function(){return!1}}]),e}();r.default=h},{"../errors":21,"../events":23,"../remux/mp4-generator":31,"../utils/logger":38}],33:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),a=0;aNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(e){var t=/^(\d+)x(\d+)$/.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){for(var t,r=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a={};null!==(t=r.exec(e));){var i=t[2],n='"';0===i.indexOf(n)&&i.lastIndexOf(n)===i.length-1&&(i=i.slice(1,-1)),a[t[1]]=i}return a}}]),e}();r.default=n},{}],35:[function(e,t,r){"use strict";var a={search:function(e,t){for(var r=0,a=e.length-1,i=null,n=null;r<=a;){i=(r+a)/2|0,n=e[i];var s=t(n);if(s>0)r=i+1;else{if(!(s<0))return n;a=i-1}}return null}};t.exports=a},{}],36:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r0;)e.removeCue(e.cues[0])}},{key:"push",value:function(e,t){this.cue||this._createCue();for(var r,a,i,n,s,o=31&t[0],l=2,u=0;u=48&&i<=63)switch(i){case 48:this.cue.text+="®";break;case 49:this.cue.text+="°";break;case 50:this.cue.text+="½";break;case 51:this.cue.text+="¿";break;case 52:this.cue.text+="™";break;case 53:this.cue.text+="¢";break;case 54:this.cue.text+="";break;case 55:this.cue.text+="£";break;case 56:this.cue.text+="♪";break;case 57:this.cue.text+=" ";break;case 58:this.cue.text+="è";break;case 59:this.cue.text+="â";break;case 60:this.cue.text+="ê";break;case 61:this.cue.text+="î";break;case 62:this.cue.text+="ô";break;case 63:this.cue.text+="û"}if((17===a||25===a)&&i>=32&&i<=47)switch(i){case 32:break;case 33:break;case 34:break;case 35:break;case 36:break;case 37:break;case 38:break;case 39:break;case 40:break;case 41:break;case 42:break;case 43:break;case 44:break;case 45:break;case 46:break;case 47:}if((20===a||28===a)&&i>=32&&i<=47)switch(i){case 32:this._clearActiveCues(e);break;case 33:this.cue.text=this.cue.text.substr(0,this.cue.text.length-1);break;case 34:break;case 35:break;case 36:break;case 37:break;case 38:break;case 39:break;case 40:break;case 41:this._clearActiveCues(e);break;case 42:break;case 43:break;case 44:this._clearActiveCues(e);break;case 45:break;case 46:this._text="";break;case 47:this._flipMemory(e)}if((23===a||31===a)&&i>=33&&i<=35)switch(i){case 33:break;case 34:break;case 35:}}}},{key:"_fromCharCode",value:function(e){switch(e){case 42:return"á";case 2:return"á";case 2:return"é";case 4:return"í";case 5:return"ó";case 6:return"ú";case 3:return"ç";case 4:return"÷";case 5:return"Ñ";case 6:return"ñ";case 7:return"█";default:return String.fromCharCode(e)}}},{key:"_flipMemory",value:function(e){this._clearActiveCues(e),this._flushCaptions(e)}},{key:"_flushCaptions",value:function(e){this._has708||(this._textTrack=this.media.addTextTrack("captions","English","en"),this._has708=!0); var t=!0,r=!1,a=void 0;try{for(var i,n=this.memory[Symbol.iterator]();!(t=(i=n.next()).done);t=!0){var s=i.value;s.startTime=e,this._textTrack.addCue(s),this.display.push(s)}}catch(e){r=!0,a=e}finally{try{!t&&n.return&&n.return()}finally{if(r)throw a}}this.memory=[],this.cue=null}},{key:"_clearActiveCues",value:function(e){var t=!0,r=!1,a=void 0;try{for(var i,n=this.display[Symbol.iterator]();!(t=(i=n.next()).done);t=!0){var s=i.value;s.endTime=e}}catch(e){r=!0,a=e}finally{try{!t&&n.return&&n.return()}finally{if(r)throw a}}this.display=[]}},{key:"_clearBufferedCues",value:function(){}}]),e}();r.default=n},{}],37:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r "+t}function n(e){var t=window.console[e];return t?function(){for(var r=arguments.length,a=Array(r),n=0;n1?t-1:0),a=1;a-1;o=a+r)r=/^\/(?:\.\.\/)*/.exec(s.slice(a))[0].length,n=(n+s.substring(o,a)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(r-1)/3+"}$"),"/");return n+s.substr(o)}};t.exports=a},{}],40:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r=2&&(0===a.tfirst&&(a.tfirst=Math.max(performance.now(),a.trequest),window.clearTimeout(this.timeoutHandle),this.timeoutHandle=window.setTimeout(this.loadtimeout.bind(this),this.timeout-(a.tfirst-a.trequest))),4===r)){var i=t.status;i>=200&&i<300?(window.clearTimeout(this.timeoutHandle),a.tload=Math.max(a.tfirst,performance.now()),this.onSuccess(e,a)):a.retry>=this.maxRetry||i>=400&&i<499?(window.clearTimeout(this.timeoutHandle),n.logger.error(i+" while loading "+this.url),this.onError(e)):(n.logger.warn(i+" while loading "+this.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.timeoutHandle=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,64e3),a.retry++)}}},{key:"loadtimeout",value:function(e){n.logger.warn("timeout while loading "+this.url),this.onTimeout(e,this.stats)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,this.onProgress&&this.onProgress(e,t)}}]),e}();r.default=s},{"../utils/logger":38}]},{},[27])(27)});