summaryrefslogtreecommitdiff
path: root/mediabrowser/assets/hls.js/hls.min.js
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-02-19 23:11:45 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-02-19 23:11:45 +0100
commit4f0bab9fb0f0b792123077c00e7fe2e5739ceafd (patch)
treea3fef692f5abf89423925113dc012fdacb2baf73 /mediabrowser/assets/hls.js/hls.min.js
parentf2ab96ee6d89a428e9e227edd3beefbf42369949 (diff)
downloadflask-mediabrowser-4f0bab9fb0f0b792123077c00e7fe2e5739ceafd.tar.gz
flask-mediabrowser-4f0bab9fb0f0b792123077c00e7fe2e5739ceafd.zip
update hls.js to latest release 0.5.7
Diffstat (limited to 'mediabrowser/assets/hls.js/hls.min.js')
-rw-r--r--mediabrowser/assets/hls.js/hls.min.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/mediabrowser/assets/hls.js/hls.min.js b/mediabrowser/assets/hls.js/hls.min.js
index 28e4dc3..bc5bf37 100644
--- a/mediabrowser/assets/hls.js/hls.min.js
+++ b/mediabrowser/assets/hls.js/hls.min.js
@@ -1,4 +1,4 @@
-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Hls=t()}}(function(){return function s(e,t,r){function i(a,d){if(!t[a]){if(!e[a]){var l="function"==typeof require&&require;if(!d&&l)return l(a,!0);if(n)return n(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var o=t[a]={exports:{}};e[a][0].call(o.exports,function(t){var r=e[a][1][t];return i(r?r:t)},o,o.exports,s,e,t,r)}return t[a].exports}for(var n="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(s,a,o){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function t(e){return"function"==typeof e}function n(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}a.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!n(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},e.prototype.emit=function(u){var o,a,n,s,e,l;if(this._events||(this._events={}),"error"===u&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(o=arguments[1],o instanceof Error)throw o;throw TypeError('Uncaught, unspecified "error" event.')}if(a=this._events[u],i(a))return!1;if(t(a))switch(arguments.length){case 1:a.call(this);break;case 2:a.call(this,arguments[1]);break;case 3:a.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,s=new Array(n-1),e=1;n>e;e++)s[e-1]=arguments[e];a.apply(this,s)}else if(r(a)){for(n=arguments.length,s=new Array(n-1),e=1;n>e;e++)s[e-1]=arguments[e];for(l=a.slice(),n=l.length,e=0;n>e;e++)l[e].apply(this,s)}return!0},e.prototype.addListener=function(a,n){var s;if(!t(n))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,t(n.listener)?n.listener:n),this._events[a]?r(this._events[a])?this._events[a].push(n):this._events[a]=[this._events[a],n]:this._events[a]=n,r(this._events[a])&&!this._events[a].warned){var s;s=i(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[a].length>s&&(this._events[a].warned=!0,"function"==typeof console.trace)}return this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(i,e){function r(){this.removeListener(i,r),a||(a=!0,e.apply(this,arguments))}if(!t(e))throw TypeError("listener must be a function");var a=!1;return r.listener=e,this.on(i,r),this},e.prototype.removeListener=function(a,i){var e,s,o,n;if(!t(i))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(e=this._events[a],o=e.length,s=-1,e===i||t(e.listener)&&e.listener===i)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,i);else if(r(e)){for(n=o;n-->0;)if(e[n]===i||e[n].listener&&e[n].listener===i){s=n;break}if(0>s)return this;1===e.length?(e.length=0,delete this._events[a]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",a,i)}return this},e.prototype.removeAllListeners=function(e){var i,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(i in this._events)"removeListener"!==i&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],t(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},e.prototype.listeners=function(e){var r;return r=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.listenerCount=function(e,r){var i;return i=e._events&&e._events[r]?t(e._events[r])?1:e._events[r].length:0}},{}],2:[function(n,i,s){var a=arguments[3],e=arguments[4],r=arguments[5],t=JSON.stringify;i.exports=function(u){for(var i,o=Object.keys(r),n=0,l=o.length;l>n;n++){var s=o[n];if(r[s].exports===u){i=s;break}}if(!i){i=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var d={},n=0,l=o.length;l>n;n++){var s=o[n];d[s]=s}e[i]=[Function(["require","module","exports"],"("+u+")(self)"),d]}var h=Math.floor(Math.pow(16,8)*Math.random()).toString(16),f={};f[i]=i,e[h]=[Function(["require"],"require("+t(i)+")(self)"),f];var c="("+a+")({"+Object.keys(e).map(function(r){return t(r)+":["+e[r][0]+","+t(e[r][1])+"]"}).join(",")+"},{},["+t(h)+"])",v=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(v.createObjectURL(new Blob([c],{type:"text/javascript"})))}},{}],3:[function(t,s,e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var f=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),o=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},l=t("../events"),u=r(l),d=t("../event-handler"),i=r(d),h=function(t){function e(t){a(this,e),o(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,t,u.default.FRAG_LOAD_PROGRESS),this.lastfetchlevel=0,this._autoLevelCapping=-1,this._nextAutoLevel=-1}return n(e,t),f(e,[{key:"destroy",value:function(){i.default.prototype.destroy.call(this)}},{key:"onFragLoadProgress",value:function(t){var e=t.stats;void 0===e.aborted&&(this.lastfetchduration=(performance.now()-e.trequest)/1e3,this.lastfetchlevel=t.frag.level,this.lastbw=8*e.loaded/this.lastfetchduration)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping=e}},{key:"nextAutoLevel",get:function(){var r,e,t,i=this.lastbw,a=this.hls;if(t=-1===this._autoLevelCapping?a.levels.length-1:this._autoLevelCapping,-1!==this._nextAutoLevel){var n=Math.min(this._nextAutoLevel,t);if(n!==this.lastfetchlevel)return n;this._nextAutoLevel=-1}for(e=0;t>=e;e++)if(r=e<=this.lastfetchlevel?.8*i:.7*i,r<a.levels[e].bitrate)return Math.max(0,e-1);return e-1},set:function(e){this._nextAutoLevel=e}}]),e}(i.default);e.default=h,s.exports=e.default},{"../event-handler":18,"../events":19}],4:[function(i,o,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(a,"__esModule",{value:!0});var s=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),v=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},l=i("../events"),t=n(l),d=i("../event-handler"),h=n(d),r=i("../utils/logger"),e=i("../errors"),u=function(a){function i(e){f(this,i),v(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,e,t.default.MANIFEST_LOADED,t.default.LEVEL_LOADED,t.default.ERROR),this.ontick=this.tick.bind(this),this._manualLevel=this._autoLevelCapping=-1}return c(i,a),s(i,[{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this._manualLevel=-1}},{key:"onManifestLoaded",value:function(l){var s,a,n=[],i=[],u={},d=!1,h=!1,o=this.hls;if(l.levels.forEach(function(e){e.videoCodec&&(d=!0),e.audioCodec&&(h=!0);var t=u[e.bitrate];void 0===t?(u[e.bitrate]=n.length,e.url=[e.url],e.urlId=0,n.push(e)):n[t].url.push(e.url)}),d&&h?n.forEach(function(e){e.videoCodec&&i.push(e)}):i=n,i=i.filter(function(e){var t=function(e){return MediaSource.isTypeSupported("video/mp4;codecs="+e)},r=e.audioCodec,i=e.videoCodec;return(!r||t(r))&&(!i||t(i))}),i.length){for(s=i[0].bitrate,i.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=i,a=0;a<i.length;a++)if(i[a].bitrate===s){this._firstLevel=a,r.logger.log("manifest loaded,"+i.length+" level(s) found, first bitrate:"+s);break}o.trigger(t.default.MANIFEST_PARSED,{levels:this._levels,firstLevel:this._firstLevel,stats:l.stats})}else o.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:o.url,reason:"no compatible level found in manifest"})}},{key:"setLevelInternal",value:function(i){if(i>=0&&i<this._levels.length){this.timer&&(clearInterval(this.timer),this.timer=null),this._level=i,r.logger.log("switching to level "+i),this.hls.trigger(t.default.LEVEL_SWITCH,{level:i});var a=this._levels[i];if(void 0===a.details||a.details.live===!0){r.logger.log("(re)loading playlist for level "+i);var n=a.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:a.url[n],level:i,id:n})}}else this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(a){if(!a.fatal){var n,t,i=a.details,s=this.hls;switch(i){case e.ErrorDetails.FRAG_LOAD_ERROR:case e.ErrorDetails.FRAG_LOAD_TIMEOUT:case e.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case e.ErrorDetails.KEY_LOAD_ERROR:case e.ErrorDetails.KEY_LOAD_TIMEOUT:n=a.frag.level;break;case e.ErrorDetails.LEVEL_LOAD_ERROR:case e.ErrorDetails.LEVEL_LOAD_TIMEOUT:n=a.level}if(void 0!==n)if(t=this._levels[n],t.urlId<t.url.length-1)t.urlId++,t.details=void 0,r.logger.warn("level controller,"+i+" for level "+n+": switching to redundant stream id "+t.urlId);else{var o=-1===this._manualLevel&&n;o?(r.logger.warn("level controller,"+i+": emergency switch-down for next fragment"),s.abrController.nextAutoLevel=0):t&&t.details&&t.details.live?r.logger.warn("level controller,"+i+" on live stream, discard"):i!==e.ErrorDetails.FRAG_LOAD_ERROR&&i!==e.ErrorDetails.FRAG_LOAD_TIMEOUT&&(r.logger.error("cannot recover "+i+" error"),this._level=void 0,this.timer&&(clearInterval(this.timer),this.timer=null),a.fatal=!0,s.trigger(event,a))}}}},{key:"onLevelLoaded",value:function(e){e.details.live&&!this.timer&&(this.timer=setInterval(this.ontick,1e3*e.details.targetduration)),!e.details.live&&this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"tick",value:function(){var e=this._level;if(void 0!==e){var r=this._levels[e],i=r.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:r.url[i],level:e,id:i})}}},{key:"nextLoadLevel",value:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.abrController.nextAutoLevel}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this._level},set:function(e){(this._level!==e||void 0===this._levels[e].details)&&this.setLevelInternal(e)}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,-1!==e&&(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}}]),i}(h.default);a.default=u,o.exports=a.default},{"../errors":17,"../event-handler":18,"../events":19,"../utils/logger":29}],5:[function(a,h,s){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(s,"__esModule",{value:!0});var c=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),E=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},b=a("../demux/demuxer"),u=n(b),d=a("../events"),r=n(d),f=a("../event-handler"),o=n(f),t=a("../utils/logger"),g=a("../utils/binary-search"),p=n(g),y=a("../helper/level-helper"),l=n(y),i=a("../errors"),e={ERROR:-2,STARTING:-1,IDLE:0,KEY_LOADING:1,FRAG_LOADING:2,FRAG_LOADING_WAITING_RETRY:3,WAITING_LEVEL:4,PARSING:5,PARSED:6,APPENDING:7,BUFFER_FLUSHING:8},_=function(n){function a(e){v(this,a),E(Object.getPrototypeOf(a.prototype),"constructor",this).call(this,e,r.default.MEDIA_ATTACHING,r.default.MEDIA_DETACHING,r.default.MANIFEST_PARSED,r.default.LEVEL_LOADED,r.default.KEY_LOADED,r.default.FRAG_LOADED,r.default.FRAG_PARSING_INIT_SEGMENT,r.default.FRAG_PARSING_DATA,r.default.FRAG_PARSED,r.default.ERROR),this.config=e.config,this.audioCodecSwap=!1,this.ticks=0,this.onsbue=this.onSBUpdateEnd.bind(this),this.onsbe=this.onSBUpdateError.bind(this),this.ontick=this.tick.bind(this)}return m(a,n),c(a,[{key:"destroy",value:function(){this.stop(),o.default.prototype.destroy.call(this),this.state=e.IDLE}},{key:"startLoad",value:function(){this.levels&&this.media?(this.startInternal(),this.lastCurrentTime?(t.logger.log("seeking @ "+this.lastCurrentTime),this.lastPaused||(t.logger.log("resuming video"),this.media.play()),this.state=e.IDLE):(this.lastCurrentTime=0,this.state=e.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()):t.logger.warn("cannot start loading as either manifest not parsed or video not attached")}},{key:"startInternal",value:function(){var e=this.hls;this.stop(),this.demuxer=new u.default(e),this.timer=setInterval(this.ontick,100),this.level=-1,this.fragLoadError=0}},{key:"stop",value:function(){this.mp4segments=[],this.flushRange=[],this.bufferRange=[];var e=this.fragCurrent;if(e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.sourceBuffer){for(var r in this.sourceBuffer){var t=this.sourceBuffer[r];try{this.mediaSource.removeSourceBuffer(t),t.removeEventListener("updateend",this.onsbue),t.removeEventListener("error",this.onsbe)}catch(e){}}this.sourceBuffer=null}this.timer&&(clearInterval(this.timer),this.timer=null),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null)}},{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 h,o,n,l=this.hls;switch(this.state){case e.ERROR:break;case e.STARTING:this.startLevel=l.startLevel,-1===this.startLevel&&(this.startLevel=0,this.fragBitrateTest=!0),this.level=l.nextLoadLevel=this.startLevel,this.state=e.WAITING_LEVEL,this.loadedmetadata=!1;break;case e.IDLE:if(!this.media)break;h=this.loadedmetadata?this.media.currentTime:this.nextLoadPosition,o=this.startFragmentRequested===!1?this.startLevel:l.nextLoadLevel;var v,x=this.bufferInfo(h,this.config.maxBufferHole),N=x.len,d=x.end,f=this.fragPrevious;if(this.levels[o].hasOwnProperty("bitrate")?(v=Math.max(8*this.config.maxBufferSize/this.levels[o].bitrate,this.config.maxBufferLength),v=Math.min(v,this.config.maxMaxBufferLength)):v=this.config.maxBufferLength,v>N){if(l.nextLoadLevel=o,this.level=o,n=this.levels[o].details,"undefined"==typeof n||n.live&&this.levelLastLoaded!==o){this.state=e.WAITING_LEVEL;break}var u=n.fragments,c=u.length,g=u[0].start,O=u[c-1].start+u[c-1].duration,a=void 0;if(n.live){if(d<Math.max(g,O-this.config.liveMaxLatencyDurationCount*n.targetduration)&&(this.seekAfterBuffered=g+Math.max(0,n.totalduration-this.config.liveSyncDurationCount*n.targetduration),t.logger.log("buffer end: "+d+" is located too far from the end of live sliding playlist, media position will be reseted to: "+this.seekAfterBuffered.toFixed(3)),d=this.seekAfterBuffered),this.startFragmentRequested&&!n.PTSKnown){if(f){var T=f.sn+1;T>=n.startSN&&T<=n.endSN&&(a=u[T-n.startSN],t.logger.log("live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=u[Math.min(c-1,Math.round(c/2))],t.logger.log("live playlist, switching playlist, unknown, load middle frag : "+a.sn))}}else g>d&&(a=u[0]);if(!a){var m;if(m=O>d?p.default.search(u,function(e){return e.start+e.duration<=d?1:e.start>d?-1:0}):u[c-1],m&&(a=m,g=m.start,f&&a.level===f.level&&a.sn===f.sn))if(a.sn<n.endSN)a=u[a.sn+1-n.startSN],t.logger.log("SN just loaded, load next one: "+a.sn);else{if(!n.live){var b=this.mediaSource;if(b&&"open"===b.readyState){var E=this.sourceBuffer;E.audio&&E.audio.updating||E.video&&E.video.updating||(t.logger.log("all media data available, signal endOfStream() to MediaSource"),b.endOfStream())}}a=null}}if(a)if(null!=a.decryptdata.uri&&null==a.decryptdata.key)t.logger.log("Loading key for "+a.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+o),this.state=e.KEY_LOADING,l.trigger(r.default.KEY_LOADING,{frag:a});else{if(t.logger.log("Loading "+a.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+o+", currentTime:"+h+",bufferEnd:"+d.toFixed(3)),a.autoLevel=l.autoLevelEnabled,this.levels.length>1&&(a.expectedLen=Math.round(a.duration*this.levels[o].bitrate/8),a.trequest=performance.now()),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,a.loadCounter){a.loadCounter++;var w=this.config.fragLoadingLoopThreshold;if(a.loadCounter>w&&Math.abs(this.fragLoadIdx-a.loadIdx)<w)return void l.trigger(r.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:a})}else a.loadCounter=1;a.loadIdx=this.fragLoadIdx,this.fragCurrent=a,this.startFragmentRequested=!0,l.trigger(r.default.FRAG_LOADING,{frag:a}),this.state=e.FRAG_LOADING}}break;case e.WAITING_LEVEL:o=this.levels[this.level],o&&o.details&&(this.state=e.IDLE);break;case e.FRAG_LOADING:var A=this.media,s=this.fragCurrent;if(A&&(!A.paused||this.loadedmetadata===!1)&&s.autoLevel&&this.level&&this.levels.length>1){var k=performance.now()-s.trequest;if(k>500*s.duration){var P=1e3*s.loaded/k;s.expectedLen<s.loaded&&(s.expectedLen=s.loaded),h=A.currentTime;var L=(s.expectedLen-s.loaded)/P,_=this.bufferInfo(h,this.config.maxBufferHole).end-h,D=s.duration*this.levels[l.nextLoadLevel].bitrate/(8*P);_<2*s.duration&&L>_&&L>D&&(t.logger.warn("loading too slow, abort fragment loading"),t.logger.log("fragLoadedDelay/bufferStarvationDelay/fragLevelNextLoadedDelay :"+L.toFixed(1)+"/"+_.toFixed(1)+"/"+D.toFixed(1)),s.loader.abort(),l.trigger(r.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s}),this.state=e.IDLE)}}break;case e.FRAG_LOADING_WAITING_RETRY:var G=performance.now(),S=this.retryDate,I=this.media,M=I&&I.seeking;(!S||G>=S||M)&&(t.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=e.IDLE);break;case e.PARSING:break;case e.PARSED:case e.APPENDING:if(this.sourceBuffer){if(this.media.error)return t.logger.error("trying to append although a media error occured, switch to ERROR state"),void(this.state=e.ERROR);if(this.sourceBuffer.audio&&this.sourceBuffer.audio.updating||this.sourceBuffer.video&&this.sourceBuffer.video.updating);else if(this.mp4segments.length){var R=this.mp4segments.shift();try{this.sourceBuffer[R.type].appendBuffer(R.data),this.appendError=0}catch(a){if(t.logger.error("error while trying to append buffer:"+a.message+",try appending later"),this.mp4segments.unshift(R),22!==a.code){this.appendError?this.appendError++:this.appendError=1;var y={type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_APPEND_ERROR,frag:this.fragCurrent};if(this.appendError>this.config.appendErrorMaxRetry)return t.logger.log("fail "+this.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),y.fatal=!0,l.trigger(r.default.ERROR,y),void(this.state=e.ERROR);y.fatal=!1,l.trigger(r.default.ERROR,y)}}this.state=e.APPENDING}}else this.state=e.IDLE;break;case e.BUFFER_FLUSHING:for(;this.flushRange.length;){var C=this.flushRange[0];if(!this.flushBuffer(C.start,C.end))break;this.flushRange.shift()}0===this.flushRange.length&&(this.immediateSwitch&&this.immediateLevelSwitchEnd(),this.state=e.IDLE,this.fragPrevious=null)}this._checkBuffer(),this._checkFragmentChanged()}},{key:"bufferInfo",value:function(i,a){var e,n=this.media,t=n.buffered,r=[];for(e=0;e<t.length;e++)r.push({start:t.start(e),end:t.end(e)});return this.bufferedInfo(r,i,a)}},{key:"bufferedInfo",value:function(r,i,a){var o,l,n,f,e,t=[];for(r.sort(function(e,t){var r=e.start-t.start;return r?r:t.end-e.end}),e=0;e<r.length;e++){var u=t.length;if(u){var d=t[u-1].end;r[e].start-d<a?r[e].end>d&&(t[u-1].end=r[e].end):t.push(r[e])}else t.push(r[e])}for(e=0,o=0,l=n=i;e<t.length;e++){var s=t[e].start,h=t[e].end;if(i+a>=s&&h>i)l=s,n=h+a,o=n-i;else if(s>i+a){f=s;break}}return{len:o,start:l,end:n,nextStart:f}}},{key:"getBufferRange",value:function(r){var e,t;for(e=this.bufferRange.length-1;e>=0;e--)if(t=this.bufferRange[e],r>=t.start&&r<=t.end)return t;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(r){for(var i=this.media,t=i.buffered,e=0;e<t.length;e++)if(r>=t.start(e)&&r<=t.end(e))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var t,e,i=this.media;if(i&&i.seeking===!1&&(e=i.currentTime,e>i.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),this.isBuffered(e)?t=this.getBufferRange(e):this.isBuffered(e+.1)&&(t=this.getBufferRange(e+.1)),t)){var a=t.frag;a!==this.fragPlaying&&(this.fragPlaying=a,this.hls.trigger(r.default.FRAG_CHANGED,{frag:a}))}}},{key:"flushBuffer",value:function(d,l){var r,e,o,s,i,a;if(this.flushBufferCounter++<2*this.bufferRange.length&&this.sourceBuffer)for(var u in this.sourceBuffer){if(r=this.sourceBuffer[u],r.updating)return!1;for(e=0;e<r.buffered.length;e++)if(o=r.buffered.start(e),s=r.buffered.end(e),-1!==navigator.userAgent.toLowerCase().indexOf("firefox")&&l===Number.POSITIVE_INFINITY?(i=d,a=l):(i=Math.max(o,d),a=Math.min(s,l)),a-i>.5)return t.logger.log("flush "+u+" ["+i+","+a+"], of ["+o+","+s+"], pos:"+this.media.currentTime),r.remove(i,a),!1}var n,h=[];for(e=0;e<this.bufferRange.length;e++)n=this.bufferRange[e],this.isBuffered((n.start+n.end)/2)&&h.push(n);return this.bufferRange=h,t.logger.log("buffer flushed"),!0}},{key:"immediateLevelSwitch",value:function(){t.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,this.previouslyPaused=this.media.paused,this.media.pause());var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushBufferCounter=0,this.flushRange.push({start:0,end:Number.POSITIVE_INFINITY}),this.state=e.BUFFER_FLUSHING,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.tick()}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1,this.media.currentTime-=1e-4,this.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){var r,i,t;if(i=this.getBufferRange(this.media.currentTime),i&&this.flushRange.push({start:0,end:i.start-1}),this.media.paused)r=0;else{var s=this.hls.nextLoadLevel,o=this.levels[s],n=this.fragLastKbps;r=n&&this.fragCurrent?this.fragCurrent.duration*o.bitrate/(1e3*n)+1:0}if(t=this.getBufferRange(this.media.currentTime+r),t&&(t=this.followingBufferRange(t))){this.flushRange.push({start:t.start,end:Number.POSITIVE_INFINITY});var a=this.fragCurrent;a&&a.loader&&a.loader.abort(),this.fragCurrent=null}this.flushRange.length&&(this.flushBufferCounter=0,this.state=e.BUFFER_FLUSHING,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.tick())}},{key:"onMediaAttaching",value:function(t){var r=this.media=t.media,e=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),e.addEventListener("sourceopen",this.onmso),e.addEventListener("sourceended",this.onmse),e.addEventListener("sourceclose",this.onmsc),r.src=URL.createObjectURL(e)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var a=this.levels;a&&a.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void 0})});var i=this.mediaSource;if(i){if("open"===i.readyState)try{i.endOfStream()}catch(e){t.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}i.removeEventListener("sourceopen",this.onmso),i.removeEventListener("sourceended",this.onmse),i.removeEventListener("sourceclose",this.onmsc),this.media.src="",this.mediaSource=null,e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("loadedmetadata",this.onvmetadata),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvmetadata=null),this.media=null,this.loadedmetadata=!1,this.stop()}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(r.default.MEDIA_DETACHED)}},{key:"onMediaSeeking",value:function(){if(this.state===e.FRAG_LOADING&&0===this.bufferInfo(this.media.currentTime,this.config.maxBufferHole).len){t.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");var r=this.fragCurrent;r&&(r.loader&&r.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=e.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:"onMediaMetadata",value:function(){var e=this.media,r=e.currentTime;r||r===this.startPosition||(t.logger.log("onMediaMetadata: adjust currentTime to startPosition"),e.currentTime=this.startPosition),this.loadedmetadata=!0,this.tick()}},{key:"onMediaEnded",value:function(){t.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(r){var e,i=!1,a=!1;r.levels.forEach(function(t){e=t.codecs,e&&(-1!==e.indexOf("mp4a.40.2")&&(i=!0),-1!==e.indexOf("mp4a.40.5")&&(a=!0))}),this.audiocodecswitch=i&&a,this.audiocodecswitch&&t.logger.log("both AAC/HE-AAC audio found in levels; declaring audio codec as HE-AAC"),this.levels=r.levels,this.startLevelLoaded=!1,this.startFragmentRequested=!1,this.media&&this.config.autoStartLoad&&this.startLoad()}},{key:"onLevelLoaded",value:function(n){var i=n.details,a=n.level,s=this.levels[a],o=i.totalduration;if(t.logger.log("level "+a+" loaded ["+i.startSN+","+i.endSN+"],duration:"+o),this.levelLastLoaded=a,i.live){var u=s.details;u?(l.default.mergeDetails(u,i),i.PTSKnown?t.logger.log("live playlist sliding:"+i.fragments[0].start.toFixed(3)):t.logger.log("live playlist - outdated PTS, unknown sliding")):(i.PTSKnown=!1,t.logger.log("live playlist - first load, unknown sliding"))}else i.PTSKnown=!1;s.details=i,this.hls.trigger(r.default.LEVEL_UPDATED,{details:i,level:a}),this.startLevelLoaded===!1&&(i.live&&(this.startPosition=Math.max(0,o-this.config.liveSyncDurationCount*i.targetduration)),this.nextLoadPosition=this.startPosition,this.startLevelLoaded=!0),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){var i=this.fragCurrent;if(this.state===e.FRAG_LOADING&&i&&a.frag.level===i.level&&a.frag.sn===i.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:i});else{this.state=e.PARSING,this.stats=a.stats;var s=this.levels[this.level],o=s.details,d=o.totalduration,h=i.start,l=i.level,u=i.sn,n=s.audioCodec;this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),void 0===n&&(n=this.lastAudioCodec),n=-1!==n.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t.logger.log("Demuxing "+u+" of ["+o.startSN+" ,"+o.endSN+"],level "+l),this.demuxer.push(a.payload,n,s.videoCodec,h,i.cc,l,u,d,i.decryptdata)}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(i){if(this.state===e.PARSING){var n,r=this.levels[this.level].audioCodec,a=this.levels[this.level].videoCodec;this.lastAudioCodec=i.audioCodec,r&&this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),r=-1!==r.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t.logger.log("playlist_level/init_segment codecs: video => "+a+"/"+i.videoCodec+"; audio => "+r+"/"+i.audioCodec),(void 0===r||void 0===i.audioCodec)&&(r=i.audioCodec),(void 0===a||void 0===i.videoCodec)&&(a=i.videoCodec);var s=navigator.userAgent.toLowerCase();this.audiocodecswitch&&1!==i.audioChannelCount&&-1===s.indexOf("android")&&-1===s.indexOf("firefox")&&(r="mp4a.40.5"),this.sourceBuffer||(this.sourceBuffer={},t.logger.log("selected A/V codecs for sourceBuffers:"+r+","+a),r&&(n=this.sourceBuffer.audio=this.mediaSource.addSourceBuffer("video/mp4;codecs="+r),n.addEventListener("updateend",this.onsbue),n.addEventListener("error",this.onsbe)),a&&(n=this.sourceBuffer.video=this.mediaSource.addSourceBuffer("video/mp4;codecs="+a),n.addEventListener("updateend",this.onsbue),n.addEventListener("error",this.onsbe))),r&&this.mp4segments.push({type:"audio",data:i.audioMoov}),a&&this.mp4segments.push({type:"video",data:i.videoMoov}),this.tick()}}},{key:"onFragParsingData",value:function(i){if(this.state===e.PARSING){this.tparse2=Date.now();var a=this.levels[this.level],n=this.fragCurrent;t.logger.log("parsed "+i.type+",PTS:["+i.startPTS.toFixed(3)+","+i.endPTS.toFixed(3)+"],DTS:["+i.startDTS.toFixed(3)+"/"+i.endDTS.toFixed(3)+"],nb:"+i.nb);var s=l.default.updateFragPTS(a.details,n.sn,i.startPTS,i.endPTS);this.hls.trigger(r.default.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:s}),this.mp4segments.push({type:i.type,data:i.moof}),this.mp4segments.push({type:i.type,data:i.mdat}),this.nextLoadPosition=i.endPTS,this.bufferRange.push({type:i.type,start:i.startPTS,end:i.endPTS,frag:n}),this.tick()}else t.logger.warn("not in PARSING state, ignoring FRAG_PARSING_DATA event")}},{key:"onFragParsed",value:function(){this.state===e.PARSING&&(this.state=e.PARSED,this.stats.tparsed=performance.now(),this.tick())}},{key:"onError",value:function(a){switch(a.details){case i.ErrorDetails.FRAG_LOAD_ERROR:case i.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!a.fatal){var n=this.fragLoadError;if(n?n++:n=1,n<=this.config.fragLoadingMaxRetry){this.fragLoadError=n,a.frag.loadCounter=0;var s=Math.min(Math.pow(2,n-1)*this.config.fragLoadingRetryDelay,64e3);t.logger.warn("mediaController: frag loading failed, retry in "+s+" ms"),
-this.retryDate=performance.now()+s,this.state=e.FRAG_LOADING_WAITING_RETRY}else t.logger.error("mediaController: "+a.details+" reaches max retry, redispatch as fatal ..."),a.fatal=!0,this.hls.trigger(r.default.ERROR,a),this.state=e.ERROR}break;case i.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case i.ErrorDetails.LEVEL_LOAD_ERROR:case i.ErrorDetails.LEVEL_LOAD_TIMEOUT:case i.ErrorDetails.KEY_LOAD_ERROR:case i.ErrorDetails.KEY_LOAD_TIMEOUT:t.logger.warn("mediaController: "+a.details+" while loading frag,switch to "+(a.fatal?"ERROR":"IDLE")+" state ..."),this.state=a.fatal?e.ERROR:e.IDLE}}},{key:"onSBUpdateEnd",value:function(){if(this.state===e.APPENDING&&0===this.mp4segments.length){var a=this.fragCurrent,i=this.stats;a&&(this.fragPrevious=a,i.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*i.length/(i.tbuffered-i.tfirst)),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:i,frag:a}),t.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=e.IDLE)}this.tick()}},{key:"_checkBuffer",value:function(){var e=this.media;if(e){var o=e.readyState;if(o){var a=this.seekAfterBuffered;if(a)e.duration>=a&&(e.currentTime=a,this.seekAfterBuffered=void 0);else{var r=e.currentTime,n=this.bufferInfo(r,0),u=!(e.paused||e.ended||e.seeking||3>o),s=.2;if(n.len<=s&&(r>e.playbackRate*this.lastCurrentTime||!u?s=0:t.logger.log("playback seems stuck"),n.len<=s)){var i=n.nextStart,l=i-r;i&&l<this.config.maxSeekHole&&l>.005&&!e.seeking&&(t.logger.log("adjust currentTime from "+r+" to "+i),e.currentTime=i)}}}}}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"onSBUpdateError",value:function(a){t.logger.error("sourceBuffer error:"+a),this.state=e.ERROR,this.hls.trigger(r.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1,frag:this.fragCurrent})}},{key:"timeRangesToString",value:function(t){for(var r="",i=t.length,e=0;i>e;e++)r+="["+t.start(e)+","+t.end(e)+"]";return r}},{key:"onMediaSourceOpen",value:function(){t.logger.log("media source opened"),this.hls.trigger(r.default.MEDIA_ATTACHED),this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvmetadata=this.onMediaMetadata.bind(this),this.onvended=this.onMediaEnded.bind(this);var e=this.media;e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("loadedmetadata",this.onvmetadata),e.addEventListener("ended",this.onvended),this.levels&&this.config.autoStartLoad&&this.startLoad(),this.mediaSource.removeEventListener("sourceopen",this.onmso)}},{key:"onMediaSourceClose",value:function(){t.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){t.logger.log("media source ended")}},{key:"currentLevel",get:function(){if(this.media){var e=this.getBufferRange(this.media.currentTime);if(e)return e.frag.level}return-1}},{key:"nextBufferRange",get:function(){return this.media?this.followingBufferRange(this.getBufferRange(this.media.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferRange;return e?e.frag.level:-1}}]),a}(o.default);s.default=_,h.exports=s.default},{"../demux/demuxer":13,"../errors":17,"../event-handler":18,"../events":19,"../helper/level-helper":20,"../utils/binary-search":28,"../utils/logger":29}],6:[function(n,t,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(h){r(this,e),this._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],this._precompute();var i,s,t,o,l,n=this._tables[0][4],u=this._tables[1],a=h.length,d=1;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);for(o=h.slice(0),l=[],this._key=[o,l],i=a;4*a+28>i;i++)t=o[i-1],(i%a===0||8===a&&i%a===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%a===0&&(t=t<<8^t>>>24^d<<24,d=d<<1^283*(d>>7))),o[i]=o[i-a]^t;for(s=0;i;s++,i--)t=o[3&s?i:i-4],4>=i||4>s?l[s]=t:l[s]=u[0][n[t>>>24]]^u[1][n[t>>16&255]]^u[2][n[t>>8&255]]^u[3][n[255&t]]}return i(e,[{key:"_precompute",value:function(){var e,i,r,u,h,d,t,s,l,n=this._tables[0],o=this._tables[1],f=n[4],v=o[4],a=[],c=[];for(e=0;256>e;e++)c[(a[e]=e<<1^283*(e>>7))^e]=e;for(i=r=0;!f[i];i^=u||1,r=c[r]||1)for(t=r^r<<1^r<<2^r<<3^r<<4,t=t>>8^255&t^99,f[i]=t,v[t]=i,d=a[h=a[u=a[i]]],l=16843009*d^65537*h^257*u^16843008*i,s=257*a[t]^16843008*t,e=0;4>e;e++)n[e][i]=s=s<<24^s>>>8,o[e][t]=l=l<<24^l>>>8;for(e=0;5>e;e++)n[e]=n[e].slice(0),o[e]=o[e].slice(0)}},{key:"decrypt",value:function(R,p,_,b,E,m){var f,g,v,n,e=this._key[1],t=R^e[0],i=b^e[1],a=_^e[2],r=p^e[3],y=e.length/4-2,s=4,o=this._tables[1],h=o[0],d=o[1],u=o[2],l=o[3],c=o[4];for(n=0;y>n;n++)f=h[t>>>24]^d[i>>16&255]^u[a>>8&255]^l[255&r]^e[s],g=h[i>>>24]^d[a>>16&255]^u[r>>8&255]^l[255&t]^e[s+1],v=h[a>>>24]^d[r>>16&255]^u[t>>8&255]^l[255&i]^e[s+2],r=h[r>>>24]^d[t>>16&255]^u[i>>8&255]^l[255&a]^e[s+3],s+=4,t=f,i=g,a=v;for(n=0;4>n;n++)E[(3&-n)+m]=c[t>>>24]<<24^c[i>>16&255]<<16^c[a>>8&255]<<8^c[255&r]^e[s++],f=t,t=i,i=a,a=r,r=f}}]),e}();e.default=a,t.exports=e.default},{}],7:[function(t,r,e){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=t("./aes"),o=i(s),l=function(){function e(t,r){a(this,e),this.key=t,this.iv=r}return n(e,[{key:"ntoh",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"doDecrypt",value:function(i,g,a){var u,f,s,h,l,c,d,n,e,r=new Int32Array(i.buffer,i.byteOffset,i.byteLength>>2),p=new o.default(Array.prototype.slice.call(g)),v=new Uint8Array(i.byteLength),t=new Int32Array(v.buffer);for(u=~~a[0],f=~~a[1],s=~~a[2],h=~~a[3],e=0;e<r.length;e+=4)l=~~this.ntoh(r[e]),c=~~this.ntoh(r[e+1]),d=~~this.ntoh(r[e+2]),n=~~this.ntoh(r[e+3]),p.decrypt(l,c,d,n,t,e),t[e]=this.ntoh(t[e]^u),t[e+1]=this.ntoh(t[e+1]^f),t[e+2]=this.ntoh(t[e+2]^s),t[e+3]=this.ntoh(t[e+3]^h),u=l,f=c,s=d,h=n;return v}},{key:"localDecrypt",value:function(e,t,r,i){var a=this.doDecrypt(e,t,r);i.set(a,e.byteOffset)}},{key:"decrypt",value:function(n){var r=32e3,t=new Int32Array(n),i=new Uint8Array(n.byteLength),e=0,s=this.key,a=this.iv;for(this.localDecrypt(t.subarray(e,e+r),s,a,i),e=r;e<t.length;e+=r)a=new Uint32Array([this.ntoh(t[e-4]),this.ntoh(t[e-3]),this.ntoh(t[e-2]),this.ntoh(t[e-1])]),this.localDecrypt(t.subarray(e,e+r),s,a,i);return i}}]),e}();e.default=l,r.exports=e.default},{"./aes":6}],8:[function(t,n,r){"use strict";function u(e){return e&&e.__esModule?e:{default:e}}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 d=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=t("./aes128-decrypter"),o=u(s),i=t("../errors"),e=t("../utils/logger"),l=function(){function t(r){a(this,t),this.hls=r;try{var e=window?window.crypto:crypto;this.subtle=e.subtle||e.webkitSubtle,this.disableWebCrypto=!this.subtle}catch(e){this.disableWebCrypto=!0}}return d(t,[{key:"destroy",value:function(){}},{key:"decrypt",value:function(e,t,r,i){this.disableWebCrypto&&this.hls.config.enableSoftwareAES?this.decryptBySoftware(e,t,r,i):this.decryptByWebCrypto(e,t,r,i)}},{key:"decryptByWebCrypto",value:function(t,r,i,a){var n=this;e.logger.log("decrypting by WebCrypto API"),this.subtle.importKey("raw",r,{name:"AES-CBC",length:128},!1,["decrypt"]).then(function(e){n.subtle.decrypt({name:"AES-CBC",iv:i.buffer},e,t).then(a).catch(function(e){n.onWebCryptoError(e,t,r,i,a)})}).catch(function(e){n.onWebCryptoError(e,t,r,i,a)})}},{key:"decryptBySoftware",value:function(r,i,a,n){e.logger.log("decrypting by JavaScript Implementation");var t=new DataView(i.buffer),s=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]);t=new DataView(a.buffer);var l=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]),u=new o.default(s,l);n(u.decrypt(r).buffer)}},{key:"onWebCryptoError",value:function(t,r,a,n,s){this.hls.config.enableSoftwareAES?(e.logger.log("disabling to use WebCrypto API"),this.disableWebCrypto=!0,this.decryptBySoftware(r,a,n,s)):(e.logger.error("decrypting error : "+t.message),this.hls.trigger(Event.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:t.message}))}}]),t}();r.default=l,n.exports=r.default},{"../errors":17,"../utils/logger":29,"./aes128-decrypter":7}],9:[function(e,s,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),h=e("./adts"),o=r(h),l=e("../utils/logger"),u=e("../demux/id3"),i=r(u),d=function(){function e(t,r){a(this,e),this.observer=t,this.remuxerClass=r,this.remuxer=new this.remuxerClass(t),this._aacTrack={type:"audio",id:-1,sequenceNumber:0,samples:[],len:0}}return n(e,[{key:"push",value:function(t,p,E,g,_,m,b,y){var n,a,e,s,c,f,u,v,r=this._aacTrack,h=new i.default(t),d=90*h.timeStamp;for(e=h.length,u=t.length;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);for(r.audiosamplerate||(n=o.default.getAudioConfig(this.observer,t,e,p),r.config=n.config,r.audiosamplerate=n.samplerate,r.channelCount=n.channelCount,r.codec=n.codec,r.timescale=this.remuxer.timescale,r.duration=this.remuxer.timescale*y,l.logger.log("parsed codec:"+r.codec+",rate:"+n.samplerate+",nb channel:"+n.channelCount)),f=0;u>e+5&&(a=(3&t[e+3])<<11,a|=t[e+4]<<3,a|=(224&t[e+5])>>>5,s=1&t[e+1]?7:9,a-=s,c=Math.round(d+1024*f*9e4/r.audiosamplerate),a>0&&u>=e+s+a);)for(v={unit:t.subarray(e+s,e+s+a),pts:c,dts:c},r.samples.push(v),r.len+=a,e+=a+s,f++;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);this.remuxer.remux(this._aacTrack,{samples:[]},{samples:[{pts:d,dts:d,unit:h.payload}]},g)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){var e,r,a=new i.default(t);if(a.hasTimeStamp)for(e=a.length,r=t.length;r-1>e;e++)if(255===t[e]&&240===(240&t[e+1]))return!0;return!1}}]),e}();t.default=d,s.exports=t.default},{"../demux/id3":15,"../utils/logger":29,"./adts":10}],10:[function(t,i,e){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=t("../utils/logger"),r=t("../errors"),o=function(){function e(){a(this,e)}return n(e,null,[{key:"getAudioConfig",value:function(f,u,l,a){var i,e,n,o,t,h=navigator.userAgent.toLowerCase(),d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return i=((192&u[l+2])>>>6)+1,e=(60&u[l+2])>>>2,e>d.length-1?void f.trigger(Event.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+e}):(o=(1&u[l+2])<<2,o|=(192&u[l+3])>>>6,s.logger.log("manifest codec:"+a+",ADTS data:type:"+i+",sampleingIndex:"+e+"["+d[e]+"Hz],channelConfig:"+o),-1!==h.indexOf("firefox")?e>=6?(i=5,t=new Array(4),n=e-3):(i=2,t=new Array(2),n=e):-1!==h.indexOf("android")?(i=2,t=new Array(2),n=e):(i=5,t=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&e>=6?n=e-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(e>=6||1===o)||!a&&1===o)&&(i=2,t=new Array(2)),n=e)),t[0]=i<<3,t[0]|=(14&e)>>1,t[1]|=(1&e)<<7,t[1]|=o<<3,5===i&&(t[1]|=(14&n)>>1,t[2]=(1&n)<<7,t[2]|=8,t[3]=0),{config:t,samplerate:d[e],channelCount:o,codec:"mp4a.40."+i})}}]),e}();e.default=o,i.exports=e.default},{"../errors":17,"../utils/logger":29}],11:[function(e,o,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var f=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=e("../events"),c=r(s),i=e("../errors"),u=e("../demux/aacdemuxer"),a=r(u),h=e("../demux/tsdemuxer"),n=r(h),l=function(){function e(t,r){d(this,e),this.hls=t,this.remuxer=r}return f(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(t,r,s,o,l,u,d,h){var e=this.demuxer;if(!e)if(n.default.probe(t))e=this.demuxer=new n.default(this.hls,this.remuxer);else{if(!a.default.probe(t))return void this.hls.trigger(c.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});e=this.demuxer=new a.default(this.hls,this.remuxer)}e.push(t,r,s,o,l,u,d,h)}}]),e}();t.default=l,o.exports=t.default},{"../demux/aacdemuxer":9,"../demux/tsdemuxer":16,"../errors":17,"../events":19}],12:[function(t,s,i){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(i,"__esModule",{value:!0});var a=t("../demux/demuxer-inline"),n=r(a),f=t("../events"),e=r(f),l=t("events"),u=r(l),d=t("../remux/mp4-remuxer"),h=r(d),o=function(r){var t=new u.default;t.trigger=function(i){for(var r=arguments.length,a=Array(r>1?r-1:0),e=1;r>e;e++)a[e-1]=arguments[e];t.emit.apply(t,[i,i].concat(a))},t.off=function(a){for(var r=arguments.length,i=Array(r>1?r-1:0),e=1;r>e;e++)i[e-1]=arguments[e];t.removeListener.apply(t,[a].concat(i))},r.addEventListener("message",function(i){switch(i.data.cmd){case"init":r.demuxer=new n.default(t,h.default);break;case"demux":var e=i.data;r.demuxer.push(new Uint8Array(e.data),e.audioCodec,e.videoCodec,e.timeOffset,e.cc,e.level,e.sn,e.duration)}}),t.on(e.default.FRAG_PARSING_INIT_SEGMENT,function(a,t){var e={event:a},i=[];t.audioCodec&&(e.audioCodec=t.audioCodec,e.audioMoov=t.audioMoov.buffer,e.audioChannelCount=t.audioChannelCount,i.push(e.audioMoov)),t.videoCodec&&(e.videoCodec=t.videoCodec,e.videoMoov=t.videoMoov.buffer,e.videoWidth=t.videoWidth,e.videoHeight=t.videoHeight,i.push(e.videoMoov)),r.postMessage(e,i)}),t.on(e.default.FRAG_PARSING_DATA,function(i,e){var t={event:i,type:e.type,startPTS:e.startPTS,endPTS:e.endPTS,startDTS:e.startDTS,endDTS:e.endDTS,moof:e.moof.buffer,mdat:e.mdat.buffer,nb:e.nb};r.postMessage(t,[t.moof,t.mdat])}),t.on(e.default.FRAG_PARSED,function(e){r.postMessage({event:e})}),t.on(e.default.ERROR,function(e,t){r.postMessage({event:e,data:t})}),t.on(e.default.FRAG_PARSING_METADATA,function(e,t){var i={event:e,samples:t.samples};r.postMessage(i)})};i.default=o,s.exports=i.default},{"../demux/demuxer-inline":11,"../events":19,"../remux/mp4-remuxer":26,events:1}],13:[function(e,u,i){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=e("../events"),t=r(l),f=e("../demux/demuxer-inline"),s=r(f),d=e("../demux/demuxer-worker"),h=r(d),n=e("../utils/logger"),c=e("../remux/mp4-remuxer"),a=r(c),g=e("../crypt/decrypter"),p=r(g),y=function(){function r(t){if(v(this,r),this.hls=t,t.config.enableWorker&&"undefined"!=typeof Worker){n.logger.log("demuxing in webworker");try{var i=e("webworkify");this.w=i(h.default),this.onwmsg=this.onWorkerMessage.bind(this),this.w.addEventListener("message",this.onwmsg),this.w.postMessage({cmd:"init"})}catch(e){n.logger.error("error while initializing DemuxerWorker, fallback on DemuxerInline"),this.demuxer=new s.default(t,a.default)}}else this.demuxer=new s.default(t,a.default);this.demuxInitialized=!0}return o(r,[{key:"destroy",value:function(){this.w?(this.w.removeEventListener("message",this.onwmsg),this.w.terminate(),this.w=null):(this.demuxer.destroy(),this.demuxer=null),this.decrypter&&(this.decrypter.destroy(),this.decrypter=null)}},{key:"pushDecrypted",value:function(e,t,r,i,a,n,s,o){this.w?this.w.postMessage({cmd:"demux",data:e,audioCodec:t,videoCodec:r,timeOffset:i,cc:a,level:n,sn:s,duration:o},[e]):this.demuxer.push(new Uint8Array(e),t,r,i,a,n,s,o)}},{key:"push",value:function(t,r,i,a,n,s,o,l,e){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){null==this.decrypter&&(this.decrypter=new p.default(this.hls));var u=this;this.decrypter.decrypt(t,e.key,e.iv,function(e){u.pushDecrypted(e,r,i,a,n,s,o,l)})}else this.pushDecrypted(t,r,i,a,n,s,o,l)}},{key:"onWorkerMessage",value:function(e){switch(e.data.event){case t.default.FRAG_PARSING_INIT_SEGMENT:var r={};e.data.audioMoov&&(r.audioMoov=new Uint8Array(e.data.audioMoov),r.audioCodec=e.data.audioCodec,r.audioChannelCount=e.data.audioChannelCount),e.data.videoMoov&&(r.videoMoov=new Uint8Array(e.data.videoMoov),r.videoCodec=e.data.videoCodec,r.videoWidth=e.data.videoWidth,r.videoHeight=e.data.videoHeight),this.hls.trigger(t.default.FRAG_PARSING_INIT_SEGMENT,r);break;case t.default.FRAG_PARSING_DATA:this.hls.trigger(t.default.FRAG_PARSING_DATA,{moof:new Uint8Array(e.data.moof),mdat:new Uint8Array(e.data.mdat),startPTS:e.data.startPTS,endPTS:e.data.endPTS,startDTS:e.data.startDTS,endDTS:e.data.endDTS,type:e.data.type,nb:e.data.nb});break;case t.default.FRAG_PARSING_METADATA:this.hls.trigger(t.default.FRAG_PARSING_METADATA,{samples:e.data.samples});break;default:this.hls.trigger(e.data.event,e.data.data)}}}]),r}();i.default=y,u.exports=i.default},{"../crypt/decrypter":8,"../demux/demuxer-inline":11,"../demux/demuxer-worker":12,"../events":19,"../remux/mp4-remuxer":26,"../utils/logger":29,webworkify:2}],14:[function(t,r,e){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),n=t("../utils/logger"),s=function(){function e(t){i(this,e),this.data=t,this.bytesAvailable=this.data.byteLength,this.word=0,this.bitsAvailable=0}return a(e,[{key:"loadWord",value:function(){var t=this.data.byteLength-this.bytesAvailable,r=new Uint8Array(4),e=Math.min(4,this.bytesAvailable);if(0===e)throw new Error("no bytes available");r.set(this.data.subarray(t,t+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}},{key:"skipBits",value:function(e){var t;this.bitsAvailable>e?(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(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0?r<<e|this.readBits(e):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>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:"skipScalingList",value:function(a){var t,i,r=8,e=8;for(t=0;a>t;t++)0!==e&&(i=this.readEG(),e=(r+i+256)%256),r=0===e?r:e}},{key:"readSPS",value:function(){var t,g,p,l,a,n,i,o,r,s=0,d=0,h=0,f=0,c=1;if(this.readUByte(),t=this.readUByte(),g=this.readBits(5),this.skipBits(3),p=this.readUByte(),this.skipUEG(),100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t){var v=this.readUEG();if(3===v&&this.skipBits(1),this.skipUEG(),this.skipUEG(),this.skipBits(1),this.readBoolean())for(o=3!==v?8:12,r=0;o>r;r++)this.readBoolean()&&(6>r?this.skipScalingList(16):this.skipScalingList(64))}this.skipUEG();var u=this.readUEG();if(0===u)this.readUEG();else if(1===u)for(this.skipBits(1),this.skipEG(),this.skipEG(),l=this.readUEG(),r=0;l>r;r++)this.skipEG();if(this.skipUEG(),this.skipBits(1),a=this.readUEG(),n=this.readUEG(),i=this.readBits(1),0===i&&this.skipBits(1),this.skipBits(1),this.readBoolean()&&(s=this.readUEG(),d=this.readUEG(),h=this.readUEG(),f=this.readUEG()),this.readBoolean()&&this.readBoolean()){var e=void 0,y=this.readUByte();switch(y){case 2:e=[12,11];break;case 3:e=[10,11];break;case 4:e=[16,11];break;case 5:e=[40,33];break;case 6:e=[24,11];break;case 7:e=[20,11];break;case 8:e=[32,11];break;case 9:e=[80,33];break;case 10:e=[18,11];break;case 11:e=[15,11];break;case 12:e=[64,33];break;case 13:e=[160,99];break;case 14:e=[4,3];break;case 15:e=[3,2];break;case 16:e=[2,1];break;case 255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}e&&(c=e[0]/e[1])}return{width:(16*(a+1)-2*s-2*d)*c,height:(2-i)*(n+1)*16-(i?2:4)*(h+f)}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=s,r.exports=e.default},{"../utils/logger":29}],15:[function(r,i,e){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),t=r("../utils/logger"),s=function(){function e(i){a(this,e),this._hasTimeStamp=!1;for(var l,u,d,h,f,s,o,n,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++],h=127&i[r++],f=(l<<21)+(u<<14)+(d<<7)+h,s=r+f,this._parseID3Frames(i,r,s),r=s;else{if("3DI"!==o)return r-=3,n=r,void(n&&(this.hasTimeStamp||t.logger.warn("ID3 tag found, but no timestamp"),this._length=n,this._payload=i.subarray(0,n)));r+=7,t.logger.log("3DI footer found, end: "+r)}}return n(e,[{key:"readUTF",value:function(i,e,a){var t="",r=e,n=e+a;do t+=String.fromCharCode(i[r++]);while(n>r);return t}},{key:"_parseID3Frames",value:function(r,e,n){for(var a,s,o,l,i;n>=e+8;)switch(a=this.readUTF(r,e,4),e+=4,s=r[e++]<<24+r[e++]<<16+r[e++]<<8+r[e++],l=r[e++]<<8+r[e++],o=e,a){case"PRIV":if("com.apple.streaming.transportStreamTimestamp"===this.readUTF(r,e,44)){e+=44,e+=4;var u=1&r[e++];this._hasTimeStamp=!0,i=((r[e++]<<23)+(r[e++]<<15)+(r[e++]<<7)+r[e++])/45,u&&(i+=47721858.84),i=Math.round(i),t.logger.trace("ID3 timestamp found: "+i),this._timeStamp=i}}}},{key:"hasTimeStamp",get:function(){return this._hasTimeStamp}},{key:"timeStamp",get:function(){return this._timeStamp}},{key:"length",get:function(){return this._length}},{key:"payload",get:function(){return this._payload}}]),e}();e.default=s,i.exports=e.default},{"../utils/logger":29}],16:[function(e,o,i){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var c=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=e("./adts"),v=a(s),l=e("../events"),n=a(l),d=e("./exp-golomb"),h=a(d),t=e("../utils/logger"),r=e("../errors"),u=function(){function e(t,r){f(this,e),this.observer=t,this.remuxerClass=r,this.lastCC=0,this.remuxer=new this.remuxerClass(t)}return c(e,[{key:"switchLevel",value:function(){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack={type:"video",id:-1,sequenceNumber:0,samples:[],len:0,nbNalu:0},this._aacTrack={type:"audio",id:-1,sequenceNumber:0,samples:[],len:0},this._id3Track={type:"id3",id:-1,sequenceNumber:0,samples:[],len:0},this.remuxer.switchLevel()}},{key:"insertDiscontinuity",value:function(){this.switchLevel(),this.remuxer.insertDiscontinuity()}},{key:"push",value:function(i,L,E,R,f,h,g,_){var l,o,s,e,d,u,y,a,b=i.length;this.audioCodec=L,this.videoCodec=E,this.timeOffset=R,this._duration=_,this.contiguous=!1,f!==this.lastCC?(t.logger.log("discontinuity detected"),this.insertDiscontinuity(),this.lastCC=f):h!==this.lastLevel?(t.logger.log("level switch detected"),this.switchLevel(),this.lastLevel=h):g===this.lastSN+1&&(this.contiguous=!0),this.lastSN=g,this.contiguous||(this.aacOverFlow=null);var p=this.pmtParsed,v=this._avcTrack.id,c=this._aacTrack.id,m=this._id3Track.id;for(e=0;b>e;e+=188)if(71===i[e]){if(d=!!(64&i[e+1]),u=((31&i[e+1])<<8)+i[e+2],y=(48&i[e+3])>>4,y>1){if(a=e+5+i[e+4],a===e+188)continue}else a=e+4;p?u===v?(d&&(l&&this._parseAVCPES(this._parsePES(l)),l={data:[],size:0}),l&&(l.data.push(i.subarray(a,e+188)),l.size+=e+188-a)):u===c?(d&&(o&&this._parseAACPES(this._parsePES(o)),o={data:[],size:0}),o&&(o.data.push(i.subarray(a,e+188)),o.size+=e+188-a)):u===m&&(d&&(s&&this._parseID3PES(this._parsePES(s)),s={data:[],size:0}),s&&(s.data.push(i.subarray(a,e+188)),s.size+=e+188-a)):(d&&(a+=i[a]+1),0===u?this._parsePAT(i,a):u===this._pmtId&&(this._parsePMT(i,a),p=this.pmtParsed=!0,v=this._avcTrack.id,c=this._aacTrack.id,m=this._id3Track.id))}else this.observer.trigger(n.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});l&&this._parseAVCPES(this._parsePES(l)),o&&this._parseAACPES(this._parsePES(o)),s&&this._parseID3PES(this._parsePES(s)),this.remux()}},{key:"remux",value:function(){this.remuxer.remux(this._aacTrack,this._avcTrack,this._id3Track,this.timeOffset,this.contiguous)}},{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(r,e){var a,n,s,i;for(a=(15&r[e+1])<<8|r[e+2],n=e+3+a-4,s=(15&r[e+10])<<8|r[e+11],e+=12+s;n>e;){switch(i=(31&r[e+1])<<8|r[e+2],r[e]){case 15:this._aacTrack.id=i;break;case 21:this._id3Track.id=i;break;case 27:this._avcTrack.id=i;break;default:t.logger.log("unkown stream type:"+r[e])}e+=((15&r[e+3])<<8|r[e+4])+5}}},{key:"_parsePES",value:function(t){var e,a,u,o,d,n,r,i,s,l=0;if(e=t.data[0],u=(e[0]<<16)+(e[1]<<8)+e[2],1===u){for(o=(e[4]<<8)+e[5],a=e[7],192&a&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,r>4294967295&&(r-=8589934592),64&a?(i=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,i>4294967295&&(i-=8589934592)):i=r),d=e[8],s=d+9,t.data[0]=t.data[0].subarray(s),t.size-=s,n=new Uint8Array(t.size);t.data.length;)e=t.data.shift(),n.set(e,l),l+=e.byteLength;return{data:n,pts:r,dts:i,len:o}}return null}},{key:"_parseAVCPES",value:function(a){var g,i,d=this,e=this._avcTrack,l=e.samples,p=this._parseAVCNALu(a.data),s=[],n=!1,v=!1,f=0;if(0===p.length&&l.length>0){var c=l[l.length-1],o=c.units.units[c.units.units.length-1],u=new Uint8Array(o.data.byteLength+a.data.byteLength);u.set(o.data,0),u.set(a.data,o.data.byteLength),o.data=u,c.units.length+=a.data.byteLength,e.len+=a.data.byteLength}a.data=null;var r="";p.forEach(function(t){switch(t.type){case 1:i=!0,n&&(r+="NDR ");break;case 5:i=!0,n&&(r+="IDR "),v=!0;break;case 6:i=!0,n&&(r+="SEI ");break;case 7:if(i=!0,n&&(r+="SPS "),!e.sps){var c=new h.default(t.data),l=c.readSPS();e.width=l.width,e.height=l.height,e.sps=[t.data],e.timescale=d.remuxer.timescale,e.duration=d.remuxer.timescale*d._duration;for(var g=t.data.subarray(1,4),u="avc1.",o=0;3>o;o++){var a=g[o].toString(16);a.length<2&&(a="0"+a),u+=a}e.codec=u}break;case 8:i=!0,n&&(r+="PPS "),e.pps||(e.pps=[t.data]);break;case 9:i=!0,n&&(r+="AUD ");break;default:i=!1,r+="unknown NAL "+t.type+" "}i&&(s.push(t),f+=t.data.byteLength)}),(n||r.length)&&t.logger.log(r),s.length&&(v===!0||e.sps)&&(g={units:{units:s,length:f},pts:a.pts,dts:a.dts,key:v},l.push(g),e.len+=f,e.nbNalu+=s.length)}},{key:"_parseAVCNALu",value:function(r){for(var n,i,s,o,a,h,t=0,c=r.byteLength,e=0,d=[];c>t;)switch(n=r[t++],e){case 0:0===n&&(e=1);break;case 1:e=0===n?2:0;break;case 2:case 3:if(0===n)e=3;else if(1===n){if(o=31&r[t],a)s={data:r.subarray(a,t-e-1),type:h},d.push(s);else if(i=t-e-1){var p=this._avcTrack,f=p.samples;if(f.length){var v=f[f.length-1],g=v.units.units,l=g[g.length-1],u=new Uint8Array(l.data.byteLength+i);u.set(l.data,0),u.set(r.subarray(0,i),l.data.byteLength),l.data=u,v.units.length+=i,p.len+=i}}a=t,h=o,(1===o||5===o)&&(t=c),e=0}else e=0}return a&&(s={data:r.subarray(a,c),type:h},d.push(s)),d}},{key:"_parseAACPES",value:function(p){var l,o,y,f,e,u,h,s,m,a=this._aacTrack,i=p.data,R=p.pts,_=0,E=this._duration,b=this.audioCodec;if(this.aacOverFlow){var g=new Uint8Array(this.aacOverFlow.byteLength+i.byteLength);g.set(this.aacOverFlow,0),g.set(i,this.aacOverFlow.byteLength),i=g}for(e=_,s=i.length;s-1>e&&(255!==i[e]||240!==(240&i[e+1]));e++);if(e){var c,d;if(s-1>e?(c="AAC PES did not start with ADTS header,offset:"+e,d=!1):(c="no ADTS header found in AAC PES",d=!0),this.observer.trigger(n.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:d,reason:c}),d)return}for(a.audiosamplerate||(l=v.default.getAudioConfig(this.observer,i,e,b),a.config=l.config,a.audiosamplerate=l.samplerate,a.channelCount=l.channelCount,a.codec=l.codec,a.timescale=this.remuxer.timescale,a.duration=a.timescale*E,t.logger.log("parsed codec:"+a.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)),f=0,y=9216e4/a.audiosamplerate;s>e+5&&(u=1&i[e+1]?7:9,o=(3&i[e+3])<<11|i[e+4]<<3|(224&i[e+5])>>>5,o-=u,h=Math.round(R+f*y),o>0&&s>=e+u+o);)for(m={unit:i.subarray(e+u,e+u+o),pts:h,dts:h},a.samples.push(m),a.len+=o,e+=o+u,f++;s-1>e&&(255!==i[e]||240!==(240&i[e+1]));e++);s>e?this.aacOverFlow=i.subarray(e,s):this.aacOverFlow=null}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(e){return e.length>=564&&71===e[0]&&71===e[188]&&71===e[376]?!0:!1}}]),e}();i.default=u,o.exports=i.default},{"../errors":17,"../events":19,"../utils/logger":29,"./adts":10,"./exp-golomb":14}],17:[function(i,a,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t={NETWORK_ERROR:"hlsNetworkError",MEDIA_ERROR:"hlsMediaError",OTHER_ERROR:"hlsOtherError"};e.ErrorTypes=t;var r={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",LEVEL_LOAD_ERROR:"levelLoadError",
-LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError"};e.ErrorDetails=r},{}],18:[function(n,t,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(n){r(this,e),this.hls=n,this.onEvent=this.onEvent.bind(this);for(var i=arguments.length,a=Array(i>1?i-1:0),t=1;i>t;t++)a[t-1]=arguments[t];this.handledEvents=a,this.useGenericHandler=!0,this.registerListeners()}return i(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{key:"isEventHandler",value:function(){return"object"==typeof this.handledEvents&&this.handledEvents.length&&"function"==typeof this.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if("hlsEventGeneric"===e)throw new Error("Forbidden event name: "+e);this.hls.on(e,this.onEvent)}.bind(this))}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)}.bind(this))}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){var r=function(t,r){var e="on"+t.replace("hls","");if("function"!=typeof this[e])throw new Error("Event "+t+" has no generic handler in this "+this.constructor.name+" class (tried "+e+")");return this[e].bind(this,r)};r.call(this,e,t).call()}}]),e}();e.default=a,t.exports=e.default},{}],19:[function(t,e,r){"use strict";e.exports={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVEL_SWITCH:"hlsLevelSwitch",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded"}},{}],20:[function(r,i,e){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),t=r("../utils/logger"),s=function(){function e(){a(this,e)}return n(e,null,[{key:"mergeDetails",value:function(n,i){var s,c=Math.max(n.startSN,i.startSN)-i.startSN,d=Math.min(n.endSN,i.endSN)-i.startSN,h=i.startSN-n.startSN,f=n.fragments,o=i.fragments,u=0;if(c>d)return void(i.PTSKnown=!1);for(var r=c;d>=r;r++){var l=f[h+r],a=o[r];u=l.cc-a.cc,isNaN(l.startPTS)||(a.start=a.startPTS=l.startPTS,a.endPTS=l.endPTS,a.duration=l.duration,s=a)}if(u)for(t.logger.log("discontinuity sliding from playlist, take drift into account"),r=0;r<o.length;r++)o[r].cc+=u;if(s)e.updateFragPTS(i,s.sn,s.startPTS,s.endPTS);else{var v=f[h].start;for(r=0;r<o.length;r++)o[r].start+=v}i.PTSKnown=n.PTSKnown}},{key:"updateFragPTS",value:function(i,l,a,s){var o,n,r,t;if(l<i.startSN||l>i.endSN)return 0;o=l-i.startSN,n=i.fragments,r=n[o],isNaN(r.startPTS)||(a=Math.min(a,r.startPTS),s=Math.max(s,r.endPTS));var u=a-r.start;for(r.start=r.startPTS=a,r.endPTS=s,r.duration=s-a,t=o;t>0;t--)e.updatePTS(n,t,t-1);for(t=o;t<n.length-1;t++)e.updatePTS(n,t,t+1);return i.PTSKnown=!0,u}},{key:"updatePTS",value:function(s,i,a){var e=s[i],r=s[a],n=r.startPTS;isNaN(n)?a>i?r.start=e.start+e.duration:r.start=e.start-r.duration:a>i?(e.duration=n-e.start,e.duration<0&&t.logger.error("negative duration computed for frag "+e.sn+",level "+e.level+", there should be some duration drift between playlist and fragment!")):(r.duration=e.start-n,r.duration<0&&t.logger.error("negative duration computed for frag "+r.sn+",level "+r.level+", there should be some duration drift between playlist and fragment!"))}}]),e}();e.default=s,i.exports=e.default},{"../utils/logger":29}],21:[function(t,c,a){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(a,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),E=t("./events"),i=r(E),s=t("./errors"),u=t("./loader/playlist-loader"),d=r(u),h=t("./loader/fragment-loader"),f=r(h),S=t("./controller/abr-controller"),v=r(S),g=t("./controller/mse-media-controller"),p=r(g),y=t("./controller/level-controller"),m=r(y),e=t("./utils/logger"),b=t("./utils/xhr-loader"),_=r(b),R=t("events"),L=r(R),A=t("./loader/key-loader"),T=r(A),l=function(){function t(){var i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];o(this,t);var n=t.DefaultConfig;for(var a in n)a in i||(i[a]=n[a]);if(void 0!==i.liveMaxLatencyDurationCount&&i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');(0,e.enableLogs)(i.debug),this.config=i;var r=this.observer=new L.default;r.trigger=function(i){for(var t=arguments.length,a=Array(t>1?t-1:0),e=1;t>e;e++)a[e-1]=arguments[e];r.emit.apply(r,[i,i].concat(a))},r.off=function(a){for(var t=arguments.length,i=Array(t>1?t-1:0),e=1;t>e;e++)i[e-1]=arguments[e];r.removeListener.apply(r,[a].concat(i))},this.on=r.on.bind(r),this.off=r.off.bind(r),this.trigger=r.trigger.bind(r),this.playlistLoader=new d.default(this),this.fragmentLoader=new f.default(this),this.levelController=new m.default(this),this.abrController=new i.abrController(this),this.mediaController=new i.mediaController(this),this.keyLoader=new T.default(this)}return n(t,null,[{key:"isSupported",value:function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"Events",get:function(){return i.default}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig||(t.defaultConfig={autoStartLoad:!0,debug:!1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.3,maxSeekHole:2,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingLoopThreshold:3,appendErrorMaxRetry:3,loader:_.default,fLoader:void 0,pLoader:void 0,abrController:v.default,mediaController:p.default}),t.defaultConfig},set:function(e){t.defaultConfig=e}}]),n(t,[{key:"destroy",value:function(){e.logger.log("destroy"),this.trigger(i.default.DESTROYING),this.detachMedia(),this.playlistLoader.destroy(),this.fragmentLoader.destroy(),this.levelController.destroy(),this.mediaController.destroy(),this.keyLoader.destroy(),this.url=null,this.observer.removeAllListeners()}},{key:"attachMedia",value:function(t){e.logger.log("attachMedia"),this.media=t,this.trigger(i.default.MEDIA_ATTACHING,{media:t})}},{key:"detachMedia",value:function(){e.logger.log("detachMedia"),this.trigger(i.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(t){e.logger.log("loadSource:"+t),this.url=t,this.trigger(i.default.MANIFEST_LOADING,{url:t})}},{key:"startLoad",value:function(){e.logger.log("startLoad"),this.mediaController.startLoad()}},{key:"swapAudioCodec",value:function(){e.logger.log("swapAudioCodec"),this.mediaController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){e.logger.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.mediaController.currentLevel},set:function(t){e.logger.log("set currentLevel:"+t),this.loadLevel=t,this.mediaController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.mediaController.nextLevel},set:function(t){e.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.mediaController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){e.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel()},set:function(e){this.levelController.level=e}},{key:"firstLevel",get:function(){return this.levelController.firstLevel},set:function(t){e.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){e.logger.log("set startLevel:"+t),this.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this.abrController.autoLevelCapping},set:function(t){e.logger.log("set autoLevelCapping:"+t),this.abrController.autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}}]),t}();a.default=l,c.exports=a.default},{"./controller/abr-controller":3,"./controller/level-controller":4,"./controller/mse-media-controller":5,"./errors":17,"./events":19,"./loader/fragment-loader":22,"./loader/key-loader":23,"./loader/playlist-loader":24,"./utils/logger":29,"./utils/xhr-loader":31,events:1}],22:[function(r,o,i){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),c=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},l=r("../events"),e=a(l),d=r("../event-handler"),n=a(d),t=r("../errors"),u=function(i){function r(t){h(this,r),c(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,t,e.default.FRAG_LOADING)}return f(r,i),s(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),n.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(r){var t=r.frag;this.frag=t,this.frag.loaded=0;var e=this.hls.config;t.loader=this.loader="undefined"!=typeof e.fLoader?new e.fLoader(e):new e.loader(e),this.loader.load(t.url,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),e.fragLoadingTimeOut,1,0,this.loadprogress.bind(this),t)}},{key:"loadsuccess",value:function(i,t){var r=i.currentTarget.response;t.length=r.byteLength,this.frag.loader=void 0,this.hls.trigger(e.default.FRAG_LOADED,{payload:r,frag:this.frag,stats:t})}},{key:"loaderror",value:function(r){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(r,t){this.frag.loaded=t.loaded,this.hls.trigger(e.default.FRAG_LOAD_PROGRESS,{frag:this.frag,stats:t})}}]),r}(n.default);i.default=u,o.exports=i.default},{"../errors":17,"../event-handler":18,"../events":19}],23:[function(r,o,i){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),c=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},l=r("../events"),e=a(l),d=r("../event-handler"),n=a(d),t=r("../errors"),u=function(i){function r(t){h(this,r),c(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,t,e.default.KEY_LOADING),this.decryptkey=null,this.decrypturl=null}return f(r,i),s(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),n.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(n){var t=this.frag=n.frag,a=t.decryptdata,i=a.uri;if(i!==this.decrypturl||null===this.decryptkey){var r=this.hls.config;t.loader=this.loader=new r.loader(r),this.decrypturl=i,this.decryptkey=null,t.loader.load(i,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r.fragLoadingTimeOut,r.fragLoadingMaxRetry,r.fragLoadingRetryDelay,this.loadprogress.bind(this),t)}else this.decryptkey&&(a.key=this.decryptkey,this.hls.trigger(e.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(r){var t=this.frag;this.decryptkey=t.decryptdata.key=new Uint8Array(r.currentTarget.response),t.loader=void 0,this.hls.trigger(e.default.KEY_LOADED,{frag:t})}},{key:"loaderror",value:function(r){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(){}}]),r}(n.default);i.default=u,o.exports=i.default},{"../errors":17,"../event-handler":18,"../events":19}],24:[function(r,u,a){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(a,"__esModule",{value:!0});var p=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),o=function(n,s,o){for(var r=!0;r;){var t=n,l=s,u=o;e=a=i=void 0,r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,l);if(void 0!==e){if("value"in e)return e.value;var i=e.get;return void 0===i?void 0:i.call(u)}var a=Object.getPrototypeOf(t);if(null===a)return void 0;n=a,s=l,o=u,r=!0}},l=r("../events"),t=i(l),y=r("../event-handler"),n=i(y),e=r("../errors"),c=r("../utils/url"),v=i(c),g=r("../utils/attr-list"),s=i(g),h=function(i){function r(e){d(this,r),o(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,e,t.default.MANIFEST_LOADING,t.default.LEVEL_LOADING)}return f(r,i),p(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),this.url=this.id=null,n.default.prototype.destroy.call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,null)}},{key:"onLevelLoading",value:function(e){this.load(e.url,e.level,e.id)}},{key:"load",value:function(a,n,s){var t,r,i,e=this.hls.config;this.url=a,this.id=n,this.id2=s,void 0===this.id?(t=e.manifestLoadingMaxRetry,r=e.manifestLoadingTimeOut,i=e.manifestLoadingRetryDelay):(t=e.levelLoadingMaxRetry,r=e.levelLoadingTimeOut,i=e.levelLoadingRetryDelay),this.loader="undefined"!=typeof e.pLoader?new e.pLoader(e):new e.loader(e),this.loader.load(a,"",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r,t,i)}},{key:"resolve",value:function(e,t){return v.default.buildAbsoluteURL(t,e)}},{key:"parseMasterPlaylist",value:function(h,u){for(var l=[],i=void 0,d=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g;null!=(i=d.exec(h));){var e={},r=e.attrs=new s.default(i[1]);e.url=this.resolve(i[2],u);var n=r.decimalResolution("RESOLUTION");n&&(e.width=n.width,e.height=n.height),e.bitrate=r.decimalInteger("BANDWIDTH"),e.name=r.NAME;var t=r.CODECS;if(t){t=t.split(",");for(var o=0;o<t.length;o++){var a=t[o];-1!==a.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(a):e.audioCodec=a}}l.push(e)}return l}},{key:"avc1toavcoti",value:function(r){var e,t=r.split(".");return t.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){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(A,l,L){var e,b,n,a,g=0,o=0,i={url:l,fragments:[],live:!0,startSN:0},r={method:null,key:null,iv:null,uri:null},E=0,h=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(A));)switch(e.shift(),e=e.filter(function(e){return void 0!==e}),e[0]){case"MEDIA-SEQUENCE":g=i.startSN=parseInt(e[1]);break;case"TARGETDURATION":i.targetduration=parseFloat(e[1]);break;case"ENDLIST":i.live=!1;break;case"DIS":E++;break;case"BYTERANGE":var c=e[1].split("@");a=1===c.length?n:parseInt(c[1]),n=parseInt(c[0])+a,t&&!t.url&&(t.byteRangeStartOffset=a,t.byteRangeEndOffset=n,t.url=this.resolve(e[2],l));break;case"INF":var v=parseFloat(e[1]);if(!isNaN(v)){var u,m=g++;if(r.method&&r.uri&&!r.iv){u=this.cloneObj(r);for(var y=new Uint8Array(16),d=12;16>d;d++)y[d]=m>>8*(15-d)&255;u.iv=y}else u=r;var T=e[2]?this.resolve(e[2],l):null;t={url:T,duration:v,start:o,sn:m,level:L,cc:E,byteRangeStartOffset:a,byteRangeEndOffset:n,decryptdata:u,programDateTime:h},i.fragments.push(t),o+=v,a=null,h=null}break;case"KEY":var R=e[1],p=new s.default(R),f=p.enumeratedString("METHOD"),_=p.URI,S=p.hexadecimalInteger("IV");f&&(r={method:null,key:null,iv:null,uri:null},_&&"AES-128"===f&&(r.method=f,r.uri=this.resolve(_,l),r.key=null,r.iv=S));break;case"PROGRAM-DATE-TIME":h=new Date(Date.parse(e[1]))}return t&&!t.url&&(i.fragments.pop(),o-=t.duration),i.totalduration=o,i.endSN=g-1,i}},{key:"loadsuccess",value:function(u,i){var s,o=u.currentTarget,n=o.responseText,r=o.responseURL,l=this.id,d=this.id2,a=this.hls;if(void 0===r&&(r=this.url),i.tload=performance.now(),i.mtime=new Date(o.getResponseHeader("Last-Modified")),0===n.indexOf("#EXTM3U"))if(n.indexOf("#EXTINF:")>0)if(null===this.id)a.trigger(t.default.MANIFEST_LOADED,{levels:[{url:r}],url:r,stats:i});else{var h=this.parseLevelPlaylist(n,r,l);i.tparsed=performance.now(),a.trigger(t.default.LEVEL_LOADED,{details:h,level:l,id:d,stats:i})}else s=this.parseMasterPlaylist(n,r),s.length?a.trigger(t.default.MANIFEST_LOADED,{levels:s,url:r,stats:i}):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"});else a.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){var r,i;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0):(r=e.ErrorDetails.LEVEL_LOAD_ERROR,i=!1),this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:this.url,loader:this.loader,response:a.currentTarget,level:this.id,id:this.id2})}},{key:"loadtimeout",value:function(){var r,i;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_TIMEOUT,i=!0):(r=e.ErrorDetails.LEVEL_LOAD_TIMEOUT,i=!1),this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:this.url,loader:this.loader,level:this.id,id:this.id2})}}]),r}(n.default);a.default=h,u.exports=a.default},{"../errors":17,"../event-handler":18,"../events":19,"../utils/attr-list":27,"../utils/url":30}],25:[function(n,t,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"init",value:function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t;for(t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),a=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:i,audio:a};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=s,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var r=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,r,l,r,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))}},{key:"box",value:function(a){for(var t,i=Array.prototype.slice.call(arguments,1),e=8,r=i.length,n=r;r--;)e+=i[r].byteLength;for(t=new Uint8Array(e),t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t.set(a,4),r=0,e=8;n>r;r++)t.set(i[r],e),e+=i[r].byteLength;return t}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,t>>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,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))}},{key:"mvex",value:function(r){for(var t=r.length,i=[];t--;)i[t]=e.trex(r[t]);return e.box.apply(null,[e.types.mvex].concat(i))}},{key:"mvhd",value:function(t,r){var i=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,i)}},{key:"sdtp",value:function(n){var r,t,i=n.samples||[],a=new Uint8Array(4+i.length);for(t=0;t<i.length;t++)r=i[t].flags,a[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,a)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,a,n,i=[],s=[];for(r=0;r<t.sps.length;r++)a=t.sps[r],n=a.byteLength,i.push(n>>>8&255),i.push(255&n),i=i.concat(Array.prototype.slice.call(a));for(r=0;r<t.pps.length;r++)a=t.pps[r],n=a.byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(a));var u=e.box(e.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(s))),o=t.width,l=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,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.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,i=t.duration,a=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,i>>24,i>>16&255,i>>8&255,255&i,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,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))}},{key:"traf",value:function(i,t){var a=e.sdtp(i),r=i.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t])),e.trun(i,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(r){var t=r.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(f,o){var i,a,n,s,t,l,d=f.samples||[],r=d.length,h=12+16*r,u=new Uint8Array(h);for(o+=8+h,u.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o],0),i=0;r>i;i++)a=d[i],n=a.duration,s=a.size,t=a.flags,l=a.cts,u.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,61440&t.degradPrio,15&t.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,u)}},{key:"initSegment",value:function(i){e.types||e.init();var t,r=e.moov(i);return t=new Uint8Array(e.FTYP.byteLength+r.byteLength),t.set(e.FTYP),t.set(r,e.FTYP.byteLength),t}}]),e}();e.default=a,t.exports=e.default},{}],26:[function(i,h,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(a,"__esModule",{value:!0});var d=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),f=i("../events"),e=n(f),t=i("../utils/logger"),u=i("../remux/mp4-generator"),r=n(u),s=i("../errors"),o=function(){function i(e){l(this,i),this.observer=e,this.ISGenerated=!1,this.PES2MP4SCALEFACTOR=4,this.PES_TIMESCALE=9e4,this.MP4_TIMESCALE=this.PES_TIMESCALE/this.PES2MP4SCALEFACTOR}return d(i,[{key:"destroy",value:function(){}},{key:"insertDiscontinuity",value:function(){this._initPTS=this._initDTS=this.nextAacPts=this.nextAvcDts=void 0}},{key:"switchLevel",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(r,i,a,t,n){this.ISGenerated||this.generateIS(r,i,t),i.samples.length&&this.remuxVideo(i,t,n),r.samples.length&&this.remuxAudio(r,t,n),a.samples.length&&this.remuxID3(a,t),this.observer.trigger(e.default.FRAG_PARSED)}},{key:"generateIS",value:function(i,t,a){var u=this.observer,o=i.samples,l=t.samples,d=o.length,h=l.length,n=this.PES_TIMESCALE;0===d&&0===h?u.trigger(e.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"}):0===h?(i.config&&(u.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,{audioMoov:r.default.initSegment([i]),audioCodec:i.codec,audioChannelCount:i.channelCount}),this.ISGenerated=!0),void 0===this._initPTS&&(this._initPTS=o[0].pts-n*a,this._initDTS=o[0].dts-n*a)):0===d?t.sps&&t.pps&&(u.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,{videoMoov:r.default.initSegment([t]),videoCodec:t.codec,videoWidth:t.width,videoHeight:t.height}),this.ISGenerated=!0,void 0===this._initPTS&&(this._initPTS=l[0].pts-n*a,this._initDTS=l[0].dts-n*a)):i.config&&t.sps&&t.pps&&(u.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,{audioMoov:r.default.initSegment([i]),audioCodec:i.codec,audioChannelCount:i.channelCount,videoMoov:r.default.initSegment([t]),videoCodec:t.codec,videoWidth:t.width,videoHeight:t.height}),this.ISGenerated=!0,void 0===this._initPTS&&(this._initPTS=Math.min(l[0].pts,o[0].pts)-n*a,this._initDTS=Math.min(l[0].dts,o[0].dts)-n*a))}},{key:"remuxVideo",value:function(a,w,k){var A,l,g,L,v,d,S,T,R,f,_,c,o,i,s,p=8,E=this.PES_TIMESCALE,h=this.PES2MP4SCALEFACTOR,u=[];for(d=new Uint8Array(a.len+4*a.nbNalu+8),
-A=new DataView(d.buffer),A.setUint32(0,d.byteLength),d.set(r.default.types.mdat,4);a.samples.length;){for(l=a.samples.shift(),L=0;l.units.units.length;)v=l.units.units.shift(),A.setUint32(p,v.data.byteLength),p+=4,d.set(v.data,p),p+=v.data.byteLength,L+=4+v.data.byteLength;if(_=l.pts-this._initDTS,c=l.dts-this._initDTS,c=Math.min(_,c),void 0!==f){o=this._PTSNormalize(_,f),i=this._PTSNormalize(c,f);var y=(i-f)/h;0>=y&&(t.logger.log("invalid sample duration at PTS/DTS: "+l.pts+"/"+l.dts+":"+y),y=1),g.duration=y}else{var n,m=this.nextAvcDts;o=this._PTSNormalize(_,m),i=this._PTSNormalize(c,m),n=Math.round((i-m)/90),(k||Math.abs(n)<600)&&n&&(n>1?t.logger.log("AVC:"+n+" ms hole between fragments detected,filling it"):-1>n&&t.logger.log("AVC:"+-n+" ms overlapping between fragments detected"),i=m,o=Math.max(o-n,i),t.logger.log("Video/PTS/DTS adjusted: "+o+"/"+i+",delta:"+n)),T=Math.max(0,o),R=Math.max(0,i)}g={size:L,duration:0,cts:(o-i)/h,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},s=g.flags,l.key===!0?(s.dependsOn=2,s.isNonSync=0):(s.dependsOn=1,s.isNonSync=1),u.push(g),f=i}var b=0;u.length>=2&&(b=u[u.length-2].duration,g.duration=b),this.nextAvcDts=i+b*h,a.len=0,a.nbNalu=0,u.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(s=u[0].flags,s.dependsOn=2,s.isNonSync=0),a.samples=u,S=r.default.moof(a.sequenceNumber++,R/h,a),a.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{moof:S,mdat:d,startPTS:T/E,endPTS:(o+h*b)/E,startDTS:R/E,endDTS:this.nextAvcDts/E,type:"video",nb:u.length})}},{key:"remuxAudio",value:function(i,k,S){var L,f,s,d,u,R,A,_,h,l,E,o,n,T=8,c=this.PES_TIMESCALE,p=this.PES2MP4SCALEFACTOR,g=[],b=[];for(i.samples.forEach(function(e){void 0===l||e.pts>l?(b.push(e),l=e.pts):t.logger.warn("dropping past audio frame")});b.length;){if(f=b.shift(),d=f.unit,l=f.pts-this._initDTS,E=f.dts-this._initDTS,void 0!==h)o=this._PTSNormalize(l,h),n=this._PTSNormalize(E,h),s.duration=(n-h)/p,s.duration<0&&(t.logger.log("invalid AAC sample duration at PTS:"+f.pts+":"+s.duration),s.duration=0);else{var a,m=this.nextAacPts;if(o=this._PTSNormalize(l,m),n=this._PTSNormalize(E,m),a=Math.round(1e3*(o-m)/c),(S||Math.abs(a)<600)&&a){if(a>0)t.logger.log(a+" ms hole between AAC samples detected,filling it");else if(0>a){t.logger.log(-a+" ms overlapping between AAC samples detected, drop frame"),i.len-=d.byteLength;continue}o=n=m}A=Math.max(0,o),_=Math.max(0,n),u=new Uint8Array(i.len+8),L=new DataView(u.buffer),L.setUint32(0,u.byteLength),u.set(r.default.types.mdat,4)}u.set(d,T),T+=d.byteLength,s={size:d.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},g.push(s),h=n}var y=0,v=g.length;v>=2&&(y=g[v-2].duration,s.duration=y),v&&(this.nextAacPts=o+p*y,i.len=0,i.samples=g,R=r.default.moof(i.sequenceNumber++,_/p,i),i.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{moof:R,mdat:u,startPTS:A/c,endPTS:this.nextAacPts/c,startDTS:_/c,endDTS:(n+p*y)/c,type:"audio",nb:v}))}},{key:"remuxID3",value:function(r,a){var t,n=r.samples.length;if(n){for(var i=0;n>i;i++)t=r.samples[i],t.pts=(t.pts-this._initPTS)/this.PES_TIMESCALE,t.dts=(t.dts-this._initDTS)/this.PES_TIMESCALE;this.observer.trigger(e.default.FRAG_PARSING_METADATA,{samples:r.samples})}r.samples=[],a=a}},{key:"_PTSNormalize",value:function(e,t){var r;if(void 0===t)return e;for(r=e>t?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}},{key:"timescale",get:function(){return this.MP4_TIMESCALE}}]),i}();a.default=o,h.exports=a.default},{"../errors":17,"../events":19,"../remux/mp4-generator":25,"../utils/logger":29}],27:[function(n,t,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(t){r(this,e),"string"==typeof t&&(t=e.parseAttrList(t));for(var i in t)t.hasOwnProperty(i)&&(this[i]=t[i])}return i(e,[{key:"decimalInteger",value:function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"hexadecimalInteger",value:function(r){if(this[r]){var e=(this[r]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var i=new Uint8Array(e.length/2),t=0;t<e.length/2;t++)i[t]=parseInt(e.slice(2*t,2*t+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(t){var e=/^(\d+)x(\d+)$/.exec(this[t]);return null===e?void 0:{width:parseInt(e[1],10),height:parseInt(e[2],10)}}}],[{key:"parseAttrList",value:function(a){for(var t,n=/(.+?)=((?:\".*?\")|.*?)(?:,|$)/g,r={};null!==(t=n.exec(a));){var e=t[2],i='"';0===e.indexOf(i)&&e.lastIndexOf(i)===e.length-1&&(e=e.slice(1,-1)),r[t[1]]=e}return r}}]),e}();e.default=a,t.exports=e.default},{}],28:[function(r,e,i){"use strict";var t={search:function(a,s){for(var t=0,r=a.length-1,e=null,i=null;r>=t;){e=(t+r)/2|0,i=a[e];var n=s(i);if(n>0)t=e+1;else{if(!(0>n))return i;r=e-1}}return null}};e.exports=t},{}],29:[function(d,u,r){"use strict";function e(){}function l(t,e){return e="["+t+"] > "+e}function a(t){var r=window.console[t];return r?function(){for(var a=arguments.length,e=Array(a),i=0;a>i;i++)e[i]=arguments[i];e[0]&&(e[0]=l(t,e[0])),r.apply(window.console,e)}:e}function s(r){for(var i=arguments.length,n=Array(i>1?i-1:0),e=1;i>e;e++)n[e-1]=arguments[e];n.forEach(function(e){t[e]=r[e]?r[e].bind(r):a(e)})}Object.defineProperty(r,"__esModule",{value:!0});var i={trace:e,debug:e,log:e,warn:e,info:e,error:e},t=i,n=function(e){if(e===!0||"object"==typeof e){s(e,"debug","log","info","warn","error");try{t.log()}catch(e){t=i}}else t=i};r.enableLogs=n;var o=t;r.logger=o},{}],30:[function(r,t,i){"use strict";var e={buildAbsoluteURL:function(i,t){if(t=t.trim(),/^[a-z]+:/i.test(t))return t;var a=null,n=null,s=/^([^#]*)(.*)$/.exec(t);s&&(n=s[2],t=s[1]);var o=/^([^\?]*)(.*)$/.exec(t);o&&(a=o[2],t=o[1]);var u=/^([^#]*)(.*)$/.exec(i);u&&(i=u[1]);var d=/^([^\?]*)(.*)$/.exec(i);d&&(i=d[1]);var l=/^((([a-z]+):)?\/\/[a-z0-9\.-]+(:[0-9]+)?\/)(.*)$/i.exec(i),c=l[3],h=l[1],f=l[5],r=null;if(/^\/\//.test(t))r=c+"://"+e.buildAbsolutePath("",t.substring(2));else if(/^\//.test(t))r=h+e.buildAbsolutePath("",t.substring(1));else{var v=e.buildAbsolutePath(f,t);r=h+v}return a&&(r+=a),n&&(r+=n),r},buildAbsolutePath:function(n,s){for(var i,e,o=s,a="",t=n.replace(/[^\/]*$/,o.replace(/(\/|^)(?:\.?\/+)+/g,"$1")),r=0;e=t.indexOf("/../",r),e>-1;r=e+i)i=/^\/(?:\.\.\/)*/.exec(t.slice(e))[0].length,a=(a+t.substring(r,e)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(i-1)/3+"}$"),"/");return a+t.substr(r)}};t.exports=e},{}],31:[function(r,i,e){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),t=r("../utils/logger"),s=function(){function e(t){a(this,e),t&&t.xhrSetup&&(this.xhrSetup=t.xhrSetup)}return n(e,[{key:"destroy",value:function(){this.abort(),this.loader=null}},{key:"abort",value:function(){var e=this.loader,t=this.timeoutHandle;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),t&&window.clearTimeout(t)}},{key:"load",value:function(r,i,a,n,s,t,o,l){var u=arguments.length<=8||void 0===arguments[8]?null:arguments[8],e=arguments.length<=9||void 0===arguments[9]?null:arguments[9];this.url=r,!e||isNaN(e.byteRangeStartOffset)||isNaN(e.byteRangeEndOffset)||(this.byteRange=e.byteRangeStartOffset+"-"+(e.byteRangeEndOffset-1)),this.responseType=i,this.onSuccess=a,this.onProgress=u,this.onTimeout=s,this.onError=n,this.stats={trequest:performance.now(),retry:0},this.timeout=t,this.maxRetry=o,this.retryDelay=l,this.timeoutHandle=window.setTimeout(this.loadtimeout.bind(this),t),this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.loader=new XMLHttpRequest;e.onloadend=this.loadend.bind(this),e.onprogress=this.loadprogress.bind(this),e.open("GET",this.url,!0),this.byteRange&&e.setRequestHeader("Range","bytes="+this.byteRange),e.responseType=this.responseType,this.stats.tfirst=null,this.stats.loaded=0,this.xhrSetup&&this.xhrSetup(e,this.url),e.send()}},{key:"loadend",value:function(i){var a=i.currentTarget,r=a.status,e=this.stats;e.aborted||(r>=200&&300>r?(window.clearTimeout(this.timeoutHandle),e.tload=performance.now(),this.onSuccess(i,e)):e.retry<this.maxRetry?(t.logger.warn(r+" while loading "+this.url+", retrying in "+this.retryDelay+"..."),this.destroy(),window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,64e3),e.retry++):(window.clearTimeout(this.timeoutHandle),t.logger.error(r+" while loading "+this.url),this.onError(i)))}},{key:"loadtimeout",value:function(e){t.logger.warn("timeout while loading "+this.url),this.onTimeout(e,this.stats)}},{key:"loadprogress",value:function(t){var e=this.stats;null===e.tfirst&&(e.tfirst=performance.now()),e.loaded=t.loaded,this.onProgress&&this.onProgress(t,e)}}]),e}();e.default=s,i.exports=e.default},{"../utils/logger":29}]},{},[21])(21)});
+!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 s(e,t,r){function n(a,d){if(!t[a]){if(!e[a]){var l="function"==typeof require&&require;if(!d&&l)return l(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var o=t[a]={exports:{}};e[a][0].call(o.exports,function(t){var r=e[a][1][t];return n(r?r:t)},o,o.exports,s,e,t,r)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)n(r[a]);return n}({1:[function(s,a,o){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function t(e){return"function"==typeof e}function i(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function n(e){return void 0===e}a.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},e.prototype.emit=function(l){var s,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],s instanceof Error)throw s;throw TypeError('Uncaught, unspecified "error" event.')}if(e=this._events[l],n(e))return!1;if(t(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),e.apply(this,a)}else if(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){var s;if(!t(i))throw TypeError("listener must be a function");return this._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"==typeof console.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(n,e){function r(){this.removeListener(n,r),a||(a=!0,e.apply(this,arguments))}if(!t(e))throw TypeError("listener must be a function");var a=!1;return r.listener=e,this.on(n,r),this},e.prototype.removeListener=function(a,n){var e,s,o,i;if(!t(n))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(e=this._events[a],o=e.length,s=-1,e===n||t(e.listener)&&e.listener===n)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,n);else if(r(e)){for(i=o;i-- >0;)if(e[i]===n||e[i].listener&&e[i].listener===n){s=i;break}if(0>s)return this;1===e.length?(e.length=0,delete this._events[a]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",a,n)}return this},e.prototype.removeAllListeners=function(r){var n,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[r]&&delete this._events[r],this;if(0===arguments.length){for(n in this._events)"removeListener"!==n&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[r],t(e))this.removeListener(r,e);else if(e)for(;e.length;)this.removeListener(r,e[e.length-1]);return delete this._events[r],this},e.prototype.listeners=function(e){var r;return r=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.prototype.listenerCount=function(r){if(this._events){var e=this._events[r];if(t(e))return 1;if(e)return e.length}return 0},e.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(i,n,s){var a=arguments[3],e=arguments[4],r=arguments[5],t=JSON.stringify;n.exports=function(l){for(var n,s=Object.keys(r),i=0,d=s.length;d>i;i++){var o=s[i],u=r[o].exports;if(u===l||u.default===l){n=o;break}}if(!n){n=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var f={},i=0,d=s.length;d>i;i++){var o=s[i];f[o]=o}e[n]=[Function(["require","module","exports"],"("+l+")(self)"),f]}var h=Math.floor(Math.pow(16,8)*Math.random()).toString(16),c={};c[n]=n,e[h]=[Function(["require"],"var f = require("+t(n)+");(f.default ? f.default : f)(self);"),c];var g="("+a+")({"+Object.keys(e).map(function(r){return t(r)+":["+e[r][0]+","+t(e[r][1])+"]"}).join(",")+"},{},["+t(h)+"])",v=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(v.createObjectURL(new Blob([g],{type:"text/javascript"})))}},{}],3:[function(e,h,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=e("../events"),u=r(l),d=e("../event-handler"),n=r(d),s=function(t){function e(r){a(this,e);var t=i(this,Object.getPrototypeOf(e).call(this,r,u.default.FRAG_LOAD_PROGRESS));return t.lastfetchlevel=0,t._autoLevelCapping=-1,t._nextAutoLevel=-1,t}return f(e,t),o(e,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onFragLoadProgress",value:function(e){var t=e.stats;void 0===t.aborted&&1===e.frag.loadCounter&&(this.lastfetchduration=(performance.now()-t.trequest)/1e3,this.lastfetchlevel=e.frag.level,this.lastbw=8*t.loaded/this.lastfetchduration)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping=e}},{key:"nextAutoLevel",get:function(){var r,e,t,n=this.lastbw,a=this.hls;if(t=-1===this._autoLevelCapping?a.levels.length-1:this._autoLevelCapping,-1!==this._nextAutoLevel){var i=Math.min(this._nextAutoLevel,t);if(i!==this.lastfetchlevel)return i;this._nextAutoLevel=-1}for(e=0;t>=e;e++)if(r=e<=this.lastfetchlevel?.8*n:.7*n,r<a.levels[e].bitrate)return Math.max(0,e-1);return e-1},set:function(e){this._nextAutoLevel=e}}]),e}(n.default);t.default=s},{"../event-handler":20,"../events":21}],4:[function(n,g,a){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var c=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});var l=n("../events"),e=i(l),d=n("../event-handler"),s=i(d),t=n("../utils/logger"),r=n("../errors"),o=function(a){function n(r){u(this,n);var t=f(this,Object.getPrototypeOf(n).call(this,r,e.default.MEDIA_ATTACHING,e.default.MEDIA_DETACHING,e.default.BUFFER_RESET,e.default.BUFFER_APPENDING,e.default.BUFFER_CODECS,e.default.BUFFER_EOS,e.default.BUFFER_FLUSHING));return t.onsbue=t.onSBUpdateEnd.bind(t),t.onsbe=t.onSBUpdateError.bind(t),t}return h(n,a),c(n,[{key:"destroy",value:function(){s.default.prototype.destroy.call(this)}},{key:"onMediaAttaching",value:function(t){var r=this.media=t.media,e=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),e.addEventListener("sourceopen",this.onmso),e.addEventListener("sourceended",this.onmse),e.addEventListener("sourceclose",this.onmsc),r.src=URL.createObjectURL(e)}},{key:"onMediaDetaching",value:function(){var r=this.mediaSource;if(r){if("open"===r.readyState)try{r.endOfStream()}catch(e){t.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}r.removeEventListener("sourceopen",this.onmso),r.removeEventListener("sourceended",this.onmse),r.removeEventListener("sourceclose",this.onmsc),this.media.src="",this.mediaSource=null,this.media=null,this.pendingTracks=null}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(e.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){t.logger.log("media source opened"),this.hls.trigger(e.default.MEDIA_ATTACHED,{media:this.media}),this.mediaSource.removeEventListener("sourceopen",this.onmso);var r=this.pendingTracks;r&&(this.onBufferCodecs(r),this.pendingTracks=null,this.doAppending())}},{key:"onMediaSourceClose",value:function(){t.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){t.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){this._needsFlush&&this.doFlush(),this._needsEos&&this.onBufferEos(),this.hls.trigger(e.default.BUFFER_APPENDED),this.doAppending()}},{key:"onSBUpdateError",value:function(n){t.logger.error("sourceBuffer error:"+n),this.hls.trigger(e.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferReset",value:function(){var e=this.sourceBuffer;if(e){for(var r in e){var t=e[r];try{this.mediaSource.removeSourceBuffer(t),t.removeEventListener("updateend",this.onsbue),t.removeEventListener("error",this.onsbe)}catch(e){}}this.sourceBuffer=null}this.flushRange=[],this.appended=0}},{key:"onBufferCodecs",value:function(r){var n,a,e,s,i;if(!this.media)return void(this.pendingTracks=r);if(!this.sourceBuffer){var o={},l=this.mediaSource;for(a in r)e=r[a],s=e.levelCodec||e.codec,i=e.container+";codecs="+s,t.logger.log("creating sourceBuffer with mimeType:"+i),n=o[a]=l.addSourceBuffer(i),n.addEventListener("updateend",this.onsbue),n.addEventListener("error",this.onsbe);this.sourceBuffer=o}}},{key:"onBufferAppending",value:function(e){this.segments?this.segments.push(e):this.segments=[e],this.doAppending()}},{key:"onBufferAppendFail",value:function(n){t.logger.error("sourceBuffer error:"+n.event),this.hls.trigger(e.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1,frag:this.fragCurrent})}},{key:"onBufferEos",value:function(){var e=this.sourceBuffer,r=this.mediaSource;r&&"open"===r.readyState&&(e.audio&&e.audio.updating||e.video&&e.video.updating?this._needsEos=!0:(t.logger.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment"),r.endOfStream(),this._needsEos=!1))}},{key:"onBufferFlushing",value:function(e){this.flushRange.push({start:e.startOffset,end:e.endOffset}),this.flushBufferCounter=0,this.doFlush()}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var r=this.flushRange[0];if(!this.flushBuffer(r.start,r.end))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var n=0,t=this.sourceBuffer;if(t)for(var a in t)n+=t[a].buffered.length;this.appended=n,this.hls.trigger(e.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var i=this.hls,s=this.sourceBuffer,a=this.segments;if(s){if(this.media.error)return a=[],void t.logger.error("trying to append although a media error occured, flush segment and abort");for(var l in s)if(s[l].updating)return;if(a.length){var o=a.shift();try{s[o.type].appendBuffer(o.data),this.appendError=0,this.appended++}catch(s){t.logger.error("error while trying to append buffer:"+s.message),a.unshift(o);var n={type:r.ErrorTypes.MEDIA_ERROR};if(22!==s.code){if(this.appendError?this.appendError++:this.appendError=1,n.details=r.ErrorDetails.BUFFER_APPEND_ERROR,n.frag=this.fragCurrent,this.appendError>i.config.appendErrorMaxRetry)return t.logger.log("fail "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),a=[],n.fatal=!0,void i.trigger(e.default.ERROR,n);n.fatal=!1,i.trigger(e.default.ERROR,n)}else a=[],n.details=r.ErrorDetails.BUFFER_FULL,i.trigger(e.default.ERROR,n)}}}}},{key:"flushBuffer",value:function(l,s){var e,r,o,i,n,a;if(this.flushBufferCounter<this.appended&&this.sourceBuffer)for(var u in this.sourceBuffer){if(e=this.sourceBuffer[u],e.updating)return t.logger.warn("cannot flush, sb updating in progress"),!1;for(r=0;r<e.buffered.length;r++)if(o=e.buffered.start(r),i=e.buffered.end(r),-1!==navigator.userAgent.toLowerCase().indexOf("firefox")&&s===Number.POSITIVE_INFINITY?(n=l,a=s):(n=Math.max(o,l),a=Math.min(i,s)),Math.min(a,i)-n>.5)return this.flushBufferCounter++,t.logger.log("flush "+u+" ["+n+","+a+"], of ["+o+","+i+"], pos:"+this.media.currentTime),e.remove(n,a),!1}else t.logger.warn("abort flushing too many retries");return t.logger.log("buffer flushed"),!0}}]),n}(s.default);a.default=o},{"../errors":19,"../event-handler":20,"../events":21,"../utils/logger":34}],5:[function(n,g,a){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var c=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});var l=n("../events"),t=i(l),d=n("../event-handler"),f=i(d),r=n("../utils/logger"),e=n("../errors"),o=function(a){function n(r){u(this,n);var e=h(this,Object.getPrototypeOf(n).call(this,r,t.default.MANIFEST_LOADED,t.default.LEVEL_LOADED,t.default.ERROR));return e.ontick=e.tick.bind(e),e._manualLevel=e._autoLevelCapping=-1,e}return s(n,a),c(n,[{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this._manualLevel=-1}},{key:"onManifestLoaded",value:function(l){var s,a,i=[],n=[],u={},d=!1,f=!1,o=this.hls;if(l.levels.forEach(function(e){e.videoCodec&&(d=!0),e.audioCodec&&(f=!0);var t=u[e.bitrate];void 0===t?(u[e.bitrate]=i.length,e.url=[e.url],e.urlId=0,i.push(e)):i[t].url.push(e.url)}),d&&f?i.forEach(function(e){e.videoCodec&&n.push(e)}):n=i,n=n.filter(function(e){var n=function(e){return MediaSource.isTypeSupported("audio/mp4;codecs="+e)},a=function(e){return MediaSource.isTypeSupported("video/mp4;codecs="+e)},t=e.audioCodec,r=e.videoCodec;return(!t||n(t))&&(!r||a(r))}),n.length){for(s=n[0].bitrate,n.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=n,a=0;a<n.length;a++)if(n[a].bitrate===s){this._firstLevel=a,r.logger.log("manifest loaded,"+n.length+" level(s) found, first bitrate:"+s);break}o.trigger(t.default.MANIFEST_PARSED,{levels:this._levels,firstLevel:this._firstLevel,stats:l.stats})}else o.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:o.url,reason:"no compatible level found in manifest"})}},{key:"setLevelInternal",value:function(n){if(n>=0&&n<this._levels.length){this.timer&&(clearInterval(this.timer),this.timer=null),this._level=n,r.logger.log("switching to level "+n),this.hls.trigger(t.default.LEVEL_SWITCH,{level:n});var a=this._levels[n];if(void 0===a.details||a.details.live===!0){r.logger.log("(re)loading playlist for level "+n);var i=a.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:a.url[i],level:n,id:i})}}else this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.LEVEL_SWITCH_ERROR,level:n,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(a){if(!a.fatal){var i,t,n=a.details,s=this.hls;switch(n){case e.ErrorDetails.FRAG_LOAD_ERROR:case e.ErrorDetails.FRAG_LOAD_TIMEOUT:case e.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case e.ErrorDetails.KEY_LOAD_ERROR:case e.ErrorDetails.KEY_LOAD_TIMEOUT:i=a.frag.level;break;case e.ErrorDetails.LEVEL_LOAD_ERROR:case e.ErrorDetails.LEVEL_LOAD_TIMEOUT:i=a.level}if(void 0!==i)if(t=this._levels[i],t.urlId<t.url.length-1)t.urlId++,t.details=void 0,r.logger.warn("level controller,"+n+" for level "+i+": switching to redundant stream id "+t.urlId);else{var o=-1===this._manualLevel&&i;o?(r.logger.warn("level controller,"+n+": emergency switch-down for next fragment"),s.abrController.nextAutoLevel=0):t&&t.details&&t.details.live?r.logger.warn("level controller,"+n+" on live stream, discard"):n!==e.ErrorDetails.FRAG_LOAD_ERROR&&n!==e.ErrorDetails.FRAG_LOAD_TIMEOUT&&(r.logger.error("cannot recover "+n+" error"),this._level=void 0,this.timer&&(clearInterval(this.timer),this.timer=null),a.fatal=!0,s.trigger(event,a))}}}},{key:"onLevelLoaded",value:function(e){e.details.live&&!this.timer&&(this.timer=setInterval(this.ontick,1e3*e.details.targetduration)),!e.details.live&&this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"tick",value:function(){var e=this._level;if(void 0!==e){var r=this._levels[e],n=r.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:r.url[n],level:e,id:n})}}},{key:"nextLoadLevel",value:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.abrController.nextAutoLevel}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this._level},set:function(e){(this._level!==e||void 0===this._levels[e].details)&&this.setLevelInternal(e)}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,-1!==e&&(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}}]),n}(f.default);a.default=o},{"../errors":19,"../event-handler":20,"../events":21,"../utils/logger":34}],6:[function(a,_,o){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var m=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(o,"__esModule",{value:!0});var b=a("../demux/demuxer"),u=i(b),d=a("../events"),r=i(d),h=a("../event-handler"),s=i(h),t=a("../utils/logger"),v=a("../utils/binary-search"),p=i(v),y=a("../helper/level-helper"),l=i(y),n=a("../errors"),e={ERROR:"ERROR",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_LEVEL:"WAITING_LEVEL",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED"},E=function(i){function a(t){g(this,a);var e=f(this,Object.getPrototypeOf(a).call(this,t,r.default.MEDIA_ATTACHED,r.default.MEDIA_DETACHING,r.default.MANIFEST_PARSED,r.default.LEVEL_LOADED,r.default.KEY_LOADED,r.default.FRAG_LOADED,r.default.FRAG_PARSING_INIT_SEGMENT,r.default.FRAG_PARSING_DATA,r.default.FRAG_PARSED,r.default.ERROR,r.default.BUFFER_APPENDED,r.default.BUFFER_FLUSHED));return e.config=t.config,e.audioCodecSwap=!1,e.ticks=0,e.ontick=e.tick.bind(e),e}return c(a,i),m(a,[{key:"destroy",value:function(){this.stop(),s.default.prototype.destroy.call(this),this.state=e.IDLE}},{key:"startLoad",value:function(){if(this.levels){var r=this.media,n=this.lastCurrentTime;this.stop(),this.demuxer=new u.default(this.hls),this.timer=setInterval(this.ontick,100),this.level=-1,this.fragLoadError=0,r&&n?(t.logger.log("configure startPosition @"+n),this.lastPaused||(t.logger.log("resuming video"),r.play()),this.state=e.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:0,this.state=e.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else t.logger.warn("cannot start loading as manifest not parsed yet")}},{key:"stop",value:function(){this.bufferRange=[],this.stalled=!1;var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,t.logger.log("trigger BUFFER_RESET"),this.hls.trigger(r.default.BUFFER_RESET),this.timer&&(clearInterval(this.timer),this.timer=null),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null)}},{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 h,o,i,l=this.hls,u=l.config;switch(this.state){case e.ERROR:case e.PAUSED:break;case e.STARTING:this.startLevel=l.startLevel,-1===this.startLevel&&(this.startLevel=0,this.fragBitrateTest=!0),this.level=l.nextLoadLevel=this.startLevel,this.state=e.WAITING_LEVEL,this.loadedmetadata=!1;break;case e.IDLE:if(!this.media&&(this.startFragRequested||!u.startFragPrefetch))break;h=this.loadedmetadata?this.media.currentTime:this.nextLoadPosition,o=this.startFragRequested===!1?this.startLevel:l.nextLoadLevel;var c,S=this.bufferInfo(h,u.maxBufferHole),x=S.len,f=S.end,g=this.fragPrevious;if(this.levels[o].hasOwnProperty("bitrate")?(c=Math.max(8*u.maxBufferSize/this.levels[o].bitrate,u.maxBufferLength),c=Math.min(c,u.maxMaxBufferLength)):c=u.maxBufferLength,c>x){if(l.nextLoadLevel=o,this.level=o,i=this.levels[o].details,"undefined"==typeof i||i.live&&this.levelLastLoaded!==o){this.state=e.WAITING_LEVEL;break}var d=i.fragments,v=d.length,y=d[0].start,L=d[v-1].start+d[v-1].duration,a=void 0;if(i.live){if(f<Math.max(y,L-u.liveMaxLatencyDurationCount*i.targetduration)&&(this.seekAfterBuffered=y+Math.max(0,i.totalduration-u.liveSyncDurationCount*i.targetduration),t.logger.log("buffer end: "+f+" is located too far from the end of live sliding playlist, media position will be reseted to: "+this.seekAfterBuffered.toFixed(3)),f=this.seekAfterBuffered),this.startFragRequested&&!i.PTSKnown){if(g){var b=g.sn+1;b>=i.startSN&&b<=i.endSN&&(a=d[b-i.startSN],t.logger.log("live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=d[Math.min(v-1,Math.round(v/2))],t.logger.log("live playlist, switching playlist, unknown, load middle frag : "+a.sn))}}else y>f&&(a=d[0]);if(!a){var m;m=L>f?p.default.search(d,function(e){return e.start+e.duration<=f?1:e.start>f?-1:0}):d[v-1],m&&(a=m,y=m.start,g&&a.level===g.level&&a.sn===g.sn&&(a.sn<i.endSN?(a=d[a.sn+1-i.startSN],t.logger.log("SN just loaded, load next one: "+a.sn)):(i.live||(this.hls.trigger(r.default.BUFFER_EOS),this.state=e.ENDED),a=null)))}if(a)if(null!=a.decryptdata.uri&&null==a.decryptdata.key)t.logger.log("Loading key for "+a.sn+" of ["+i.startSN+" ,"+i.endSN+"],level "+o),this.state=e.KEY_LOADING,l.trigger(r.default.KEY_LOADING,{frag:a});else{if(t.logger.log("Loading "+a.sn+" of ["+i.startSN+" ,"+i.endSN+"],level "+o+", currentTime:"+h+",bufferEnd:"+f.toFixed(3)),a.autoLevel=l.autoLevelEnabled,this.levels.length>1&&(a.expectedLen=Math.round(a.duration*this.levels[o].bitrate/8),a.trequest=performance.now()),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,a.loadCounter){a.loadCounter++;var w=u.fragLoadingLoopThreshold;if(a.loadCounter>w&&Math.abs(this.fragLoadIdx-a.loadIdx)<w)return void l.trigger(r.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:a})}else a.loadCounter=1;a.loadIdx=this.fragLoadIdx,this.fragCurrent=a,this.startFragRequested=!0,l.trigger(r.default.FRAG_LOADING,{frag:a}),this.state=e.FRAG_LOADING}}break;case e.WAITING_LEVEL:o=this.levels[this.level],o&&o.details&&(this.state=e.IDLE);break;case e.FRAG_LOADING:var E=this.media,s=this.fragCurrent;if(E&&(!E.paused||this.loadedmetadata===!1)&&s.autoLevel&&this.level&&this.levels.length>1){var A=performance.now()-s.trequest;if(A>500*s.duration){var T=1e3*s.loaded/A;s.expectedLen<s.loaded&&(s.expectedLen=s.loaded),h=E.currentTime;var _=(s.expectedLen-s.loaded)/T,R=this.bufferInfo(h,u.maxBufferHole).end-h,O=s.duration*this.levels[l.nextLoadLevel].bitrate/(8*T);R<2*s.duration&&_>R&&_>O&&(t.logger.warn("loading too slow, abort fragment loading"),t.logger.log("fragLoadedDelay/bufferStarvationDelay/fragLevelNextLoadedDelay :"+_.toFixed(1)+"/"+R.toFixed(1)+"/"+O.toFixed(1)),s.loader.abort(),l.trigger(r.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s}),this.state=e.IDLE)}}break;case e.FRAG_LOADING_WAITING_RETRY:var P=performance.now(),D=this.retryDate,k=this.media,I=k&&k.seeking;(!D||P>=D||I)&&(t.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=e.IDLE);break;case e.PARSING:break;case e.PARSED:break;case e.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"bufferInfo",value:function(a,i){var r=this.media;if(r){var e,t=r.buffered,n=[];for(e=0;e<t.length;e++)n.push({start:t.start(e),end:t.end(e)});return this.bufferedInfo(n,a,i)}return{len:0,start:0,end:0,nextStart:void 0}}},{key:"bufferedInfo",value:function(r,n,a){var o,l,i,h,e,t=[];for(r.sort(function(e,t){var r=e.start-t.start;return r?r:t.end-e.end}),e=0;e<r.length;e++){var u=t.length;if(u){var d=t[u-1].end;r[e].start-d<a?r[e].end>d&&(t[u-1].end=r[e].end):t.push(r[e])}else t.push(r[e])}for(e=0,o=0,l=i=n;e<t.length;e++){var s=t[e].start,f=t[e].end;if(n+a>=s&&f>n)l=s,i=f+a,o=i-n;else if(s>n+a){h=s;break}}return{len:o,start:l,end:i,nextStart:h}}},{key:"getBufferRange",value:function(r){var e,t;for(e=this.bufferRange.length-1;e>=0;e--)if(t=this.bufferRange[e],r>=t.start&&r<=t.end)return t;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(r){for(var n=this.media,t=n.buffered,e=0;e<t.length;e++)if(r>=t.start(e)&&r<=t.end(e))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var t,e,n=this.media;if(n&&n.seeking===!1&&(e=n.currentTime,e>n.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),this.isBuffered(e)?t=this.getBufferRange(e):this.isBuffered(e+.1)&&(t=this.getBufferRange(e+.1)),t)){var a=t.frag;a!==this.fragPlaying&&(this.fragPlaying=a,this.hls.trigger(r.default.FRAG_CHANGED,{frag:a}))}}},{key:"immediateLevelSwitch",value:function(){t.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,this.previouslyPaused=this.media.paused,this.media.pause());var n=this.fragCurrent;n&&n.loader&&n.loader.abort(),this.fragCurrent=null,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.tick()}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1,this.media.currentTime-=1e-4,this.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){var a,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{var o=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;var i=this.fragCurrent;i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold}}},{key:"onMediaAttached",value:function(t){var e=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.startLoad()}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var r=this.levels;r&&r.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.stop()}},{key:"onMediaSeeking",value:function(){if(this.state===e.FRAG_LOADING){if(0===this.bufferInfo(this.media.currentTime,this.config.maxBufferHole).len){t.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");var r=this.fragCurrent;r&&(r.loader&&r.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=e.IDLE}}else this.state===e.ENDED&&(this.state=e.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(){t.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(r){var e,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.startLoad()}},{key:"onLevelLoaded",value:function(s){var n=s.details,a=s.level,o=this.levels[a],u=n.totalduration,i=0;if(t.logger.log("level "+a+" loaded ["+n.startSN+","+n.endSN+"],duration:"+u),this.levelLastLoaded=a,n.live){var d=o.details;d?(l.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"))}else n.PTSKnown=!1;o.details=n,this.hls.trigger(r.default.LEVEL_UPDATED,{details:n,level:a}),this.startFragRequested===!1&&(n.live&&(this.startPosition=Math.max(0,i+u-this.config.liveSyncDurationCount*n.targetduration)),
+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){var n=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;var s=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"),void 0===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){var s,n,a=l.tracks;if(n=a.audio){var o=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){var u=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){var i={codec:"",levelCodec:""};for(s in l.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(s in a){n=a[s],t.logger.log("track:"+s+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var d=n.initSegment;d&&(this.pendingAppending++,this.hls.trigger(r.default.BUFFER_APPENDING,{type:s,data:d}))}this.tick()}}},{key:"onFragParsingData",value:function(n){var o=this;if(this.state===e.PARSING){this.tparse2=Date.now();var a=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);var u=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()}else t.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){case e.PARSING:case e.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===e.PARSED&&0===this.pendingAppending){var a=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){case n.ErrorDetails.FRAG_LOAD_ERROR:case n.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!a.fatal){var i=this.fragLoadError;if(i?i++:i=1,i<=this.config.fragLoadingMaxRetry){this.fragLoadError=i,a.frag.loadCounter=0;var s=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_RETRY}else t.logger.error("mediaController: "+a.details+" reaches max retry, redispatch as fatal ..."),a.fatal=!0,this.hls.trigger(r.default.ERROR,a),this.state=e.ERROR}break;case n.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case n.ErrorDetails.LEVEL_LOAD_ERROR:case n.ErrorDetails.LEVEL_LOAD_TIMEOUT:case n.ErrorDetails.KEY_LOAD_ERROR:case n.ErrorDetails.KEY_LOAD_TIMEOUT:t.logger.warn("mediaController: "+a.details+" while loading frag,switch to "+(a.fatal?"ERROR":"IDLE")+" state ..."),this.state=a.fatal?e.ERROR:e.IDLE;break;case n.ErrorDetails.BUFFER_FULL:this.config.maxMaxBufferLength/=2,t.logger.warn("reduce max buffer length to "+this.config.maxMaxBufferLength+"s and trigger a nextLevelSwitch to flush old buffer and fix QuotaExceededError"),this.nextLevelSwitch()}}},{key:"_checkBuffer",value:function(){var e=this.media;if(e){var d=e.readyState;if(d){var a,i,o=this.seekAfterBuffered;if(o)e.duration>=o&&(a=o,this.seekAfterBuffered=void 0);else{i=e.currentTime;var g=this.loadedmetadata;!g&&e.buffered.length&&(this.loadedmetadata=!0,i||i===this.startPosition||(a=this.startPosition))}a&&(i=a,t.logger.log("target seek position:"+a));var l=this.bufferInfo(i,0),c=!(e.paused||e.ended||e.seeking||2>d),u=.2,f=i>e.playbackRate*this.lastCurrentTime;if(this.stalled&&f&&(this.stalled=!1),l.len<=u){if(f||!c?u=0:(t.logger.log("playback seems stuck @"+i),this.stalled||(this.hls.trigger(r.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0)),l.len<=u){var s=l.nextStart,h=s-i;s&&h<this.config.maxSeekHole&&h>.005&&!e.seeking&&(t.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+s),e.currentTime=s)}}else a&&e.currentTime!==a&&(t.logger.log("adjust currentTime from "+e.currentTime+" to "+a),e.currentTime=a)}}}},{key:"onBufferFlushed",value:function(){var t,r,n=[];for(r=0;r<this.bufferRange.length;r++)t=this.bufferRange[r],this.isBuffered((t.start+t.end)/2)&&n.push(t);this.bufferRange=n,this.immediateSwitch&&this.immediateLevelSwitchEnd(),this.state=e.IDLE,this.fragPrevious=null}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"timeRangesToString",value:function(t){for(var r="",n=t.length,e=0;n>e;e++)r+="["+t.start(e)+","+t.end(e)+"]";return r}},{key:"currentLevel",get:function(){if(this.media){var e=this.getBufferRange(this.media.currentTime);if(e)return e.frag.level}return-1}},{key:"nextBufferRange",get:function(){return this.media?this.followingBufferRange(this.getBufferRange(this.media.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferRange;return e?e.frag.level:-1}}]),a}(s.default);o.default=E},{"../demux/demuxer":15,"../errors":19,"../event-handler":20,"../events":21,"../helper/level-helper":22,"../utils/binary-search":32,"../utils/logger":34}],7:[function(t,g,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var c=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(n,"__esModule",{value:!0});var l=t("../events"),e=r(l),d=t("../event-handler"),a=r(d),h=t("../utils/cea-708-interpreter"),o=r(h),u=function(r){function t(n){f(this,t);var r=i(this,Object.getPrototypeOf(t).call(this,n,e.default.MEDIA_ATTACHING,e.default.MEDIA_DETACHING,e.default.FRAG_PARSING_USERDATA,e.default.MANIFEST_LOADING,e.default.FRAG_LOADED));return r.hls=n,r.config=n.config,r.config.enableCEA708Captions&&(r.cea708Interpreter=new o.default),r}return s(t,r),c(t,[{key:"destroy",value:function(){a.default.prototype.destroy.call(this)}},{key:"onMediaAttaching",value:function(e){var t=this.media=e.media;this.cea708Interpreter.attach(t)}},{key:"onMediaDetaching",value:function(){this.cea708Interpreter.detach()}},{key:"onManifestLoading",value:function(){this.lastPts=Number.POSITIVE_INFINITY}},{key:"onFragLoaded",value:function(t){var e=t.frag.start;e<=this.lastPts&&this.cea708Interpreter.clear(),this.lastPts=e}},{key:"onFragParsingUserdata",value:function(t){for(var e=0;e<t.samples.length;e++)this.cea708Interpreter.push(t.samples[e].pts,t.samples[e].bytes)}}]),t}(a.default);n.default=u},{"../event-handler":20,"../events":21,"../utils/cea-708-interpreter":33}],8:[function(a,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(f){t(this,e),this._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],this._precompute();var n,s,r,o,l,i=this._tables[0][4],u=this._tables[1],a=f.length,d=1;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);for(o=f.slice(0),l=[],this._key=[o,l],n=a;4*a+28>n;n++)r=o[n-1],(n%a===0||8===a&&n%a===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[255&r],n%a===0&&(r=r<<8^r>>>24^d<<24,d=d<<1^283*(d>>7))),o[n]=o[n-a]^r;for(s=0;n;s++,n--)r=o[3&s?n:n-4],4>=n||4>s?l[s]=r:l[s]=u[0][i[r>>>24]]^u[1][i[r>>16&255]]^u[2][i[r>>8&255]]^u[3][i[255&r]]}return r(e,[{key:"_precompute",value:function(){var e,n,r,u,f,d,t,s,l,i=this._tables[0],o=this._tables[1],h=i[4],g=o[4],a=[],c=[];for(e=0;256>e;e++)c[(a[e]=e<<1^283*(e>>7))^e]=e;for(n=r=0;!h[n];n^=u||1,r=c[r]||1)for(t=r^r<<1^r<<2^r<<3^r<<4,t=t>>8^255&t^99,h[n]=t,g[t]=n,d=a[f=a[u=a[n]]],l=16843009*d^65537*f^257*u^16843008*n,s=257*a[t]^16843008*t,e=0;4>e;e++)i[e][n]=s=s<<24^s>>>8,o[e][t]=l=l<<24^l>>>8;for(e=0;5>e;e++)i[e]=i[e].slice(0),o[e]=o[e].slice(0)}},{key:"decrypt",value:function(R,p,_,E,b,m){var h,v,g,i,e=this._key[1],t=R^e[0],n=E^e[1],a=_^e[2],r=p^e[3],y=e.length/4-2,s=4,o=this._tables[1],f=o[0],d=o[1],u=o[2],l=o[3],c=o[4];for(i=0;y>i;i++)h=f[t>>>24]^d[n>>16&255]^u[a>>8&255]^l[255&r]^e[s],v=f[n>>>24]^d[a>>16&255]^u[r>>8&255]^l[255&t]^e[s+1],g=f[a>>>24]^d[r>>16&255]^u[t>>8&255]^l[255&n]^e[s+2],r=f[r>>>24]^d[t>>16&255]^u[n>>8&255]^l[255&a]^e[s+3],s+=4,t=h,n=v,a=g;for(i=0;4>i;i++)b[(3&-i)+m]=c[t>>>24]<<24^c[n>>16&255]<<16^c[a>>8&255]<<8^c[255&r]^e[s++],h=t,t=n,n=a,a=r,r=h}}]),e}();e.default=n},{}],9:[function(t,l,e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var i=t("./aes"),s=r(i),o=function(){function e(t,r){n(this,e),this.key=t,this.iv=r}return a(e,[{key:"ntoh",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"doDecrypt",value:function(n,v,a){var u,h,o,f,l,c,d,i,e,r=new Int32Array(n.buffer,n.byteOffset,n.byteLength>>2),p=new s.default(Array.prototype.slice.call(v)),g=new Uint8Array(n.byteLength),t=new Int32Array(g.buffer);for(u=~~a[0],h=~~a[1],o=~~a[2],f=~~a[3],e=0;e<r.length;e+=4)l=~~this.ntoh(r[e]),c=~~this.ntoh(r[e+1]),d=~~this.ntoh(r[e+2]),i=~~this.ntoh(r[e+3]),p.decrypt(l,c,d,i,t,e),t[e]=this.ntoh(t[e]^u),t[e+1]=this.ntoh(t[e+1]^h),t[e+2]=this.ntoh(t[e+2]^o),t[e+3]=this.ntoh(t[e+3]^f),u=l,h=c,o=d,f=i;return g}},{key:"localDecrypt",value:function(e,t,r,n){var a=this.doDecrypt(e,t,r);n.set(a,e.byteOffset)}},{key:"decrypt",value:function(i){var r=32e3,t=new Int32Array(i),n=new Uint8Array(i.byteLength),e=0,s=this.key,a=this.iv;for(this.localDecrypt(t.subarray(e,e+r),s,a,n),e=r;e<t.length;e+=r)a=new Uint32Array([this.ntoh(t[e-4]),this.ntoh(t[e-3]),this.ntoh(t[e-2]),this.ntoh(t[e-1])]),this.localDecrypt(t.subarray(e,e+r),s,a,n);return n}}]),e}();e.default=o},{"./aes":8}],10:[function(t,d,r){"use strict";function l(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(r,"__esModule",{value:!0});var s=t("./aes128-decrypter"),o=l(s),n=t("../errors"),e=t("../utils/logger"),i=function(){function t(r){a(this,t),this.hls=r;try{var e=window?window.crypto:crypto;this.subtle=e.subtle||e.webkitSubtle,this.disableWebCrypto=!this.subtle}catch(e){this.disableWebCrypto=!0}}return u(t,[{key:"destroy",value:function(){}},{key:"decrypt",value:function(e,t,r,n){this.disableWebCrypto&&this.hls.config.enableSoftwareAES?this.decryptBySoftware(e,t,r,n):this.decryptByWebCrypto(e,t,r,n)}},{key:"decryptByWebCrypto",value:function(t,r,n,a){var i=this;e.logger.log("decrypting by WebCrypto API"),this.subtle.importKey("raw",r,{name:"AES-CBC",length:128},!1,["decrypt"]).then(function(e){i.subtle.decrypt({name:"AES-CBC",iv:n.buffer},e,t).then(a).catch(function(e){i.onWebCryptoError(e,t,r,n,a)})}).catch(function(e){i.onWebCryptoError(e,t,r,n,a)})}},{key:"decryptBySoftware",value:function(r,n,a,i){e.logger.log("decrypting by JavaScript Implementation");var t=new DataView(n.buffer),s=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]);t=new DataView(a.buffer);var l=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]),u=new o.default(s,l);i(u.decrypt(r).buffer)}},{key:"onWebCryptoError",value:function(t,r,a,i,s){this.hls.config.enableSoftwareAES?(e.logger.log("disabling to use WebCrypto API"),this.disableWebCrypto=!0,this.decryptBySoftware(r,a,i,s)):(e.logger.error("decrypting error : "+t.message),this.hls.trigger(Event.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:t.message}))}}]),t}();r.default=i},{"../errors":19,"../utils/logger":34,"./aes128-decrypter":9}],11:[function(e,f,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var d=e("./adts"),o=r(d),l=e("../utils/logger"),u=e("../demux/id3"),n=r(u),s=function(){function e(t,r){a(this,e),this.observer=t,this.remuxerClass=r,this.remuxer=new this.remuxerClass(t),this._aacTrack={container:"audio/adts",type:"audio",id:-1,sequenceNumber:0,samples:[],len:0}}return i(e,[{key:"push",value:function(t,p,R,m,_,E,b,y){var a,i,v,c,e,s,f,u,g,r=this._aacTrack,d=new n.default(t),h=90*d.timeStamp;for(e=d.length,u=t.length;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);for(r.audiosamplerate||(a=o.default.getAudioConfig(this.observer,t,e,p),r.config=a.config,r.audiosamplerate=a.samplerate,r.channelCount=a.channelCount,r.codec=a.codec,r.timescale=a.samplerate,r.duration=a.samplerate*y,l.logger.log("parsed codec:"+r.codec+",rate:"+a.samplerate+",nb channel:"+a.channelCount)),c=0,v=9216e4/r.audiosamplerate;u>e+5&&(s=1&t[e+1]?7:9,i=(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5,i-=s,i>0&&u>=e+s+i);)for(f=h+c*v,g={unit:t.subarray(e+s,e+s+i),pts:f,dts:f},r.samples.push(g),r.len+=i,e+=i+s,c++;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);this.remuxer.remux(this._aacTrack,{samples:[]},{samples:[{pts:h,dts:h,unit:d.payload}]},{samples:[]},m)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){var e,r,a=new n.default(t);if(a.hasTimeStamp)for(e=a.length,r=t.length;r-1>e;e++)if(255===t[e]&&240===(240&t[e+1]))return!0;return!1}}]),e}();t.default=s},{"../demux/id3":17,"../utils/logger":34,"./adts":12}],12:[function(e,o,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var i=e("../utils/logger"),r=e("../errors"),s=function(){function e(){n(this,e)}return a(e,null,[{key:"getAudioConfig",value:function(h,u,l,a){var n,e,s,o,t,f=navigator.userAgent.toLowerCase(),d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return n=((192&u[l+2])>>>6)+1,e=(60&u[l+2])>>>2,e>d.length-1?void h.trigger(Event.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+e}):(o=(1&u[l+2])<<2,o|=(192&u[l+3])>>>6,i.logger.log("manifest codec:"+a+",ADTS data:type:"+n+",sampleingIndex:"+e+"["+d[e]+"Hz],channelConfig:"+o),-1!==f.indexOf("firefox")?e>=6?(n=5,t=new Array(4),s=e-3):(n=2,t=new Array(2),s=e):-1!==f.indexOf("android")?(n=2,t=new Array(2),s=e):(n=5,t=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&e>=6?s=e-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(e>=6||1===o)||!a&&1===o)&&(n=2,t=new Array(2)),s=e)),t[0]=n<<3,t[0]|=(14&e)>>1,t[1]|=(1&e)<<7,t[1]|=o<<3,5===n&&(t[1]|=(14&s)>>1,t[2]=(1&s)<<7,t[2]|=8,t[3]=0),{config:t,samplerate:d[e],channelCount:o,codec:"mp4a.40."+n})}}]),e}();t.default=s},{"../errors":19,"../utils/logger":34}],13:[function(e,y,n){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var h=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(n,"__esModule",{value:!0});var g=e("../events"),o=t(g),a=e("../errors"),p=e("../demux/aacdemuxer"),i=t(p),f=e("../demux/tsdemuxer"),r=t(f),c=e("../remux/mp4-remuxer"),s=t(c),v=e("../remux/passthrough-remuxer"),u=t(v),l=function(){function e(t,r){d(this,e),this.hls=t,this.typeSupported=r}return h(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(n,l,d,f,h,c,g,v){var e=this.demuxer;if(!e){var t=this.hls;if(r.default.probe(n))e=this.typeSupported.mp2t===!0?new r.default(t,u.default):new r.default(t,s.default);else{if(!i.default.probe(n))return void t.trigger(o.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});e=new i.default(t,s.default)}this.demuxer=e}e.push(n,l,d,f,h,c,g,v)}}]),e}();n.default=l},{"../demux/aacdemuxer":11,"../demux/tsdemuxer":18,"../errors":19,"../events":21,"../remux/mp4-remuxer":29,"../remux/passthrough-remuxer":30}],14:[function(t,d,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=t("../demux/demuxer-inline"),u=r(a),s=t("../events"),e=r(s),l=t("events"),i=r(l),o=function(r){var t=new i.default;t.trigger=function(n){for(var r=arguments.length,a=Array(r>1?r-1:0),e=1;r>e;e++)a[e-1]=arguments[e];t.emit.apply(t,[n,n].concat(a))},t.off=function(a){for(var r=arguments.length,n=Array(r>1?r-1:0),e=1;r>e;e++)n[e-1]=arguments[e];t.removeListener.apply(t,[a].concat(n))},r.addEventListener("message",function(n){var e=n.data;switch(e.cmd){case"init":r.demuxer=new u.default(t,e.typeSupported);break;case"demux":r.demuxer.push(new Uint8Array(e.data),e.audioCodec,e.videoCodec,e.timeOffset,e.cc,e.level,e.sn,e.duration)}}),t.on(e.default.FRAG_PARSING_INIT_SEGMENT,function(t,e){r.postMessage({event:t,tracks:e.tracks,unique:e.unique})}),t.on(e.default.FRAG_PARSING_DATA,function(n,e){var t={event:n,type:e.type,startPTS:e.startPTS,endPTS:e.endPTS,startDTS:e.startDTS,endDTS:e.endDTS,data1:e.data1.buffer,data2:e.data2.buffer,nb:e.nb};r.postMessage(t,[t.data1,t.data2])}),t.on(e.default.FRAG_PARSED,function(e){r.postMessage({event:e})}),t.on(e.default.ERROR,function(e,t){r.postMessage({event:e,data:t})}),t.on(e.default.FRAG_PARSING_METADATA,function(e,t){var n={event:e,samples:t.samples};r.postMessage(n)}),t.on(e.default.FRAG_PARSING_USERDATA,function(e,t){var n={event:e,samples:t.samples};r.postMessage(n)})};n.default=o},{"../demux/demuxer-inline":13,"../events":21,events:1}],15:[function(t,v,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var h=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(n,"__esModule",{value:!0});var s=t("../events"),e=r(s),g=t("../demux/demuxer-inline"),a=r(g),d=t("../demux/demuxer-worker"),f=r(d),i=t("../utils/logger"),c=t("../crypt/decrypter"),l=r(c),o=function(){function r(e){u(this,r),this.hls=e;var n={mp4:MediaSource.isTypeSupported("video/mp4"),mp2t:e.config.enableMP2TPassThrough&&MediaSource.isTypeSupported("video/mp2t")};if(e.config.enableWorker&&"undefined"!=typeof Worker){i.logger.log("demuxing in webworker");try{var s=t("webworkify");this.w=s(f.default),this.onwmsg=this.onWorkerMessage.bind(this),this.w.addEventListener("message",this.onwmsg),this.w.postMessage({cmd:"init",typeSupported:n})}catch(t){i.logger.error("error while initializing DemuxerWorker, fallback on DemuxerInline"),this.demuxer=new a.default(e,n)}}else this.demuxer=new a.default(e,n);this.demuxInitialized=!0}return h(r,[{key:"destroy",value:function(){this.w?(this.w.removeEventListener("message",this.onwmsg),this.w.terminate(),this.w=null):(this.demuxer.destroy(),this.demuxer=null),this.decrypter&&(this.decrypter.destroy(),this.decrypter=null)}},{key:"pushDecrypted",value:function(e,t,r,n,a,i,s,o){this.w?this.w.postMessage({cmd:"demux",data:e,audioCodec:t,videoCodec:r,timeOffset:n,cc:a,level:i,sn:s,duration:o},[e]):this.demuxer.push(new Uint8Array(e),t,r,n,a,i,s,o)}},{key:"push",value:function(t,r,n,a,i,s,o,u,e){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){null==this.decrypter&&(this.decrypter=new l.default(this.hls));var d=this;this.decrypter.decrypt(t,e.key,e.iv,function(e){d.pushDecrypted(e,r,n,a,i,s,o,u)})}else this.pushDecrypted(t,r,n,a,i,s,o,u)}},{key:"onWorkerMessage",value:function(n){var t=n.data;switch(t.event){case e.default.FRAG_PARSING_INIT_SEGMENT:var r={};r.tracks=t.tracks,r.unique=t.unique,this.hls.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,r);break;case e.default.FRAG_PARSING_DATA:this.hls.trigger(e.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});break;case e.default.FRAG_PARSING_METADATA:this.hls.trigger(e.default.FRAG_PARSING_METADATA,{samples:t.samples});break;case e.default.FRAG_PARSING_USERDATA:this.hls.trigger(e.default.FRAG_PARSING_USERDATA,{samples:t.samples});break;default:this.hls.trigger(t.event,t.data)}}}]),r}();n.default=o},{"../crypt/decrypter":10,"../demux/demuxer-inline":13,"../demux/demuxer-worker":14,"../events":21,"../utils/logger":34,webworkify:2}],16:[function(t,s,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=t("../utils/logger"),i=function(){function e(t){r(this,e),this.data=t,this.bytesAvailable=this.data.byteLength,this.word=0,this.bitsAvailable=0}return n(e,[{key:"loadWord",value:function(){var t=this.data.byteLength-this.bytesAvailable,r=new Uint8Array(4),e=Math.min(4,this.bytesAvailable);if(0===e)throw new Error("no bytes available");r.set(this.data.subarray(t,t+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}},{key:"skipBits",value:function(e){var t;this.bitsAvailable>e?(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(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0?r<<e|this.readBits(e):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>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(a){var t,n,r=8,e=8;for(t=0;a>t;t++)0!==e&&(n=this.readEG(),e=(r+n+256)%256),r=0===e?r:e}},{key:"readSPS",value:function(){var t,v,p,l,a,i,n,o,r,s=0,d=0,f=0,h=0,c=1;if(this.readUByte(),t=this.readUByte(),v=this.readBits(5),this.skipBits(3),p=this.readUByte(),this.skipUEG(),100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t){var g=this.readUEG();if(3===g&&this.skipBits(1),this.skipUEG(),this.skipUEG(),this.skipBits(1),this.readBoolean())for(o=3!==g?8:12,r=0;o>r;r++)this.readBoolean()&&(6>r?this.skipScalingList(16):this.skipScalingList(64))}this.skipUEG();var u=this.readUEG();if(0===u)this.readUEG();else if(1===u)for(this.skipBits(1),this.skipEG(),this.skipEG(),l=this.readUEG(),r=0;l>r;r++)this.skipEG();if(this.skipUEG(),this.skipBits(1),a=this.readUEG(),i=this.readUEG(),n=this.readBits(1),0===n&&this.skipBits(1),this.skipBits(1),this.readBoolean()&&(s=this.readUEG(),d=this.readUEG(),f=this.readUEG(),h=this.readUEG()),this.readBoolean()&&this.readBoolean()){var e=void 0,y=this.readUByte();switch(y){case 1:e=[1,1];break;case 2:e=[12,11];break;case 3:e=[10,11];break;case 4:e=[16,11];break;case 5:e=[40,33];break;case 6:e=[24,11];break;case 7:e=[20,11];break;case 8:e=[32,11];break;case 9:e=[80,33];break;case 10:e=[18,11];break;case 11:e=[15,11];break;case 12:e=[64,33];break;case 13:e=[160,99];break;case 14:e=[4,3];break;case 15:e=[3,2];break;case 16:e=[2,1];break;case 255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}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(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=i},{"../utils/logger":34}],17:[function(r,s,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(a){n(this,t),this._hasTimeStamp=!1;for(var l,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)return r-=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)}}return a(t,[{key:"readUTF",value:function(n,e,a){var t="",r=e,i=e+a;do t+=String.fromCharCode(n[r++]);while(i>r);return t}},{key:"_parseID3Frames",value:function(r,t,i){for(var a,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;var u=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(){return this._hasTimeStamp}},{key:"timeStamp",get:function(){return this._timeStamp}},{key:"length",get:function(){return this._length}},{key:"payload",get:function(){return this._payload}}]),t}();t.default=i},{"../utils/logger":34}],18:[function(t,g,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});var h=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(){function t(e,r){u(this,t),this.observer=e,this.remuxerClass=r,this.lastCC=0,this.remuxer=new this.remuxerClass(e)}return f(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,k,_,p,m,b,A){var s,o,l,t,d,u,y,a,c=n.length,E=this.remuxer.passthrough;this.audioCodec=R,this.videoCodec=k,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):b===this.lastSN+1&&(this.contiguous=!0),this.lastSN=b,this.contiguous||(this.aacOverFlow=null);var v=this.pmtParsed,h=this._avcTrack.id,f=this._aacTrack.id,g=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}else a=t+4;if(v)if(u===h){if(d){if(s&&(this._parseAVCPES(this._parsePES(s)),E&&this._avcTrack.codec&&(-1===f||this._aacTrack.codec)))return void this.remux(n);
+s={data:[],size:0}}s&&(s.data.push(n.subarray(a,t+188)),s.size+=t+188-a)}else if(u===f){if(d){if(o&&(this._parseAACPES(this._parsePES(o)),E&&this._aacTrack.codec&&(-1===h||this._avcTrack.codec)))return void this.remux(n);o={data:[],size:0}}o&&(o.data.push(n.subarray(a,t+188)),o.size+=t+188-a)}else u===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));else d&&(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)}else this.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=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(r,t){var a,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]){case 15:this._aacTrack.id=n;break;case 21:this._id3Track.id=n;break;case 27: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){var e,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=new Uint8Array(o.size);s.length;){e=s.shift();var a=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}}return null}},{key:"_parseAVCPES",value:function(n){var t,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){var v=u[u.length-1],h=v.units.units[v.units.units.length-1],p=new Uint8Array(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;var a="";m.forEach(function(e){switch(e.type){case 1:i=!0,o&&(a+="NDR ");break;case 5:i=!0,o&&(a+="IDR "),c=!0;break;case 6:i=!0,o&&(a+="SEI "),t=new s.default(e.data),t.readUByte();var b=t.readUByte();if(4===b){var p=0;do p=t.readUByte();while(255===p);var R=t.readUByte();if(181===R){var _=t.readUShort();if(49===_){var A=t.readUInt();if(1195456820===A){var L=t.readUByte();if(3===L){var v=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;case 7:if(i=!0,o&&(a+="SPS "),!r.sps){t=new s.default(e.data);var y=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;var k=e.data.subarray(1,4),m="avc1.";for(l=0;3>l;l++){var u=k[l].toString(16);u.length<2&&(u="0"+u),m+=u}r.codec=m}break;case 8:i=!0,o&&(a+="PPS "),r.pps||(r.pps=[e.data]);break;case 9: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(var i,n,s,p,a,l,t=0,h=r.byteLength,e=0,d=[];h>t;)switch(i=r[t++],e){case 0:0===i&&(e=1);break;case 1:e=0===i?2:0;break;case 2:case 3:if(0===i)e=3;else if(1===i&&h>t){if(p=31&r[t],a)s={data:r.subarray(a,t-e-1),type:l},d.push(s);else if(n=t-e-1){var c=this._avcTrack,f=c.samples;if(f.length){var g=f[f.length-1],v=g.units.units,o=v[v.length-1],u=new Uint8Array(o.data.byteLength+n);u.set(o.data,0),u.set(r.subarray(0,n),o.data.byteLength),o.data=u,g.units.length+=n,c.len+=n}}a=t,l=p,e=0}else e=0}return a&&(s={data:r.subarray(a,h),type:l},d.push(s)),d}},{key:"_parseAACPES",value:function(R){var s,l,p,b,t,d,h,o,_,a=this._aacTrack,n=R.data,g=R.pts,L=0,k=this._duration,A=this.audioCodec,u=this.aacOverFlow,E=this.lastAacPTS;if(u){var m=new Uint8Array(u.byteLength+n.byteLength);m.set(u,0),m.set(n,u.byteLength),n=m}for(t=L,o=n.length;o-1>t&&(255!==n[t]||240!==(240&n[t+1]));t++);if(t){var y,f;if(o-1>t?(y="AAC PES did not start with ADTS header,offset:"+t,f=!1):(y="no ADTS header found in AAC PES",f=!0),this.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:f,reason:y}),f)return}if(a.audiosamplerate||(s=c.default.getAudioConfig(this.observer,n,t,A),a.config=s.config,a.audiosamplerate=s.samplerate,a.channelCount=s.channelCount,a.codec=s.codec,a.timescale=s.samplerate,a.duration=s.samplerate*k,e.logger.log("parsed codec:"+a.codec+",rate:"+s.samplerate+",nb channel:"+s.channelCount)),b=0,p=9216e4/a.audiosamplerate,u&&E){var v=E+p;Math.abs(v-g)>1&&(e.logger.log("AAC: align PTS for overlapping frames by "+Math.round((v-g)/90)),g=v)}for(;o>t+5&&(d=1&n[t+1]?7:9,l=(3&n[t+3])<<11|n[t+4]<<3|(224&n[t+5])>>>5,l-=d,l>0&&o>=t+d+l);)for(h=g+b*p,_={unit:n.subarray(t+d,t+d+l),pts:h,dts:h},a.samples.push(_),a.len+=l,t+=l+d,b++;o-1>t&&(255!==n[t]||240!==(240&n[t+1]));t++);u=o>t?n.subarray(t,o):null,this.aacOverFlow=u,this.lastAacPTS=h}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(e){return e.length>=564&&71===e[0]&&71===e[188]&&71===e[376]?!0:!1}}]),t}();a.default=o},{"../errors":19,"../events":21,"../utils/logger":34,"./adts":12,"./exp-golomb":16}],19:[function(t,r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ErrorTypes={NETWORK_ERROR:"hlsNetworkError",MEDIA_ERROR:"hlsMediaError",OTHER_ERROR:"hlsOtherError"},e.ErrorDetails={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError"}},{}],20:[function(i,s,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="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},n=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(i){t(this,e),this.hls=i,this.onEvent=this.onEvent.bind(this);for(var n=arguments.length,a=Array(n>1?n-1:0),r=1;n>r;r++)a[r-1]=arguments[r];this.handledEvents=a,this.useGenericHandler=!0,this.registerListeners()}return n(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{key:"isEventHandler",value:function(){return"object"===r(this.handledEvents)&&this.handledEvents.length&&"function"==typeof this.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if("hlsEventGeneric"===e)throw new Error("Forbidden event name: "+e);this.hls.on(e,this.onEvent)}.bind(this))}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)}.bind(this))}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){var r=function(t,r){var e="on"+t.replace("hls","");if("function"!=typeof this[e])throw new Error("Event "+t+" has no generic handler in this "+this.constructor.name+" class (tried "+e+")");return this[e].bind(this,r)};r.call(this,e,t).call()}}]),e}();e.default=a},{}],21:[function(t,e,r){"use strict";e.exports={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVEL_SWITCH:"hlsLevelSwitch",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded"}},{}],22:[function(r,s,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(){n(this,t)}return a(t,null,[{key:"mergeDetails",value:function(i,n){var s,c=Math.max(i.startSN,n.startSN)-n.startSN,d=Math.min(i.endSN,n.endSN)-n.startSN,f=n.startSN-i.startSN,h=i.fragments,o=n.fragments,u=0;if(c>d)return void(n.PTSKnown=!1);for(var r=c;d>=r;r++){var l=h[f+r],a=o[r];u=l.cc-a.cc,isNaN(l.startPTS)||(a.start=a.startPTS=l.startPTS,a.endPTS=l.endPTS,a.duration=l.duration,s=a)}if(u)for(e.logger.log("discontinuity sliding from playlist, take drift into account"),r=0;r<o.length;r++)o[r].cc+=u;if(s)t.updateFragPTS(n,s.sn,s.startPTS,s.endPTS);else{var g=h[f].start;for(r=0;r<o.length;r++)o[r].start+=g}n.PTSKnown=i.PTSKnown}},{key:"updateFragPTS",value:function(n,l,a,s){var o,i,r,e;if(l<n.startSN||l>n.endSN)return 0;o=l-n.startSN,i=n.fragments,r=i[o],isNaN(r.startPTS)||(a=Math.min(a,r.startPTS),s=Math.max(s,r.endPTS));var u=a-r.start;for(r.start=r.startPTS=a,r.endPTS=s,r.duration=s-a,e=o;e>0;e--)t.updatePTS(i,e,e-1);for(e=o;e<i.length-1;e++)t.updatePTS(i,e,e+1);return n.PTSKnown=!0,u}},{key:"updatePTS",value:function(s,n,a){var t=s[n],r=s[a],i=r.startPTS;isNaN(i)?a>n?r.start=t.start+t.duration:r.start=t.start-r.duration:a>n?(t.duration=i-t.start,t.duration<0&&e.logger.error("negative duration computed for frag "+t.sn+",level "+t.level+", there should be some duration drift between playlist and fragment!")):(r.duration=t.start-i,r.duration<0&&e.logger.error("negative duration computed for frag "+r.sn+",level "+r.level+", there should be some duration drift between playlist and fragment!"))}}]),t}();t.default=i},{"../utils/logger":34}],23:[function(t,D,a){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});var A=t("./events"),n=r(A),s=t("./errors"),u=t("./loader/playlist-loader"),d=r(u),f=t("./loader/fragment-loader"),h=r(f),c=t("./controller/abr-controller"),g=r(c),O=t("./controller/buffer-controller"),p=r(O),y=t("./controller/stream-controller"),m=r(y),b=t("./controller/level-controller"),E=r(b),_=t("./controller/timeline-controller"),R=r(_),e=t("./utils/logger"),k=t("./utils/xhr-loader"),L=r(k),T=t("events"),S=r(T),w=t("./loader/key-loader"),v=r(w),l=function(){function t(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];o(this,t);var i=t.DefaultConfig;for(var a in i)a in n||(n[a]=i[a]);if(void 0!==n.liveMaxLatencyDurationCount&&n.liveMaxLatencyDurationCount<=n.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');(0,e.enableLogs)(n.debug),this.config=n;var r=this.observer=new S.default;r.trigger=function(n){for(var t=arguments.length,a=Array(t>1?t-1:0),e=1;t>e;e++)a[e-1]=arguments[e];r.emit.apply(r,[n,n].concat(a))},r.off=function(a){for(var t=arguments.length,n=Array(t>1?t-1:0),e=1;t>e;e++)n[e-1]=arguments[e];r.removeListener.apply(r,[a].concat(n))},this.on=r.on.bind(r),this.off=r.off.bind(r),this.trigger=r.trigger.bind(r),this.playlistLoader=new d.default(this),this.fragmentLoader=new h.default(this),this.levelController=new E.default(this),this.abrController=new n.abrController(this),this.bufferController=new n.bufferController(this),this.streamController=new n.streamController(this),this.timelineController=new n.timelineController(this),this.keyLoader=new v.default(this)}return i(t,null,[{key:"isSupported",value:function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"Events",get:function(){return n.default}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig||(t.defaultConfig={autoStartLoad:!0,debug:!1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingLoopThreshold:3,startFragPrefetch:!1,appendErrorMaxRetry:3,loader:L.default,fLoader:void 0,pLoader:void 0,abrController:g.default,bufferController:p.default,streamController:m.default,timelineController:R.default,enableCEA708Captions:!0,enableMP2TPassThrough:!1}),t.defaultConfig},set:function(e){t.defaultConfig=e}}]),i(t,[{key:"destroy",value:function(){e.logger.log("destroy"),this.trigger(n.default.DESTROYING),this.detachMedia(),this.playlistLoader.destroy(),this.fragmentLoader.destroy(),this.levelController.destroy(),this.bufferController.destroy(),this.streamController.destroy(),this.timelineController.destroy(),this.keyLoader.destroy(),this.url=null,this.observer.removeAllListeners()}},{key:"attachMedia",value:function(t){e.logger.log("attachMedia"),this.media=t,this.trigger(n.default.MEDIA_ATTACHING,{media:t})}},{key:"detachMedia",value:function(){e.logger.log("detachMedia"),this.trigger(n.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(t){e.logger.log("loadSource:"+t),this.url=t,this.trigger(n.default.MANIFEST_LOADING,{url:t})}},{key:"startLoad",value:function(){e.logger.log("startLoad"),this.streamController.startLoad()}},{key:"swapAudioCodec",value:function(){e.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){e.logger.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){e.logger.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){e.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){e.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel()},set:function(e){this.levelController.level=e}},{key:"firstLevel",get:function(){return this.levelController.firstLevel},set:function(t){e.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){e.logger.log("set startLevel:"+t),this.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this.abrController.autoLevelCapping},set:function(t){e.logger.log("set autoLevelCapping:"+t),this.abrController.autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}}]),t}();a.default=l},{"./controller/abr-controller":3,"./controller/buffer-controller":4,"./controller/level-controller":5,"./controller/stream-controller":6,"./controller/timeline-controller":7,"./errors":19,"./events":21,"./loader/fragment-loader":25,"./loader/key-loader":26,"./loader/playlist-loader":27,"./utils/logger":34,"./utils/xhr-loader":36,events:1}],24:[function(e,t,r){"use strict";t.exports=e("./hls.js").default},{"./hls.js":23}],25:[function(r,c,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var h=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(n,"__esModule",{value:!0});var l=r("../events"),e=a(l),d=r("../event-handler"),i=a(d),t=r("../errors"),o=function(n){function r(t){return u(this,r),f(this,Object.getPrototypeOf(r).call(this,t,e.default.FRAG_LOADING))}return s(r,n),h(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),i.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(r){var t=r.frag;this.frag=t,this.frag.loaded=0;var e=this.hls.config;t.loader=this.loader="undefined"!=typeof e.fLoader?new e.fLoader(e):new e.loader(e),this.loader.load(t.url,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),e.fragLoadingTimeOut,1,0,this.loadprogress.bind(this),t)}},{key:"loadsuccess",value:function(n,t){var r=n.currentTarget.response;t.length=r.byteLength,this.frag.loader=void 0,this.hls.trigger(e.default.FRAG_LOADED,{payload:r,frag:this.frag,stats:t})}},{key:"loaderror",value:function(r){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(r,t){this.frag.loaded=t.loaded,this.hls.trigger(e.default.FRAG_LOAD_PROGRESS,{frag:this.frag,stats:t})}}]),r}(i.default);n.default=o},{"../errors":19,"../event-handler":20,"../events":21}],26:[function(r,c,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var h=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(n,"__esModule",{value:!0});var l=r("../events"),e=a(l),d=r("../event-handler"),i=a(d),t=r("../errors"),o=function(n){function r(n){u(this,r);var t=f(this,Object.getPrototypeOf(r).call(this,n,e.default.KEY_LOADING));return t.decryptkey=null,t.decrypturl=null,t}return s(r,n),h(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),i.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(i){var t=this.frag=i.frag,a=t.decryptdata,n=a.uri;if(n!==this.decrypturl||null===this.decryptkey){var r=this.hls.config;t.loader=this.loader=new r.loader(r),this.decrypturl=n,this.decryptkey=null,t.loader.load(n,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r.fragLoadingTimeOut,r.fragLoadingMaxRetry,r.fragLoadingRetryDelay,this.loadprogress.bind(this),t)}else this.decryptkey&&(a.key=this.decryptkey,this.hls.trigger(e.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(r){var t=this.frag;this.decryptkey=t.decryptdata.key=new Uint8Array(r.currentTarget.response),t.loader=void 0,this.hls.trigger(e.default.KEY_LOADED,{frag:t})}},{key:"loaderror",value:function(r){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(){}}]),r}(i.default);n.default=o},{"../errors":19,"../event-handler":20,"../events":21}],27:[function(r,y,s){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(s,"__esModule",{value:!0});var l=r("../events"),t=n(l),p=r("../event-handler"),i=n(p),e=r("../errors"),c=r("../utils/url"),g=n(c),v=r("../utils/attr-list"),a=n(v),u=function(n){function r(e){return d(this,r),f(this,Object.getPrototypeOf(r).call(this,e,t.default.MANIFEST_LOADING,t.default.LEVEL_LOADING))}return h(r,n),o(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),this.url=this.id=null,i.default.prototype.destroy.call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,null)}},{key:"onLevelLoading",value:function(e){this.load(e.url,e.level,e.id)}},{key:"load",value:function(a,i,s){var t,r,n,e=this.hls.config;this.url=a,this.id=i,this.id2=s,void 0===this.id?(t=e.manifestLoadingMaxRetry,r=e.manifestLoadingTimeOut,n=e.manifestLoadingRetryDelay):(t=e.levelLoadingMaxRetry,r=e.levelLoadingTimeOut,n=e.levelLoadingRetryDelay),this.loader="undefined"!=typeof e.pLoader?new e.pLoader(e):new e.loader(e),this.loader.load(a,"",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r,t,n)}},{key:"resolve",value:function(e,t){return g.default.buildAbsoluteURL(t,e)}},{key:"parseMasterPlaylist",value:function(f,u){for(var l=[],n=void 0,d=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g;null!=(n=d.exec(f));){var e={},r=e.attrs=new a.default(n[1]);e.url=this.resolve(n[2],u);var s=r.decimalResolution("RESOLUTION");s&&(e.width=s.width,e.height=s.height),e.bitrate=r.decimalInteger("BANDWIDTH"),e.name=r.NAME;var t=r.CODECS;if(t){t=t.split(",");for(var o=0;o<t.length;o++){var i=t[o];-1!==i.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(i):e.audioCodec=i}}l.push(e)}return l}},{key:"avc1toavcoti",value:function(r){var e,t=r.split(".");return t.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){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(k,l,A){var e,E,s,i,v=0,o=0,n={url:l,fragments:[],live:!0,startSN:0},r={method:null,key:null,iv:null,uri:null},b=0,f=null,t=null;for(E=/(?:#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=E.exec(k));)switch(e.shift(),e=e.filter(function(e){return void 0!==e}),e[0]){case"MEDIA-SEQUENCE":v=n.startSN=parseInt(e[1]);break;case"TARGETDURATION":n.targetduration=parseFloat(e[1]);break;case"ENDLIST":n.live=!1;break;case"DIS":b++;break;case"BYTERANGE":var c=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":var g=parseFloat(e[1]);if(!isNaN(g)){var u,m=v++;if(r.method&&r.uri&&!r.iv){u=this.cloneObj(r);for(var y=new Uint8Array(16),d=12;16>d;d++)y[d]=m>>8*(15-d)&255;u.iv=y}else u=r;var L=e[2]?this.resolve(e[2],l):null;t={url:L,duration:g,start:o,sn:m,level:A,cc:b,byteRangeStartOffset:i,byteRangeEndOffset:s,decryptdata:u,programDateTime:f},n.fragments.push(t),o+=g,i=null,f=null}break;case"KEY":var R=e[1],p=new a.default(R),h=p.enumeratedString("METHOD"),_=p.URI,T=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=T));break;case"PROGRAM-DATE-TIME":f=new Date(Date.parse(e[1]))}return t&&!t.url&&(n.fragments.pop(),o-=t.duration),n.totalduration=o,n.endSN=v-1,n}},{key:"loadsuccess",value:function(u,n){var s,o=u.currentTarget,i=o.responseText,r=o.responseURL,l=this.id,d=this.id2,a=this.hls;if(void 0===r&&(r=this.url),n.tload=performance.now(),n.mtime=new Date(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{var f=this.parseLevelPlaylist(i,r,l);n.tparsed=performance.now(),a.trigger(t.default.LEVEL_LOADED,{details:f,level:l,id:d,stats:n})}else s=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"});else a.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){var r,n;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0):(r=e.ErrorDetails.LEVEL_LOAD_ERROR,n=!1),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(){var r,n;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_TIMEOUT,n=!0):(r=e.ErrorDetails.LEVEL_LOAD_TIMEOUT,n=!1),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":19,"../event-handler":20,"../events":21,"../utils/attr-list":31,"../utils/url":35}],28:[function(a,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(){t(this,e)}return r(e,null,[{key:"init",value:function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t;for(t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var n=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),a=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:n,audio:a};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=s,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var r=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,r,l,r,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))}},{key:"box",value:function(a){for(var t,n=Array.prototype.slice.call(arguments,1),e=8,r=n.length,i=r;r--;)e+=n[r].byteLength;for(t=new Uint8Array(e),t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t.set(a,4),r=0,e=8;i>r;r++)t.set(n[r],e),e+=n[r].byteLength;return t}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,t>>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,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))}},{key:"moov",value:function(t){for(var r=t.length,n=[];r--;)n[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(e.mvex(t)))}},{key:"mvex",value:function(r){for(var t=r.length,n=[];t--;)n[t]=e.trex(r[t]);return e.box.apply(null,[e.types.mvex].concat(n))}},{key:"mvhd",value:function(t,r){var n=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,n)}},{key:"sdtp",value:function(i){var r,t,n=i.samples||[],a=new Uint8Array(4+n.length);for(t=0;t<n.length;t++)r=n[t].flags,a[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,a)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,a,i,n=[],s=[];for(r=0;r<t.sps.length;r++)a=t.sps[r],i=a.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(a));for(r=0;r<t.pps.length;r++)a=t.pps[r],i=a.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(a));var u=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))),o=t.width,l=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,o>>8&255,255&o,l>>8&255,255&l,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]),u,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.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,n=t.duration,a=t.width,i=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,n>>24,n>>16&255,n>>8&255,255&n,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,a>>8&255,255&a,0,0,i>>8&255,255&i,0,0]))}},{key:"traf",value:function(n,t){var a=e.sdtp(n),r=n.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t])),e.trun(n,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(r){var t=r.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(h,o){var n,a,i,s,t,l,d=h.samples||[],r=d.length,f=12+16*r,u=new Uint8Array(f);for(o+=8+f,u.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o],0),n=0;r>n;n++)a=d[n],i=a.duration,s=a.size,t=a.flags,l=a.cts,u.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,61440&t.degradPrio,15&t.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,u)}},{key:"initSegment",value:function(n){e.types||e.init();var t,r=e.moov(n);return t=new Uint8Array(e.FTYP.byteLength+r.byteLength),t.set(e.FTYP),t.set(r,e.FTYP.byteLength),t}}]),e}();e.default=n},{}],29:[function(n,h,a){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(a,"__esModule",{value:!0});var f=n("../events"),e=i(f),t=n("../utils/logger"),u=n("../remux/mp4-generator"),r=i(u),s=n("../errors"),d=function(){function n(e){o(this,n),this.observer=e,this.ISGenerated=!1,this.PES2MP4SCALEFACTOR=4,this.PES_TIMESCALE=9e4,this.MP4_TIMESCALE=this.PES_TIMESCALE/this.PES2MP4SCALEFACTOR}return l(n,[{key:"destroy",value:function(){}},{key:"insertDiscontinuity",value:function(){this._initPTS=this._initDTS=this.nextAacPts=this.nextAvcDts=void 0}},{key:"switchLevel",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(r,n,a,i,t,s){this.ISGenerated||this.generateIS(r,n,t),n.samples.length&&this.remuxVideo(n,t,s),r.samples.length&&this.remuxAudio(r,t,s),a.samples.length&&this.remuxID3(a,t),i.samples.length&&this.remuxText(i,t),this.observer.trigger(e.default.FRAG_PARSED)}},{key:"generateIS",value:function(n,t,f){var a,i,h=this.observer,c=n.samples,u=t.samples,d=this.PES_TIMESCALE,o={},g={tracks:o,unique:!1},l=void 0===this._initPTS;l&&(a=i=1/0),n.config&&c.length&&(o.audio={container:"audio/mp4",codec:n.codec,initSegment:r.default.initSegment([n]),metadata:{channelCount:n.channelCount}},l&&(a=i=c[0].pts-d*f)),t.sps&&t.pps&&u.length&&(o.video={container:"video/mp4",codec:t.codec,initSegment:r.default.initSegment([t]),metadata:{width:t.width,height:t.height}},l&&(a=Math.min(a,u[0].pts-d*f),i=Math.min(i,u[0].dts-d*f))),Object.keys(o)?(h.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,l&&(this._initPTS=a,this._initDTS=i)):h.trigger(e.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(a,w,S){var k,l,v,A,g,d,T,L,R,h,_,c,o,n,s,p=8,b=this.PES_TIMESCALE,f=this.PES2MP4SCALEFACTOR,u=[];for(d=new Uint8Array(a.len+4*a.nbNalu+8),k=new DataView(d.buffer),k.setUint32(0,d.byteLength),d.set(r.default.types.mdat,4);a.samples.length;){for(l=a.samples.shift(),A=0;l.units.units.length;)g=l.units.units.shift(),k.setUint32(p,g.data.byteLength),p+=4,d.set(g.data,p),p+=g.data.byteLength,A+=4+g.data.byteLength;if(_=l.pts-this._initDTS,c=l.dts-this._initDTS,c=Math.min(_,c),void 0!==h){o=this._PTSNormalize(_,h),n=this._PTSNormalize(c,h);var y=(n-h)/f;0>=y&&(t.logger.log("invalid sample duration at PTS/DTS: "+l.pts+"/"+l.dts+":"+y),y=1),v.duration=y}else{var i,m=this.nextAvcDts;o=this._PTSNormalize(_,m),n=this._PTSNormalize(c,m),i=Math.round((n-m)/90),(S||Math.abs(i)<600)&&i&&(i>1?t.logger.log("AVC:"+i+" ms hole between fragments detected,filling it"):-1>i&&t.logger.log("AVC:"+-i+" ms overlapping between fragments detected"),n=m,o=Math.max(o-i,n),t.logger.log("Video/PTS/DTS adjusted: "+o+"/"+n+",delta:"+i)),L=Math.max(0,o),R=Math.max(0,n)}v={size:A,duration:0,cts:(o-n)/f,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},s=v.flags,l.key===!0?(s.dependsOn=2,s.isNonSync=0):(s.dependsOn=1,s.isNonSync=1),u.push(v),h=n}var E=0;u.length>=2&&(E=u[u.length-2].duration,v.duration=E),this.nextAvcDts=n+E*f,a.len=0,a.nbNalu=0,u.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(s=u[0].flags,s.dependsOn=2,s.isNonSync=0),a.samples=u,T=r.default.moof(a.sequenceNumber++,R/f,a),a.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{data1:T,data2:d,startPTS:L/b,endPTS:(o+f*E)/b,startDTS:R/b,endDTS:this.nextAvcDts/b,type:"video",nb:u.length})}},{key:"remuxAudio",value:function(n,w,S){var L,y,i,f,o,k,A,b,l,v,_,d,a,R=8,u=this.PES_TIMESCALE,T=n.timescale,h=u/T,m=[],E=[];for(n.samples.sort(function(e,t){return e.pts-t.pts}),E=n.samples;E.length;){if(y=E.shift(),f=y.unit,v=y.pts-this._initDTS,_=y.dts-this._initDTS,void 0!==l)d=this._PTSNormalize(v,l),a=this._PTSNormalize(_,l),i.duration=(a-l)/h,Math.abs(i.duration-1024)>10&&t.logger.log("invalid AAC sample duration at PTS "+Math.round(v/90)+",should be 1024,found :"+Math.round(i.duration)),i.duration=1024,a=1024*h+l;else{var s,p=this.nextAacPts;if(d=this._PTSNormalize(v,p),a=this._PTSNormalize(_,p),s=Math.round(1e3*(d-p)/u),(S||Math.abs(s)<600)&&s){if(s>0)t.logger.log(s+" ms hole between AAC samples detected,filling it");else if(-12>s){t.logger.log(-s+" ms overlapping between AAC samples detected, drop frame"),n.len-=f.byteLength;continue}d=a=p}if(A=Math.max(0,d),b=Math.max(0,a),!(n.len>0))return;o=new Uint8Array(n.len+8),L=new DataView(o.buffer),L.setUint32(0,o.byteLength),o.set(r.default.types.mdat,4)}o.set(f,R),R+=f.byteLength,i={size:f.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},m.push(i),l=a}var g=0,c=m.length;c>=2&&(g=m[c-2].duration,i.duration=g),c&&(this.nextAacPts=d+h*g,n.len=0,n.samples=m,k=r.default.moof(n.sequenceNumber++,b/h,n),n.samples=[],this.observer.trigger(e.default.FRAG_PARSING_DATA,{data1:k,data2:o,startPTS:A/u,endPTS:this.nextAacPts/u,startDTS:b/u,endDTS:(a+h*g)/u,type:"audio",nb:c}))}},{key:"remuxID3",value:function(r,a){var t,i=r.samples.length;if(i){for(var n=0;i>n;n++)t=r.samples[n],t.pts=(t.pts-this._initPTS)/this.PES_TIMESCALE,t.dts=(t.dts-this._initDTS)/this.PES_TIMESCALE;this.observer.trigger(e.default.FRAG_PARSING_METADATA,{samples:r.samples})}r.samples=[],a=a}},{key:"remuxText",value:function(t,a){t.samples.sort(function(e,t){return e.pts-t.pts});var r,i=t.samples.length;if(i){for(var n=0;i>n;n++)r=t.samples[n],r.pts=(r.pts-this._initPTS)/this.PES_TIMESCALE;this.observer.trigger(e.default.FRAG_PARSING_USERDATA,{samples:t.samples})}t.samples=[],a=a}},{key:"_PTSNormalize",value:function(e,t){var r;if(void 0===t)return e;for(r=e>t?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}},{key:"passthrough",get:function(){return!1}},{key:"timescale",get:function(){return this.MP4_TIMESCALE}}]),n}();a.default=d},{"../errors":19,"../events":21,"../remux/mp4-generator":28,"../utils/logger":34}],30:[function(r,l,e){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var s=r("../events"),t=n(s),o=function(){function e(t){a(this,e),this.observer=t,this.ISGenerated=!1}return i(e,[{key:"destroy",value:function(){}},{key:"insertDiscontinuity",value:function(){}},{key:"switchLevel",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(o,s,f,d,a,u){var i=this.observer;if(!this.ISGenerated){var l={},n={tracks:l,unique:!0},e=s,r=e.codec;r&&(n.tracks.video={container:e.container,codec:r,metadata:{width:e.width,height:e.height}}),e=o,r=e.codec,r&&(n.tracks.audio={container:e.container,codec:r,metadata:{channelCount:e.channelCount}}),this.ISGenerated=!0,i.trigger(t.default.FRAG_PARSING_INIT_SEGMENT,n)}i.trigger(t.default.FRAG_PARSING_DATA,{data1:u,startPTS:a,startDTS:a,type:"audiovideo",nb:1})}},{key:"passthrough",get:function(){return!0}},{key:"timescale",get:function(){return 0}}]),e}();e.default=o},{"../events":21}],31:[function(a,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(r){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r));for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n])}return r(e,[{key:"decimalInteger",value:function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"hexadecimalInteger",value:function(r){if(this[r]){var e=(this[r]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var n=new Uint8Array(e.length/2),t=0;t<e.length/2;t++)n[t]=parseInt(e.slice(2*t,2*t+2),16);return n}return null}},{key:"hexadecimalIntegerAsNumber",value:function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(t){var e=/^(\d+)x(\d+)$/.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}}],[{key:"parseAttrList",value:function(a){for(var t,i=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,r={};null!==(t=i.exec(a));){var e=t[2],n='"';0===e.indexOf(n)&&e.lastIndexOf(n)===e.length-1&&(e=e.slice(1,-1)),r[t[1]]=e}return r}}]),e}();e.default=n},{}],32:[function(r,e,n){"use strict";var t={search:function(a,s){for(var t=0,r=a.length-1,e=null,n=null;r>=t;){e=(t+r)/2|0,n=a[e];var i=s(n);if(i>0)t=e+1;else{if(!(0>i))return n;r=e-1}}return null}};e.exports=t},{}],33:[function(a,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(){t(this,e)}return r(e,[{key:"attach",value:function(e){this.media=e,this.display=[],this.memory=[]}},{key:"detach",value:function(){this.clear()}},{key:"destroy",value:function(){}},{key:"_createCue",value:function(){var t=window.VTTCue||window.TextTrackCue,e=this.cue=new t(-1,-1,"");e.text="",e.pauseOnExit=!1,e.startTime=Number.MAX_VALUE,e.endTime=Number.MAX_VALUE,this.memory.push(e)}},{key:"clear",value:function(){var e=this._textTrack;if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}},{key:"push",value:function(r,n){this.cue||this._createCue();for(var a,t,e,s,o,u=31&n[0],i=2,l=0;u>l;l++)if(a=n[i++],t=127&n[i++],e=127&n[i++],s=0===(4&a)?!1:!0,o=3&a,(0!==t||0!==e)&&s&&0===o){if(32&t||64&t)this.cue.text+=this._fromCharCode(t)+this._fromCharCode(e);else if((17===t||25===t)&&e>=48&&63>=e)switch(e){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===t||25===t)&&e>=32&&47>=e)switch(e){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===t||28===t)&&e>=32&&47>=e)switch(e){case 32:this._clearActiveCues(r);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(r);break;case 42:break;case 43:break;case 44:this._clearActiveCues(r);break;case 45:break;case 46:this._text="";break;case 47:this._flipMemory(r)}if((23===t||31===t)&&e>=33&&35>=e)switch(e){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(s){this._has708||(this._textTrack=this.media.addTextTrack("captions","English","en"),this._has708=!0);var e=!0,n=!1,a=void 0;try{for(var i,t=this.memory[Symbol.iterator]();!(e=(i=t.next()).done);e=!0){var r=i.value;r.startTime=s,this._textTrack.addCue(r),this.display.push(r)}}catch(e){n=!0,a=e}finally{try{!e&&t.return&&t.return()}finally{if(n)throw a}}this.memory=[],this.cue=null}},{key:"_clearActiveCues",value:function(i){var e=!0,r=!1,n=void 0;try{for(var a,t=this.display[Symbol.iterator]();!(e=(a=t.next()).done);e=!0){var s=a.value;s.endTime=i}}catch(e){r=!0,n=e}finally{try{!e&&t.return&&t.return()}finally{if(r)throw n}}this.display=[]}},{key:"_clearBufferedCues",value:function(){}}]),e}();e.default=n},{}],34:[function(l,u,r){"use strict";function e(){}function a(t,e){return e="["+t+"] > "+e}function i(t){var r=window.console[t];return r?function(){for(var i=arguments.length,e=Array(i),n=0;i>n;n++)e[n]=arguments[n];e[0]&&(e[0]=a(t,e[0])),r.apply(window.console,e)}:e}function s(r){for(var n=arguments.length,a=Array(n>1?n-1:0),e=1;n>e;e++)a[e-1]=arguments[e];a.forEach(function(e){t[e]=r[e]?r[e].bind(r):i(e)})}var o="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};Object.defineProperty(r,"__esModule",{value:!0});var n={trace:e,debug:e,log:e,warn:e,info:e,error:e},t=n;r.enableLogs=function(e){if(e===!0||"object"===("undefined"==typeof e?"undefined":o(e))){s(e,"debug","log","info","warn","error");try{t.log()}catch(e){t=n}}else t=n},r.logger=t},{}],35:[function(r,t,n){"use strict";var e={buildAbsoluteURL:function(r,t){if(t=t.trim(),/^[a-z]+:/i.test(t))return t;var o=null,a=null,i=/^([^#]*)(.*)$/.exec(t);i&&(a=i[2],t=i[1]);var s=/^([^\?]*)(.*)$/.exec(t);s&&(o=s[2],t=s[1]);var f=/^([^#]*)(.*)$/.exec(r);f&&(r=f[1]);var u=/^([^\?]*)(.*)$/.exec(r);u&&(r=u[1]);var l=/^((([a-z]+):)?\/\/[a-z0-9\.-]+(:[0-9]+)?\/)(.*)$/i.exec(r),h=l[3],d=l[1],c=l[5],n=null;return n=/^\/\//.test(t)?h+"://"+e.buildAbsolutePath("",t.substring(2)):/^\//.test(t)?d+e.buildAbsolutePath("",t.substring(1)):e.buildAbsolutePath(d+c,t),o&&(n+=o),a&&(n+=a),n},buildAbsolutePath:function(i,s){for(var n,e,o=s,a="",t=i.replace(/[^\/]*$/,o.replace(/(\/|^)(?:\.?\/+)+/g,"$1")),r=0;e=t.indexOf("/../",r),e>-1;r=e+n)n=/^\/(?:\.\.\/)*/.exec(t.slice(e))[0].length,a=(a+t.substring(r,e)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(n-1)/3+"}$"),"/");return a+t.substr(r)}};t.exports=e},{}],36:[function(r,s,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(e){n(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return a(t,[{key:"destroy",value:function(){this.abort(),this.loader=null}},{key:"abort",value:function(){var e=this.loader,t=this.timeoutHandle;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),t&&window.clearTimeout(t)}},{key:"load",value:function(r,n,a,i,s,t,o,l){var u=arguments.length<=8||void 0===arguments[8]?null:arguments[8],e=arguments.length<=9||void 0===arguments[9]?null:arguments[9];this.url=r,!e||isNaN(e.byteRangeStartOffset)||isNaN(e.byteRangeEndOffset)||(this.byteRange=e.byteRangeStartOffset+"-"+(e.byteRangeEndOffset-1)),this.responseType=n,this.onSuccess=a,this.onProgress=u,this.onTimeout=s,this.onError=i,this.stats={trequest:performance.now(),retry:0},this.timeout=t,this.maxRetry=o,this.retryDelay=l,this.timeoutHandle=window.setTimeout(this.loadtimeout.bind(this),t),this.loadInternal()}},{key:"loadInternal",value:function(){var e;e="undefined"!=typeof XDomainRequest?this.loader=new XDomainRequest:this.loader=new XMLHttpRequest,e.onloadend=this.loadend.bind(this),e.onprogress=this.loadprogress.bind(this),e.open("GET",this.url,!0),this.byteRange&&e.setRequestHeader("Range","bytes="+this.byteRange),e.responseType=this.responseType,this.stats.tfirst=null,this.stats.loaded=0,this.xhrSetup&&this.xhrSetup(e,this.url),e.send()}},{key:"loadend",value:function(n){var a=n.currentTarget,r=a.status,t=this.stats;t.aborted||(r>=200&&300>r?(window.clearTimeout(this.timeoutHandle),t.tload=performance.now(),this.onSuccess(n,t)):t.retry<this.maxRetry?(e.logger.warn(r+" while loading "+this.url+", retrying in "+this.retryDelay+"..."),this.destroy(),window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,64e3),t.retry++):(window.clearTimeout(this.timeoutHandle),e.logger.error(r+" while loading "+this.url),this.onError(n)))}},{key:"loadtimeout",value:function(t){e.logger.warn("timeout while loading "+this.url),this.onTimeout(t,this.stats)}},{key:"loadprogress",value:function(t){var e=this.stats;null===e.tfirst&&(e.tfirst=performance.now()),e.loaded=t.loaded,this.onProgress&&this.onProgress(t,e)}}]),t}();t.default=i},{"../utils/logger":34}]},{},[24])(24)});