/*! hlsjs engine plugin for Flowplayer HTML5 Copyright (c) 2015-2016, Flowplayer Oy Released under the MIT License: http://www.opensource.org/licenses/mit-license.php Includes hls.js Copyright (c) 2015 Dailymotion (http://www.dailymotion.com) https://github.com/dailymotion/hls.js/blob/master/LICENSE Includes es5.js https://github.com/inexorabletash/polyfill/blob/master/es5.js for compatibility with legacy browsers Requires Flowplayer HTML5 version 6.x revision: 13bd2db */ !function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){r(41),e.exports=r(9)},function(e,t){"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"}},function(e,t){"use strict";function r(){}function n(e,t){return t="["+e+"] > "+t}function i(e){var t=window.console[e];return t?function(){for(var r=arguments.length,i=Array(r),a=0;r>a;a++)i[a]=arguments[a];i[0]&&(i[0]=n(e,i[0])),t.apply(window.console,i)}:r}function a(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];r.forEach(function(t){u[t]=e[t]?e[t].bind(e):i(t)})}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(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":"undefined"==typeof e?"undefined":o(e)},l={trace:r,debug:r,log:r,warn:r,info:r,error:r},u=l;t.enableLogs=function(e){if(e===!0||"object"===("undefined"==typeof e?"undefined":s(e))){a(e,"debug","log","info","warn","error");try{u.log()}catch(t){u=l}}else u=l},t.logger=u},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",OTHER_ERROR:"otherError"},t.ErrorDetails={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",INTERNAL_EXCEPTION:"internalException"}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a="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(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"===a(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":a(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":"undefined"==typeof e?"undefined":a(e)},s=function(){function e(e,t){for(var r=0;r1?r-1:0),a=1;r>a;a++)n[a-1]=arguments[a];this.handledEvents=n,this.useGenericHandler=!0,this.registerListeners()}return s(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{key:"isEventHandler",value:function(){return"object"===o(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(e,t){var r="on"+e.replace("hls","");if("function"!=typeof this[r])throw new Error("Event "+e+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,t)};try{r.call(this,e,t).call()}catch(n){l.logger.error("internal error happened while processing "+e+":"+n.message),this.hls.trigger(d["default"].ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,err:n})}}}]),e}();t["default"]=c},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r>>6)+1,s=(60&t[r+2])>>>2,s>c.length-1?void e.trigger(Event.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s}):(u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,a.logger.log("manifest codec:"+n+",ADTS data:type:"+i+",sampleingIndex:"+s+"["+c[s]+"Hz],channelConfig:"+u),-1!==d.indexOf("firefox")?s>=6?(i=5,f=new Array(4),l=s-3):(i=2,f=new Array(2),l=s):-1!==d.indexOf("android")?(i=2,f=new Array(2),l=s):(i=5,f=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&s>=6?l=s-3:((n&&-1!==n.indexOf("mp4a.40.2")&&s>=6&&1===u||!n&&1===u)&&(i=2,f=new Array(2)),l=s)),f[0]=i<<3,f[0]|=(14&s)>>1,f[1]|=(1&s)<<7,f[1]|=u<<3,5===i&&(f[1]|=(14&l)>>1,f[2]=(1&l)<<7,f[2]|=8,f[3]=0),{config:f,samplerate:c[s],channelCount:u,codec:"mp4a.40."+i})}}]),e}();t["default"]=s},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;rf&&(l[u-1].end=e[s].end):l.push(e[s])}else l.push(e[s])}for(s=0,n=0,i=a=t;s=d&&c>t)i=d,a=c,n=a-t;else if(d>t+r){o=d;break}}return{len:n,start:i,end:a,nextStart:o}}}]),e}();t["default"]=i},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function i(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,i,s,l,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],o(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(a(r))for(s=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,l=0;i>l;l++)u[l].apply(this,s);return!0},r.prototype.addListener=function(e,t){var i;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(i=o(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,i,o,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],o=r.length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(r)){for(s=o;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){(function(e,t){"use strict";var r,n="hlsjs",i=e.common,a=e.extend,o=e.support,s=e.version,l=function(e){return e.toLowerCase().indexOf("mpegurl")>-1},u=function(e){var t=e.clip.hlsQualities||e.hlsQualities;return o.inlineVideo&&(t===!0||t&&t.length)},f=function(o,f){var d,c,h,p,v,g=e.bean,y=function(e){var t=e.startLevel;switch(t){case"auto":t=-1;break;case"firstLevel":t=void 0}return t},m="active",b=function(e){return e||(e=o.quality),e.toLowerCase().replace(/\ /g,"")},E=function(){var e=o.qualities;e&&e.length&&(i.removeClass(f,"quality-abr"),e.forEach(function(e){i.removeClass(f,"quality-"+b(e))}))},_=function(){delete o.hlsQualities,E(),i.find(".fp-quality-selector",f).forEach(i.removeNode)},R=function(){return o.hlsQualities[o.qualities.indexOf(o.quality)+1]},A=function(e,t,r){var a,s=r.levels,l=0;_(),o.hlsQualities=[],s.forEach(function(t){(e===!0||e.indexOf(l)>-1)&&(!t.videoCodec||t.videoCodec&&window.MediaSource.isTypeSupported("video/mp4;codecs="+t.videoCodec))&&o.hlsQualities.push(l),l+=1}),o.hlsQualities.length<2||(o.qualities=[],o.hlsQualities.forEach(function(e){var t=s[e],r=t.width,n=t.height,i=r&&n?Math.min(r,n)+"p":"Level "+(e+1);o.qualities.push(i)}),a=i.createElement("ul",{"class":"fp-quality-selector"}),i.find(".fp-ui",f)[0].appendChild(a),o.hlsQualities.unshift(-1),!o.quality||o.qualities.indexOf(o.quality)<0?(c.startLevel=y(t),o.quality="abr"):(c.startLevel=R(),c.loadLevel=c.startLevel),a.appendChild(i.createElement("li",{"data-quality":"abr"},"Auto")),o.qualities.forEach(function(e){a.appendChild(i.createElement("li",{"data-quality":b(e)},e))}),i.addClass(f,"quality-"+b()),g.on(f,"click."+n,".fp-quality-selector li",function(e){var r,a,s,l=e.currentTarget,u=t.smoothSwitching,h=d.paused;if(!i.hasClass(l,m)){for(h||u||g.one(d,"pause."+n,function(){i.removeClass(f,"is-paused")}),r=i.find(".fp-quality-selector li",f),s=0;s0?o.qualities[s-1]:"abr",u?c.nextLevel=R():c.currentLevel=R(),i.addClass(l,m),h&&d.play()),i.toggleClass(r[s],m,a);E(),i.addClass(f,"quality-"+b())}}))},S={engineName:n,pick:function(e){var t,r;for(t=0;t video",f)[0]),d=i.createElement("video",{"class":"fp-engine "+n+"-engine",autoplay:v?"autoplay":!1,preload:s.clip.preload||"metadata","x-webkit-airplay":"allow"}),Object.keys(l).forEach(function(t){var r,u=l[t],c=t+"."+n;g.on(d,c,function(t){if(s.debug&&u.indexOf("progress")<0&&console.log(c,"->",u,t.originalEvent),o.ready||!(u.indexOf("ready")<0)){var n,l,h,p,v=0,g=0,y=o.quality;switch(u){case"ready":r=a(o.video,{duration:d.duration,seekable:d.seekable.end(null),width:d.videoWidth,height:d.videoHeight,url:o.video.src});break;case"resume":o.poster&&(o.poster=!1,i.removeClass(f,b));break;case"seek":case"progress":r=d.currentTime;break;case"speed":r=d.playbackRate;break;case"volume":r=d.volume;break;case"buffer":try{if(n=d.currentTime,l=d.buffered,v=l.end(null),n)for(h=l.length-1;h>-1;h-=1)g=l.end(h),g>=n&&(v=g)}catch(E){}e.buffer=v,r=t}o.trigger(u,[o,r]),"ready"===u&&y&&(p="abr"===y?0:o.qualities.indexOf(y)+1,i.addClass(i.find(".fp-quality-selector li",f)[p],m))}})}),_.adaptOnStartOnly&&g.one(d,"timeupdate."+n,function(){c.loadLevel=c.loadLevel}),s.poster&&o.on("stop."+n,function(){g.one(d,"timeupdate."+n,function(){o.poster=!0,i.addClass(f,b)})}),o.on("error."+n,function(){c&&(c.destroy(),c=0)}),i.prepend(i.find(".fp-player",f)[0],d)),o.video=e,S.forEach(function(e){var t=_[e];switch(delete R[e],e){case"adaptOnStartOnly":t&&(_.startLevel=-1);break;case"autoLevelCapping":t===!1&&(t=-1),R[e]=t;break;case"recover":h=_.strict?0:t}}),R.autoStartLoad=!1,c=new t(R),o.engine[n]=c,c.startLevel=y(_),Object.keys(p).forEach(function(r){var n=p[r],i=_.listeners,l=i&&i.indexOf(n)>-1;c.on(n,function(n,i){var f,d={},p=o.video.src;switch(r){case"MEDIA_ATTACHED":c.loadSource(p);break;case"MANIFEST_PARSED":u(s)?A(E,_,i):delete o.quality,c.startLoad();break;case"ERROR":if(i.fatal||_.strict){switch(i.type){case t.ErrorTypes.NETWORK_ERROR:h?(c.startLoad(),h>0&&(h-=1)):i.frag&&i.frag.url?(d.url=i.frag.url,f=2):f=4;break;case t.ErrorTypes.MEDIA_ERROR:h?(c.recoverMediaError(),h>0&&(h-=1)):f=3;break;default:f=5}void 0!==f&&(d.code=f,f>2&&(d.video=a(e,{src:p,url:i.url||p})),o.trigger("error",[o,d]))}}l&&o.trigger(n,[o,i])})}),c.attachMedia(d),d.paused&&v&&d.play()},resume:function(){d.play()},pause:function(){d.pause()},seek:function(e){d.currentTime=e},volume:function(e){d&&(d.volume=e)},speed:function(e){d.playbackRate=e,o.trigger("speed",[o,e])},unload:function(){if(c){var e="."+n;c.destroy(),c=0,_(),o.off(e),g.off(f,e),g.off(d,e),i.removeNode(d),d=0}}};return!/^6\.0\.[0-3]$/.test(s)||o.conf.splash||o.conf.poster||o.conf.autoplay||(p=i.css(f,"backgroundColor"),v="none"!==i.css(f,"backgroundImage")||p&&"rgba(0, 0, 0, 0)"!==p&&"transparent"!==p,v&&(o.conf.poster=!0)),S};t.isSupported()&&0!==s.indexOf("5.")&&(f.engineName=n,f.canPlay=function(t,i){var s=o.browser,u=window.navigator,f=u.userAgent.indexOf("Trident/7")>-1;return i[n]===!1||i.clip[n]===!1?!1:(r=a({smoothSwitching:!0,recover:0},e.conf[n],i[n],i.clip[n]),l(t)?r.debug?!0:r.anamorphic&&0===u.platform.indexOf("Win")&&s.mozilla&&0===s.version.indexOf("44.")?!1:f||!s.safari:!1)},e.engines.unshift(f),e(function(e){e.pluginQualitySelectorEnabled=u(e.conf)&&f.canPlay("application/x-mpegurl",e.conf)}))}).apply(null,"object"==typeof e&&e.exports?[r(43),r(28)]:[window.flowplayer,window.Hls])},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="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(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;r500*r.duration){var i=e.levels,a=Math.max(1,1e3*r.loaded/n),o=Math.max(r.loaded,Math.round(r.duration*i[r.level].bitrate/8)),s=t.currentTime,l=(o-r.loaded)/a,u=p["default"].bufferInfo(t,s,e.config.maxBufferHole).end-s;if(u<2*r.duration&&l>u){var d=void 0,c=void 0;for(c=r.level-1;c>=0&&(d=r.duration*i[c].bitrate/(6.4*a),g.logger.log("fragLoadedDelay/bufferStarvationDelay/fragLevelNextLoadedDelay["+c+"] :"+l.toFixed(1)+"/"+u.toFixed(1)+"/"+d.toFixed(1)),!(u>d));c--);l>d&&(c=Math.max(0,c),e.nextLoadLevel=c,this.bwEstimator.sample(n,r.loaded),g.logger.warn("loading too slow, abort fragment loading and switch to level "+c),r.loader.abort(),this.clearTimer(),e.trigger(f["default"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:r}))}}}}},{key:"onFragLoaded",value:function(e){var t=e.stats;void 0===t.aborted&&1===e.frag.loadCounter&&this.bwEstimator.sample(performance.now()-t.trequest,t.loaded),this.clearTimer(),this.lastLoadedFragLevel=e.frag.level,this._nextAutoLevel=-1}},{key:"onError",value:function(e){switch(e.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping=e}},{key:"nextAutoLevel",get:function(){var e,t,r=this.hls,n=r.levels,i=r.config;if(t=-1===this._autoLevelCapping&&n&&n.length?n.length-1:this._autoLevelCapping,-1!==this._nextAutoLevel)return Math.min(this._nextAutoLevel,t);var a=this.bwEstimator.getEstimate(),o=void 0;for(e=0;t>=e;e++)if(o=e<=this.lastLoadedFragLevel?i.abrBandWidthFactor*a:i.abrBandWidthUpFactor*a,othis._msDuration&&(h.logger.log("Updating mediasource duration to "+this._levelDuration),t.duration=this._levelDuration,this._msDuration=this._levelDuration)}}}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;if(r)for(var n in r)t+=r[n].buffered.length;this.appended=t,this.hls.trigger(f["default"].BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.sourceBuffer,r=this.segments;if(t){if(this.media.error)return r=[],void h.logger.error("trying to append although a media error occured, flush segment and abort");for(var n in t)if(t[n].updating)return;if(r.length){var i=r.shift();try{t[i.type].appendBuffer(i.data),this.appendError=0,this.appended++}catch(a){h.logger.error("error while trying to append buffer:"+a.message),r.unshift(i);var o={type:p.ErrorTypes.MEDIA_ERROR};if(22!==a.code){if(this.appendError?this.appendError++:this.appendError=1,o.details=p.ErrorDetails.BUFFER_APPEND_ERROR,o.frag=this.fragCurrent,this.appendError>e.config.appendErrorMaxRetry)return h.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],o.fatal=!0,void e.trigger(f["default"].ERROR,o);o.fatal=!1,e.trigger(f["default"].ERROR,o)}else r=[],o.details=p.ErrorDetails.BUFFER_FULL_ERROR,e.trigger(f["default"].ERROR,o)}}}}},{key:"flushBuffer",value:function(e,t){var r,n,i,a,o,s;if(this.flushBufferCounter.5)return this.flushBufferCounter++,h.logger.log("flush "+l+" ["+o+","+s+"], of ["+i+","+a+"], pos:"+this.media.currentTime),r.remove(o,s),!1}else h.logger.warn("abort flushing too many retries");return h.logger.log("buffer flushed"),!0}}]),t}(c["default"]);t["default"]=v},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{ value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="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(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;rthis.autoLevelCapping&&this.hls.streamController.nextLevelSwitch(),this.autoLevelCapping=this.hls.autoLevelCapping)}}},{key:"getMaxLevel",value:function(e){var t=void 0,r=void 0,n=void 0,i=this.mediaWidth,a=this.mediaHeight,o=0,s=0;for(r=0;e>=r&&(n=this.levels[r],t=r,o=n.width,s=n.height,!(o>=i||s>=a));r++);return t}},{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(t){}return e}},{key:"mediaWidth",get:function(){var e=void 0;return this.media&&(e=this.media.width||this.media.clientWidth||this.media.offsetWidth,e*=this.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e=void 0;return this.media&&(e=this.media.height||this.media.clientHeight||this.media.offsetHeight,e*=this.contentScaleFactor),e}}]),t}(c["default"]);t["default"]=h},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r=0&&ee&&(this._level===e&&void 0!==t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,void 0===this._startLevel&&(this._startLevel=e),-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}},{key:"nextLoadLevel",get:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.abrController.nextAutoLevel},set:function(e){this.level=e,-1===this._manualLevel&&(this.hls.abrController.nextAutoLevel=e)}}]),t}(c["default"]);t["default"]=v},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="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(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){var e,t,r,n=this.hls,i=n.config,a=this.media,o=a&&a.seeking;switch(this.state){case A.ERROR:case A.PAUSED:break;case A.STARTING:var s=n.startLevel;-1===s&&(s=0,this.fragBitrateTest=!0),this.level=n.nextLoadLevel=s,this.state=A.WAITING_LEVEL,this.loadedmetadata=!1;break;case A.IDLE:if(!a&&(this.startFragRequested||!i.startFragPrefetch))break;e=this.loadedmetadata?a.currentTime:this.nextLoadPosition,t=n.nextLoadLevel;var l,u=b["default"].bufferInfo(a,e,i.maxBufferHole),f=u.len,d=u.end,h=this.fragPrevious;if(this.levels[t].hasOwnProperty("bitrate")?(l=Math.max(8*i.maxBufferSize/this.levels[t].bitrate,i.maxBufferLength),l=Math.min(l,i.maxMaxBufferLength)):l=i.maxBufferLength,l>f){if(n.nextLoadLevel=t,this.level=t,r=this.levels[t].details,"undefined"==typeof r||r.live&&this.levelLastLoaded!==t){this.state=A.WAITING_LEVEL;break}var p=r.fragments,g=p.length,m=p[0].start,E=p[g-1].start+p[g-1].duration,_=void 0;if(r.live){var S=void 0!==i.liveMaxLatencyDuration?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*r.targetduration;if(dL&&(a.currentTime=L)}if(r.PTSKnown&&d>E)break;if(this.startFragRequested&&!r.PTSKnown){if(h){var k=h.sn+1;k>=r.startSN&&k<=r.endSN&&(_=p[k-r.startSN],v.logger.log("live playlist, switching playlist, load frag with next SN: "+_.sn))}_||(_=p[Math.min(g-1,Math.round(g/2))],v.logger.log("live playlist, switching playlist, unknown, load middle frag : "+_.sn))}}else m>d&&(_=p[0]);if(_||!function(){var e=i.maxFragLookUpTolerance;E>d?((d>E-e||o)&&(e=0),_=y["default"].search(p,function(t){return t.start+t.duration-e<=d?1:t.start-e>d?-1:0})):_=p[g-1]}(),_){if(m=_.start,h&&_.level===h.level&&_.sn===h.sn){if(!(_.snw&&Math.abs(this.fragLoadIdx-_.loadIdx)=D||o)&&(v.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=A.IDLE);break;case A.STOPPED:case A.FRAG_LOADING:case A.PARSING:case A.PARSED:case A.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"getBufferRange",value:function(e){var t,r,n=this.bufferRange;if(n)for(t=n.length-1;t>=0;t--)if(r=n[t],e>=r.start&&e<=r.end)return r;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(e){var t=this.media;if(t)for(var r=t.buffered,n=0;n=r.start(n)&&e<=r.end(n))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var e,t,r=this.media;if(r&&r.seeking===!1&&(t=r.currentTime,t>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=t),this.isBuffered(t)?e=this.getBufferRange(t):this.isBuffered(t+.1)&&(e=this.getBufferRange(t+.1)),e)){var n=e.frag;n!==this.fragPlaying&&(this.fragPlaying=n,this.hls.trigger(c["default"].FRAG_CHANGED,{frag:n}))}}},{key:"immediateLevelSwitch",value:function(){v.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,this.previouslyPaused=this.media.paused,this.media.pause());var e=this.fragCurrent;e&&e.loader&&e.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=A.PAUSED,this.hls.trigger(c["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY})}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1;var e=this.media;e&&e.readyState&&(e.currentTime-=1e-4,this.previouslyPaused||e.play())}},{key:"nextLevelSwitch",value:function(){var e=this.media;if(e&&e.readyState){var t=void 0,r=void 0,n=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferRange(e.currentTime),r&&r.start>1&&(this.state=A.PAUSED,this.hls.trigger(c["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:r.start-1})),e.paused)t=0;else{var i=this.hls.nextLoadLevel,a=this.levels[i],o=this.fragLastKbps;t=o&&this.fragCurrent?this.fragCurrent.duration*a.bitrate/(1e3*o)+1:0}if(n=this.getBufferRange(e.currentTime+t),n&&(n=this.followingBufferRange(n))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.state=A.PAUSED,this.hls.trigger(c["default"].BUFFER_FLUSHING,{startOffset:n.start,endOffset:Number.POSITIVE_INFINITY})}}}},{key:"onMediaAttached",value:function(e){var t=this.media=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended),this.levels&&this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(v.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void 0})}),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeking",value:function(){if(this.state===A.FRAG_LOADING){if(0===b["default"].bufferInfo(this.media,this.media.currentTime,this.config.maxBufferHole).len){v.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=A.IDLE}}else this.state===A.ENDED&&(this.state=A.IDLE);this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){this.tick()}},{key:"onMediaEnded",value:function(){v.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){v.logger.log("trigger BUFFER_RESET"),this.hls.trigger(c["default"].BUFFER_RESET),this.bufferRange=[],this.stalled=!1}},{key:"onManifestParsed",value:function(e){var t,r=!1,n=!1;e.levels.forEach(function(e){t=e.audioCodec,t&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(n=!0))}),this.audioCodecSwitch=r&&n,this.audioCodecSwitch&&v.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startLevelLoaded=!1,this.startFragRequested=!1,this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,n=this.levels[r],i=t.totalduration,a=0;if(v.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),this.levelLastLoaded=r,t.live){var o=n.details;o?(_["default"].mergeDetails(o,t),a=t.fragments[0].start,t.PTSKnown?v.logger.log("live playlist sliding:"+a.toFixed(3)):v.logger.log("live playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,v.logger.log("live playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(n.details=t,this.hls.trigger(c["default"].LEVEL_UPDATED,{details:t,level:r}),this.startFragRequested===!1){if(t.live){var s=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;this.startPosition=Math.max(0,a+i-s)}this.nextLoadPosition=this.startPosition}this.state===A.WAITING_LEVEL&&(this.state=A.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===A.KEY_LOADING&&(this.state=A.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent;if(this.state===A.FRAG_LOADING&&t&&e.frag.level===t.level&&e.frag.sn===t.sn)if(v.logger.log("Loaded "+t.sn+" of level "+t.level),this.fragBitrateTest===!0)this.state=A.IDLE,this.fragBitrateTest=!1,this.startFragRequested=!1,e.stats.tparsed=e.stats.tbuffered=performance.now(),this.hls.trigger(c["default"].FRAG_BUFFERED,{stats:e.stats,frag:t});else{this.state=A.PARSING,this.stats=e.stats;var r=this.levels[this.level],n=r.details,i=n.totalduration,a=void 0!==t.startDTS?t.startDTS:t.start,o=t.level,s=t.sn,l=r.audioCodec||this.config.defaultAudioCodec;this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),void 0===l&&(l=this.lastAudioCodec),l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingAppending=0,v.logger.log("Demuxing "+s+" of ["+n.startSN+" ,"+n.endSN+"],level "+o);var u=this.demuxer;u&&u.push(e.payload,l,r.videoCodec,a,t.cc,o,s,i,t.decryptdata)}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){if(this.state===A.PARSING){var t,r,n=e.tracks;if(r=n.audio){var i=this.levels[this.level].audioCodec,a=navigator.userAgent.toLowerCase();i&&this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==r.metadata.channelCount&&-1===a.indexOf("firefox")&&(i="mp4a.40.5"),-1!==a.indexOf("android")&&(i="mp4a.40.2",v.logger.log("Android: force audio codec to"+i)),r.levelCodec=i}if(r=n.video,r&&(r.levelCodec=this.levels[this.level].videoCodec),e.unique){var o={codec:"",levelCodec:""};for(t in e.tracks)r=n[t],o.container=r.container,o.codec&&(o.codec+=",",o.levelCodec+=","),r.codec&&(o.codec+=r.codec),r.levelCodec&&(o.levelCodec+=r.levelCodec);n={audiovideo:o}}this.hls.trigger(c["default"].BUFFER_CODECS,n);for(t in n){r=n[t],v.logger.log("track:"+t+",container:"+r.container+",codecs[level/parsed]=["+r.levelCodec+"/"+r.codec+"]");var s=r.initSegment;s&&(this.pendingAppending++,this.hls.trigger(c["default"].BUFFER_APPENDING,{type:t,data:s}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this;if(this.state===A.PARSING){this.tparse2=Date.now();var r=this.levels[this.level],n=this.fragCurrent;v.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb);var i=_["default"].updateFragPTSDTS(r.details,n.sn,e.startPTS,e.endPTS,e.startDTS,e.endDTS),a=this.hls;a.trigger(c["default"].LEVEL_PTS_UPDATED,{details:r.details,level:this.level,drift:i}),[e.data1,e.data2].forEach(function(r){r&&(t.pendingAppending++,a.trigger(c["default"].BUFFER_APPENDING,{type:e.type,data:r}))}),this.nextLoadPosition=e.endPTS,this.bufferRange.push({type:e.type,start:e.startPTS,end:e.endPTS,frag:n}),this.tick()}else v.logger.warn("not in PARSING state but "+this.state+", ignoring FRAG_PARSING_DATA event")}},{key:"onFragParsed",value:function(){this.state===A.PARSING&&(this.stats.tparsed=performance.now(),this.state=A.PARSED,this._checkAppendedParsed())}},{key:"onBufferAppended",value:function(){switch(this.state){case A.PARSING:case A.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===A.PARSED&&0===this.pendingAppending){var e=this.fragCurrent,t=this.stats;e&&(this.fragPrevious=e,t.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*t.length/(t.tbuffered-t.tfirst)),this.hls.trigger(c["default"].FRAG_BUFFERED,{stats:t,frag:e}),v.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=A.IDLE),this.tick()}}},{key:"onError",value:function(e){switch(e.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!e.fatal){var t=this.fragLoadError;if(t?t++:t=1,t<=this.config.fragLoadingMaxRetry){this.fragLoadError=t,e.frag.loadCounter=0;var r=Math.min(Math.pow(2,t-1)*this.config.fragLoadingRetryDelay,64e3);v.logger.warn("mediaController: frag loading failed, retry in "+r+" ms"),this.retryDate=performance.now()+r,this.state=A.FRAG_LOADING_WAITING_RETRY}else v.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.trigger(c["default"].ERROR,e),this.state=A.ERROR}break;case R.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case R.ErrorDetails.LEVEL_LOAD_ERROR:case R.ErrorDetails.LEVEL_LOAD_TIMEOUT:case R.ErrorDetails.KEY_LOAD_ERROR:case R.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==A.ERROR&&(this.state=e.fatal?A.ERROR:A.IDLE,v.logger.warn("mediaController: "+e.details+" while loading frag,switch to "+this.state+" state ..."));break;case R.ErrorDetails.BUFFER_FULL_ERROR:this.config.maxMaxBufferLength/=2,v.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&&e.readyState){var t=e.currentTime,r=e.buffered;if(!this.loadedmetadata&&r.length){this.loadedmetadata=!0;var n=this.startPosition;if(!t&&t!==n&&n){v.logger.log("target start position:"+n);var i=r.start(0),a=r.end(0);(i>n||n>a)&&(n=i,v.logger.log("target start position not buffered, seek to buffered.start(0) "+i)),v.logger.log("adjust currentTime from "+t+" to "+n),e.currentTime=n}}else{var o=b["default"].bufferInfo(e,t,0),s=!(e.paused||e.ended||0===e.buffered.length),l=.4,u=t>e.playbackRate*this.lastCurrentTime;if(this.stalled&&u&&(this.stalled=!1,v.logger.log("playback not stuck anymore @"+t)),s&&o.len<=l&&(u?(l=0,this.seekHoleNudgeDuration=0):this.stalled?this.seekHoleNudgeDuration+=this.config.seekHoleNudgeDuration:(this.seekHoleNudgeDuration=0,v.logger.log("playback seems stuck @"+t),this.hls.trigger(c["default"].ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0),o.len<=l)){var f=o.nextStart,d=f-t;if(f&&d0){v.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+f+" + nudge "+this.seekHoleNudgeDuration);var h=f+this.seekHoleNudgeDuration-e.currentTime;e.currentTime=f+this.seekHoleNudgeDuration,this.hls.trigger(c["default"].ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:h})}}}}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=A.IDLE,this.tick()}},{key:"onBufferFlushed",value:function(){var e,t,r=[];for(t=0;tn;n++)t+="["+e.start(n)+","+e.end(n)+"]";return t}},{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}}]),t}(p["default"]);t["default"]=S},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="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(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;re;e++)p[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!d[t];t^=n||1,r=p[r]||1)for(o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^255&o^99,d[t]=o,c[o]=t,a=h[i=h[n=h[t]]],l=16843009*a^65537*i^257*n^16843008*t,s=257*h[o]^16843008*o,e=0;4>e;e++)u[e][t]=s=s<<24^s>>>8,f[e][o]=l=l<<24^l>>>8;for(e=0;5>e;e++)u[e]=u[e].slice(0),f[e]=f[e].slice(0)}},{key:"decrypt",value:function(e,t,r,n,i,a){var o,s,l,u,f=this._key[1],d=e^f[0],c=n^f[1],h=r^f[2],p=t^f[3],v=f.length/4-2,g=4,y=this._tables[1],m=y[0],b=y[1],E=y[2],_=y[3],R=y[4];for(u=0;v>u;u++)o=m[d>>>24]^b[c>>16&255]^E[h>>8&255]^_[255&p]^f[g],s=m[c>>>24]^b[h>>16&255]^E[p>>8&255]^_[255&d]^f[g+1],l=m[h>>>24]^b[p>>16&255]^E[d>>8&255]^_[255&c]^f[g+2],p=m[p>>>24]^b[d>>16&255]^E[c>>8&255]^_[255&h]^f[g+3],g+=4,d=o,c=s,h=l;for(u=0;4>u;u++)i[(3&-u)+a]=R[d>>>24]<<24^R[c>>16&255]<<16^R[h>>8&255]<<8^R[255&p]^f[g++],o=d,d=c,c=h,h=p,p=o}}]),e}();t["default"]=i},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r>8|e>>>24}},{key:"doDecrypt",value:function(e,t,r){var n,i,a,o,l,u,f,d,c,h=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),p=new s["default"](Array.prototype.slice.call(t)),v=new Uint8Array(e.byteLength),g=new Int32Array(v.buffer);for(n=~~r[0],i=~~r[1],a=~~r[2],o=~~r[3],c=0;cv&&(255!==e[v]||240!==(240&e[v+1]));v++);for(E.audiosamplerate||(d=s["default"].getAudioConfig(this.observer,e,v,t),E.config=d.config,E.audiosamplerate=d.samplerate,E.channelCount=d.channelCount,E.codec=d.codec,E.duration=u,l.logger.log("parsed codec:"+E.codec+",rate:"+d.samplerate+",nb channel:"+d.channelCount)),p=0,h=9216e4/E.audiosamplerate;m>v+5&&(g=1&e[v+1]?7:9,c=(3&e[v+3])<<11|e[v+4]<<3|(224&e[v+5])>>>5,c-=g,c>0&&m>=v+g+c);)for(y=R+p*h,b={unit:e.subarray(v+g,v+g+c),pts:y,dts:y},E.samples.push(b),E.len+=c,v+=c+g,p++;m-1>v&&(255!==e[v]||240!==(240&e[v+1]));v++);this.remuxer.remux(this._aacTrack,{samples:[]},{samples:[{pts:R,dts:R,unit:_.payload}]},{samples:[]},n)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){var t,r,n=new f["default"](e);if(n.hasTimeStamp)for(t=n.length,r=e.length;r-1>t;t++)if(255===e[t]&&240===(240&e[t+1]))return!0;return!1}}]),e}();t["default"]=d},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(6),a=n(i),o=r(1),s=n(o),l=r(8),u=n(l),f=function(e){var t=new u["default"];t.trigger=function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;r>i;i++)n[i-1]=arguments[i];t.emit.apply(t,[e,e].concat(n))},t.off=function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;r>i;i++)n[i-1]=arguments[i];t.removeListener.apply(t,[e].concat(n))},e.addEventListener("message",function(r){var n=r.data;switch(n.cmd){case"init":e.demuxer=new a["default"](t,n.typeSupported);break;case"demux":e.demuxer.push(new Uint8Array(n.data),n.audioCodec,n.videoCodec,n.timeOffset,n.cc,n.level,n.sn,n.duration)}}),t.on(s["default"].FRAG_PARSING_INIT_SEGMENT,function(t,r){e.postMessage({event:t,tracks:r.tracks,unique:r.unique})}),t.on(s["default"].FRAG_PARSING_DATA,function(t,r){var n={event:t,type:r.type,startPTS:r.startPTS,endPTS:r.endPTS,startDTS:r.startDTS,endDTS:r.endDTS,data1:r.data1.buffer,data2:r.data2.buffer,nb:r.nb};e.postMessage(n,[n.data1,n.data2])}),t.on(s["default"].FRAG_PARSED,function(t){e.postMessage({event:t})}),t.on(s["default"].ERROR,function(t,r){e.postMessage({event:t,data:r})}),t.on(s["default"].FRAG_PARSING_METADATA,function(t,r){var n={event:t,samples:r.samples};e.postMessage(n)}),t.on(s["default"].FRAG_PARSING_USERDATA,function(t,r){var n={event:t,samples:r.samples};e.postMessage(n)})};t["default"]=f},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r0&&null!=l&&null!=l.key&&"AES-128"===l.method){null==this.decrypter&&(this.decrypter=new p["default"](this.hls));var u=this;this.decrypter.decrypt(e,l.key,l.iv,function(e){u.pushDecrypted(e,t,r,n,i,a,o,s)})}else this.pushDecrypted(e,t,r,n,i,a,o,s)}},{key:"onWorkerMessage",value:function(e){var t=e.data;switch(t.event){case s["default"].FRAG_PARSING_INIT_SEGMENT:var r={};r.tracks=t.tracks,r.unique=t.unique,this.hls.trigger(s["default"].FRAG_PARSING_INIT_SEGMENT,r);break;case s["default"].FRAG_PARSING_DATA:this.hls.trigger(s["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 s["default"].FRAG_PARSING_METADATA:this.hls.trigger(s["default"].FRAG_PARSING_METADATA,{samples:t.samples});break;case s["default"].FRAG_PARSING_USERDATA:this.hls.trigger(s["default"].FRAG_PARSING_USERDATA,{samples:t.samples});break;default:this.hls.trigger(t.event,t.data)}}}]),e}();t["default"]=v},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;re?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),t=e-t,t>0?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(e){var t,r,n=8,i=8;for(t=0;e>t;t++)0!==i&&(r=this.readEG(),i=(n+r+256)%256),n=0===i?n:i}},{key:"readSPS",value:function(){var e,t,r,n,i,a,o,s,l,u=0,f=0,d=0,c=0,h=1;if(this.readUByte(),e=this.readUByte(),t=this.readBits(5),this.skipBits(3),r=this.readUByte(),this.skipUEG(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var p=this.readUEG();if(3===p&&this.skipBits(1),this.skipUEG(),this.skipUEG(),this.skipBits(1),this.readBoolean())for(s=3!==p?8:12,l=0;s>l;l++)this.readBoolean()&&(6>l?this.skipScalingList(16):this.skipScalingList(64))}this.skipUEG();var v=this.readUEG();if(0===v)this.readUEG();else if(1===v)for(this.skipBits(1),this.skipEG(),this.skipEG(),n=this.readUEG(),l=0;n>l;l++)this.skipEG();if(this.skipUEG(),this.skipBits(1),i=this.readUEG(),a=this.readUEG(),o=this.readBits(1),0===o&&this.skipBits(1),this.skipBits(1),this.readBoolean()&&(u=this.readUEG(),f=this.readUEG(),d=this.readUEG(),c=this.readUEG()),this.readBoolean()&&this.readBoolean()){var g=void 0,y=this.readUByte();switch(y){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:g=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}g&&(h=g[0]/g[1])}return{width:Math.ceil((16*(i+1)-2*u-2*f)*h),height:(2-o)*(a+1)*16-(o?2:4)*(d+c)}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();t["default"]=o},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;ri);return n}},{key:"_parseID3Frames",value:function(e,t,r){for(var n,i,o,s,l;r>=t+8;)switch(n=this.readUTF(e,t,4),t+=4,i=e[t++]<<24+e[t++]<<16+e[t++]<<8+e[t++],s=e[t++]<<8+e[t++],o=t,n){case"PRIV":if("com.apple.streaming.transportStreamTimestamp"===this.readUTF(e,t,44)){t+=44,t+=4;var u=1&e[t++];this._hasTimeStamp=!0,l=((e[t++]<<23)+(e[t++]<<15)+(e[t++]<<7)+e[t++])/45,u&&(l+=47721858.84),l=Math.round(l),a.logger.trace("ID3 timestamp found: "+l),this._timeStamp=l}}}},{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}();t["default"]=o},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;rp;p+=188)if(71===e[p]){if(v=!!(64&e[p+1]),g=((31&e[p+1])<<8)+e[p+2],y=(48&e[p+3])>>4,y>1){if(m=p+5+e[p+4],m===p+188)continue}else m=p+4;if(R)if(g===A){if(v){if(l&&(this._parseAVCPES(this._parsePES(l)),E&&this._avcTrack.codec&&(-1===S||this._aacTrack.codec)))return void this.remux(e);l={data:[],size:0}}l&&(l.data.push(e.subarray(m,p+188)),l.size+=p+188-m)}else if(g===S){if(v){if(f&&(this._parseAACPES(this._parsePES(f)),E&&this._aacTrack.codec&&(-1===A||this._avcTrack.codec)))return void this.remux(e);f={data:[],size:0}}f&&(f.data.push(e.subarray(m,p+188)),f.size+=p+188-m)}else g===T&&(v&&(d&&this._parseID3PES(this._parsePES(d)),d={data:[],size:0}),d&&(d.data.push(e.subarray(m,p+188)),d.size+=p+188-m));else v&&(m+=e[m]+1),0===g?this._parsePAT(e,m):g===this._pmtId?(this._parsePMT(e,m),R=this.pmtParsed=!0,A=this._avcTrack.id,S=this._aacTrack.id,T=this._id3Track.id,_&&(c.logger.log("reparse from beginning"),_=!1,p=-188)):(c.logger.log("unknown PID found before PAT/PMT"),_=!0)}else this.observer.trigger(u["default"].ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});l&&this._parseAVCPES(this._parsePES(l)),f&&this._parseAACPES(this._parsePES(f)),d&&this._parseID3PES(this._parsePES(d)),this.remux(null)}},{key:"remux",value:function(e){this.remuxer.remux(this._aacTrack,this._avcTrack,this._id3Track,this._txtTrack,this.timeOffset,this.contiguous,e)}},{key:"destroy",value:function(){this.switchLevel(),this._initPTS=this._initDTS=void 0,this._duration=0}},{key:"_parsePAT",value:function(e,t){this._pmtId=(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(e,t){var r,n,i,a;for(r=(15&e[t+1])<<8|e[t+2],n=t+3+r-4,i=(15&e[t+10])<<8|e[t+11],t+=12+i;n>t;){switch(a=(31&e[t+1])<<8|e[t+2],e[t]){case 15:this._aacTrack.id=a;break;case 21:this._id3Track.id=a;break;case 27:this._avcTrack.id=a;break;default:c.logger.log("unkown stream type:"+e[t])}t+=((15&e[t+3])<<8|e[t+4])+5}}},{key:"_parsePES",value:function(e){var t,r,n,i,a,o,s,l,u,f=0,d=e.data;if(t=d[0],n=(t[0]<<16)+(t[1]<<8)+t[2],1===n){for(i=(t[4]<<8)+t[5],r=t[7],192&r&&(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,s>4294967295&&(s-=8589934592),64&r?(l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,l>4294967295&&(l-=8589934592)):l=s),a=t[8],u=a+9,e.size-=u,o=new Uint8Array(e.size);d.length;){t=d.shift();var c=t.byteLength;if(u){if(u>c){u-=c;continue}t=t.subarray(u),c-=u,u=0}o.set(t,f),f+=c}return{data:o,pts:s,dts:l,len:i}}return null}},{key:"_parseAVCPES",value:function(e){var t,r,n,i,a=this,o=this._avcTrack,s=o.samples,l=this._parseAVCNALu(e.data),u=[],f=!1,h=!1,p=0;if(0===l.length&&s.length>0){var v=s[s.length-1],g=v.units.units[v.units.units.length-1],y=new Uint8Array(g.data.byteLength+e.data.byteLength);y.set(g.data,0),y.set(e.data,g.data.byteLength),g.data=y,v.units.length+=e.data.byteLength,o.len+=e.data.byteLength}e.data=null;var m="",b=function(){u.length&&((h===!0||o.sps&&(s.length||this.contiguous))&&(r={units:{units:u,length:p},pts:e.pts,dts:e.dts,key:h},s.push(r),o.len+=p,o.nbNalu+=u.length),u=[],p=0)}.bind(this);l.forEach(function(r){switch(r.type){case 1:n=!0,f&&(m+="NDR ");break;case 5:n=!0,f&&(m+="IDR "),h=!0;break;case 6:n=!0,f&&(m+="SEI "),t=new d["default"](r.data),t.readUByte();var s=t.readUByte();if(4===s){var l=0;do l=t.readUByte();while(255===l);var c=t.readUByte();if(181===c){var v=t.readUShort();if(49===v){var g=t.readUInt();if(1195456820===g){var y=t.readUByte();if(3===y){var E=t.readUByte(),_=t.readUByte(),R=31&E,A=[E,_];for(i=0;R>i;i++)A.push(t.readUByte()),A.push(t.readUByte()),A.push(t.readUByte());a._txtTrack.samples.push({type:3,pts:e.pts,bytes:A})}}}}}break;case 7:if(n=!0,f&&(m+="SPS "),!o.sps){t=new d["default"](r.data);var S=t.readSPS();o.width=S.width,o.height=S.height,o.sps=[r.data],o.duration=a._duration;var T=r.data.subarray(1,4),L="avc1.";for(i=0;3>i;i++){var k=T[i].toString(16);k.length<2&&(k="0"+k),L+=k}o.codec=L}break;case 8:n=!0,f&&(m+="PPS "),o.pps||(o.pps=[r.data]);break;case 9:n=!1,f&&(m+="AUD "),b();break;default:n=!1,m+="unknown NAL "+r.type+" "}n&&(u.push(r),p+=r.data.byteLength)}),(f||m.length)&&c.logger.log(m),b()}},{key:"_parseAVCNALu",value:function(e){for(var t,r,n,i,a,o,s=0,l=e.byteLength,u=this.avcNaluState,f=[];l>s;)switch(t=e[s++],u){case 0:0===t&&(u=1);break;case 1:u=0===t?2:0;break;case 2:case 3:if(0===t)u=3;else if(1===t&&l>s){if(i=31&e[s],a)n={data:e.subarray(a,s-u-1),type:o},f.push(n);else{var d=this.avcNaluState;if(d&&4-d>=s){var c=this._avcTrack,h=c.samples;if(h.length){var p=h[h.length-1],v=p.units.units,g=v[v.length-1];g.state&&(g.data=g.data.subarray(0,g.data.byteLength-d),p.units.length-=d,c.len-=d)}}if(r=s-u-1,r>0){var y=this._avcTrack,m=y.samples;if(m.length){var b=m[m.length-1],E=b.units.units,_=E[E.length-1],R=new Uint8Array(_.data.byteLength+r);R.set(_.data,0),R.set(e.subarray(0,r),_.data.byteLength),_.data=R,b.units.length+=r,y.len+=r}}}a=s,o=i,u=0}else u=0}return a&&(n={data:e.subarray(a,l),type:o,state:u},f.push(n),this.avcNaluState=u),f}},{key:"_parseAACPES",value:function(e){var t,r,n,i,a,o,l,f,d,p=this._aacTrack,v=e.data,g=e.pts,y=0,m=this._duration,b=this.audioCodec,E=this.aacOverFlow,_=this.aacLastPTS;if(E){var R=new Uint8Array(E.byteLength+v.byteLength);R.set(E,0),R.set(v,E.byteLength),v=R}for(a=y,f=v.length;f-1>a&&(255!==v[a]||240!==(240&v[a+1]));a++);if(a){var A,S;if(f-1>a?(A="AAC PES did not start with ADTS header,offset:"+a,S=!1):(A="no ADTS header found in AAC PES",S=!0),this.observer.trigger(u["default"].ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:S,reason:A}),S)return}if(p.audiosamplerate||(t=s["default"].getAudioConfig(this.observer,v,a,b),p.config=t.config,p.audiosamplerate=t.samplerate,p.channelCount=t.channelCount,p.codec=t.codec,p.duration=m,c.logger.log("parsed codec:"+p.codec+",rate:"+t.samplerate+",nb channel:"+t.channelCount)),i=0,n=9216e4/p.audiosamplerate,E&&_){var T=_+n;Math.abs(T-g)>1&&(c.logger.log("AAC: align PTS for overlapping frames by "+Math.round((T-g)/90)),g=T)}for(;f>a+5&&(o=1&v[a+1]?7:9,r=(3&v[a+3])<<11|v[a+4]<<3|(224&v[a+5])>>>5,r-=o,r>0&&f>=a+o+r);)for(l=g+i*n,d={unit:v.subarray(a+o,a+o+r),pts:l,dts:l},p.samples.push(d),p.len+=r,a+=r+o,i++;f-1>a&&(255!==v[a]||240!==(240&v[a+1]));a++);E=f>a?v.subarray(a,f):null,this.aacOverFlow=E,this.aacLastPTS=l}},{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]}}]),e}();t["default"]=p},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;ro)return void(r.PTSKnown=!1);for(var d=i;o>=d;d++){var c=l[s+d],h=u[d];f=c.cc-h.cc,isNaN(c.startPTS)||(h.start=h.startPTS=c.startPTS,h.endPTS=c.endPTS,h.duration=c.duration,n=h)}if(f)for(a.logger.log("discontinuity sliding from playlist, take drift into account"),d=0;d=0&&st.endSN)return 0;s=r-t.startSN,l=t.fragments,u=l[s],isNaN(u.startPTS)||(n=Math.min(n,u.startPTS),i=Math.max(i,u.endPTS),a=Math.min(a,u.startDTS),o=Math.max(o,u.endDTS));var d=n-u.start;for(u.start=u.startPTS=n,u.endPTS=i,u.startDTS=a,u.endDTS=o,u.duration=i-n,f=s;f>0;f--)e.updatePTS(l,f,f-1);for(f=s;ft?i.start=n.start+n.duration:i.start=n.start-i.duration:r>t?(n.duration=o-n.start,n.duration<0&&a.logger.error("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!")):(i.duration=n.start-o,i.duration<0&&a.logger.error("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!"))}}]),e}();t["default"]=o},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];a.emit.apply(a,[e,e].concat(r))},a.off=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];a.removeListener.apply(a,[e].concat(r))},this.on=a.on.bind(a),this.off=a.off.bind(a),this.trigger=a.trigger.bind(a),this.playlistLoader=new f["default"](this),this.fragmentLoader=new c["default"](this),this.levelController=new R["default"](this),this.abrController=new t.abrController(this),this.bufferController=new t.bufferController(this),this.capLevelController=new t.capLevelController(this),this.streamController=new t.streamController(this),this.timelineController=new t.timelineController(this),this.keyLoader=new P["default"](this)}return a(e,null,[{key:"isSupported",value:function(){return window.MediaSource&&"function"==typeof window.MediaSource.isTypeSupported&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"Events",get:function(){return s["default"]}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig||(e.defaultConfig={autoStartLoad:!0,debug:!1,capLevelToPlayerSize:!1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,seekHoleNudgeDuration:.01,stalledInBufferedNudgeThreshold:10,maxFragLookUpTolerance:.2,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 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:k["default"],fLoader:void 0,pLoader:void 0,abrController:p["default"],bufferController:g["default"],capLevelController:m["default"],streamController:E["default"],timelineController:S["default"],enableCEA708Captions:!0,enableMP2TPassThrough:!1,abrEwmaFast:0,abrEwmaSlow:0,abrBandWidthFactor:.8,abrBandWidthUpFactor:.7}),e.defaultConfig},set:function(t){e.defaultConfig=t}}]),a(e,[{key:"destroy",value:function(){T.logger.log("destroy"),this.trigger(s["default"].DESTROYING),this.detachMedia(),this.playlistLoader.destroy(),this.fragmentLoader.destroy(),this.levelController.destroy(),this.abrController.destroy(),this.bufferController.destroy(),this.capLevelController.destroy(),this.streamController.destroy(),this.timelineController.destroy(),this.keyLoader.destroy(),this.url=null,this.observer.removeAllListeners()}},{key:"attachMedia",value:function(e){T.logger.log("attachMedia"),this.media=e,this.trigger(s["default"].MEDIA_ATTACHING,{media:e})}},{key:"detachMedia",value:function(){T.logger.log("detachMedia"),this.trigger(s["default"].MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(e){T.logger.log("loadSource:"+e),this.url=e,this.trigger(s["default"].MANIFEST_LOADING,{url:e})}},{key:"startLoad",value:function(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0];T.logger.log("startLoad"),this.levelController.startLoad(),this.streamController.startLoad(e)}},{key:"stopLoad",value:function(){T.logger.log("stopLoad"),this.levelController.stopLoad(),this.streamController.stopLoad()}},{key:"swapAudioCodec",value:function(){ T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){T.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),this.attachMedia(e)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){T.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){T.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){T.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return this.levelController.firstLevel},set:function(e){T.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){T.logger.log("set startLevel:"+e),this.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this.abrController.autoLevelCapping},set:function(e){T.logger.log("set autoLevelCapping:"+e),this.abrController.autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}}]),e}();t["default"]=I},function(e,t,r){"use strict";e.exports=r(27)["default"]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="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(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;r2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(e,t,r){var n,i,a,o,s=0,l=0,u={url:t,fragments:[],live:!0,startSN:0},f={method:null,key:null,iv:null,uri:null},d=0,c=null,h=null;for(i=/(?:#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):(.*)[\r\n]+([^#|\r\n]+)?)/g;null!==(n=i.exec(e));)switch(n.shift(),n=n.filter(function(e){return void 0!==e}),n[0]){case"MEDIA-SEQUENCE":s=u.startSN=parseInt(n[1]);break;case"TARGETDURATION":u.targetduration=parseFloat(n[1]);break;case"ENDLIST":u.live=!1;break;case"DIS":d++;break;case"BYTERANGE":var p=n[1].split("@");o=1===p.length?a:parseInt(p[1]),a=parseInt(p[0])+o,h&&!h.url&&(h.byteRangeStartOffset=o,h.byteRangeEndOffset=a,h.url=this.resolve(n[2],t));break;case"INF":var v=parseFloat(n[1]);if(!isNaN(v)){var g,m=s++;if(f.method&&f.uri&&!f.iv){g=this.cloneObj(f);for(var b=new Uint8Array(16),E=12;16>E;E++)b[E]=m>>8*(15-E)&255;g.iv=b}else g=f;var _=n[2]?this.resolve(n[2],t):null;h={url:_,duration:v,start:l,sn:m,level:r,cc:d,byteRangeStartOffset:o,byteRangeEndOffset:a,decryptdata:g,programDateTime:c},u.fragments.push(h),l+=v,o=null,c=null}break;case"KEY":var R=n[1],A=new y["default"](R),S=A.enumeratedString("METHOD"),T=A.URI,L=A.hexadecimalInteger("IV");S&&(f={method:null,key:null,iv:null,uri:null},T&&"AES-128"===S&&(f.method=S,f.uri=this.resolve(T,t),f.key=null,f.iv=L));break;case"PROGRAM-DATE-TIME":c=new Date(Date.parse(n[1])),h&&!h.url&&n.length>=3&&(h.url=this.resolve(n[2],t),h.programDateTime=c)}return h&&!h.url&&(u.fragments.pop(),l-=h.duration),u.totalduration=l,u.endSN=s-1,u}},{key:"loadsuccess",value:function(e,t){var r,n=e.currentTarget,i=n.responseText,a=n.responseURL,o=this.id,s=this.id2,l=this.hls;if(this.loading=!1,void 0===a&&(a=this.url),t.tload=performance.now(),t.mtime=new Date(n.getResponseHeader("Last-Modified")),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0)if(null===this.id)l.trigger(f["default"].MANIFEST_LOADED,{levels:[{url:a}],url:a,stats:t});else{var u=this.parseLevelPlaylist(i,a,o);t.tparsed=performance.now(),l.trigger(f["default"].LEVEL_LOADED,{details:u,level:o,id:s,stats:t})}else r=this.parseMasterPlaylist(i,a),r.length?l.trigger(f["default"].MANIFEST_LOADED,{levels:r,url:a,stats:t}):l.trigger(f["default"].ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no level found in manifest"});else l.trigger(f["default"].ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(e){var t,r;null===this.id?(t=h.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0):(t=h.ErrorDetails.LEVEL_LOAD_ERROR,r=!1),this.loader&&this.loader.abort(),this.loading=!1,this.hls.trigger(f["default"].ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:t,fatal:r,url:this.url,loader:this.loader,response:e.currentTarget,level:this.id,id:this.id2})}},{key:"loadtimeout",value:function(){var e,t;null===this.id?(e=h.ErrorDetails.MANIFEST_LOAD_TIMEOUT,t=!0):(e=h.ErrorDetails.LEVEL_LOAD_TIMEOUT,t=!1),this.loader&&this.loader.abort(),this.loading=!1,this.hls.trigger(f["default"].ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:e,fatal:t,url:this.url,loader:this.loader,level:this.id,id:this.id2})}}]),t}(c["default"]);t["default"]=m},function(e,t){"use strict";function r(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(e,t){for(var r=0;r>24&255,t[1]=n>>16&255,t[2]=n>>8&255,t[3]=255&n,t.set(e,4),i=0,n=8;a>i;i++)t.set(r[i],n),n+=r[i].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 r*=t,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(t){for(var r=t.length,n=[];r--;)n[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(n))}},{key:"mvhd",value:function(t,r){r*=t;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(t){var r,n,i=t.samples||[],a=new Uint8Array(4+i.length);for(n=0;n>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(r=0;r>>8&255),o.push(255&i),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(o))),l=t.width,u=t.height;return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}},{key:"mp4a",value:function(t){var r=t.audiosamplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"stsd",value:function(t){return"audio"===t.type?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,n=t.duration*t.timescale,i=t.width,a=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,i>>8&255,255&i,0,0,a>>8&255,255&a,0,0]))}},{key:"traf",value:function(t,r){var n=e.sdtp(t),i=t.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.trun(t,n.length+16+16+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var n,i,a,o,s,l,u=t.samples||[],f=u.length,d=12+16*f,c=new Uint8Array(d);for(r+=8+d,c.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,255&f,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;f>n;n++)i=u[n],a=i.duration,o=i.size,s=i.flags,l=i.cts,c.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var r,n=e.moov(t);return r=new Uint8Array(e.FTYP.byteLength+n.byteLength),r.set(e.FTYP),r.set(n,e.FTYP.byteLength),r}}]),e}();t["default"]=i},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;rMath.pow(2,32)&&!function(){var t=function r(e,t){return t?r(t,e%t):e};e.timescale=e.audiosamplerate/t(e.audiosamplerate,1024)}(),l.logger.log("audio mp4 timescale :"+e.timescale),h.audio={container:"audio/mp4",codec:e.codec,initSegment:f["default"].initSegment([e]),metadata:{channelCount:e.channelCount}},v&&(n=i=o[0].pts-c*r)),t.sps&&t.pps&&u.length&&(t.timescale=this.MP4_TIMESCALE,h.video={container:"video/mp4",codec:t.codec,initSegment:f["default"].initSegment([t]),metadata:{width:t.width,height:t.height}},v&&(n=Math.min(n,u[0].pts-c*r),i=Math.min(i,u[0].dts-c*r))),Object.keys(h).length?(a.trigger(s["default"].FRAG_PARSING_INIT_SEGMENT,p),this.ISGenerated=!0,v&&(this._initPTS=n,this._initDTS=i)):a.trigger(s["default"].ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r){var n,i,a,o,u,d,c,h,p,v,g,y,m,b,E,_=8,R=this.PES_TIMESCALE,A=this.PES2MP4SCALEFACTOR,S=[];for(d=new Uint8Array(e.len+4*e.nbNalu+8),n=new DataView(d.buffer),n.setUint32(0,d.byteLength),d.set(f["default"].types.mdat,4);e.samples.length;){for(i=e.samples.shift(),o=0;i.units.units.length;)u=i.units.units.shift(),n.setUint32(_,u.data.byteLength),_+=4,d.set(u.data,_),_+=u.data.byteLength,o+=4+u.data.byteLength;if(g=i.pts-this._initDTS,y=i.dts-this._initDTS,y=Math.min(g,y),void 0!==v){m=this._PTSNormalize(g,v),b=this._PTSNormalize(y,v);var T=(b-v)/A;0>=T&&(l.logger.log("invalid sample duration at PTS/DTS: "+i.pts+"/"+i.dts+":"+T),T=1),a.duration=T}else{var L=void 0,k=void 0;L=r?this.nextAvcDts:t*R,m=this._PTSNormalize(g,L),b=this._PTSNormalize(y,L),k=Math.round((b-L)/90),r&&k&&(k>1?l.logger.log("AVC:"+k+" ms hole between fragments detected,filling it"):-1>k&&l.logger.log("AVC:"+-k+" ms overlapping between fragments detected"),b=L,m=Math.max(m-k,b),l.logger.log("Video/PTS/DTS adjusted: "+m+"/"+b+",delta:"+k)),h=Math.max(0,m),p=Math.max(0,b)}a={size:o,duration:0,cts:(m-b)/A,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},E=a.flags,i.key===!0?(E.dependsOn=2,E.isNonSync=0):(E.dependsOn=1,E.isNonSync=1),S.push(a),v=b}var w=0;S.length>=2&&(w=S[S.length-2].duration,a.duration=w),this.nextAvcDts=b+w*A,e.len=0,e.nbNalu=0,S.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(E=S[0].flags,E.dependsOn=2,E.isNonSync=0),e.samples=S,c=f["default"].moof(e.sequenceNumber++,p/A,e),e.samples=[],this.observer.trigger(s["default"].FRAG_PARSING_DATA,{data1:c,data2:d,startPTS:h/R,endPTS:(m+A*w)/R,startDTS:p/R,endDTS:this.nextAvcDts/R,type:"video",nb:S.length})}},{key:"remuxAudio",value:function(e,t,r){var n,i,a,o,u,d,c,h,p,v,g,y,m,b=8,E=this.PES_TIMESCALE,_=e.timescale,R=E/_,A=1024*e.timescale/e.audiosamplerate,S=[],T=[];for(e.samples.sort(function(e,t){return e.pts-t.pts}),T=e.samples;T.length;){if(i=T.shift(),o=i.unit,v=i.pts-this._initDTS,g=i.dts-this._initDTS,void 0!==p)y=this._PTSNormalize(v,p),m=this._PTSNormalize(g,p),a.duration=(m-p)/R,Math.abs(a.duration-A)>A/10&&l.logger.log("invalid AAC sample duration at PTS "+Math.round(v/90)+",should be 1024,found :"+Math.round(a.duration*e.audiosamplerate/e.timescale)),a.duration=A,y=m=A*R+p;else{var L=void 0,k=void 0;if(L=r?this.nextAacPts:t*E,y=this._PTSNormalize(v,L),m=this._PTSNormalize(g,L),k=Math.round(1e3*(y-L)/E),r&&k){if(k>0)l.logger.log(k+" ms hole between AAC samples detected,filling it");else if(-12>k){l.logger.log(-k+" ms overlapping between AAC samples detected, drop frame"),e.len-=o.byteLength;continue}y=m=L}if(c=Math.max(0,y),h=Math.max(0,m),!(e.len>0))return;u=new Uint8Array(e.len+8),n=new DataView(u.buffer),n.setUint32(0,u.byteLength),u.set(f["default"].types.mdat,4)}u.set(o,b),b+=o.byteLength,a={size:o.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},S.push(a),p=m}var w=0,O=S.length;O>=2&&(w=S[O-2].duration,a.duration=w),O&&(this.nextAacPts=y+R*w,e.len=0,e.samples=S,d=f["default"].moof(e.sequenceNumber++,h/R,e),e.samples=[],this.observer.trigger(s["default"].FRAG_PARSING_DATA,{data1:d,data2:u,startPTS:c/E,endPTS:this.nextAacPts/E,startDTS:h/E,endDTS:(m+R*w)/E,type:"audio",nb:O}))}},{key:"remuxID3",value:function(e,t){var r,n=e.samples.length;if(n){for(var i=0;n>i;i++)r=e.samples[i],r.pts=(r.pts-this._initPTS)/this.PES_TIMESCALE,r.dts=(r.dts-this._initDTS)/this.PES_TIMESCALE;this.observer.trigger(s["default"].FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[],t=t}},{key:"remuxText",value:function(e,t){e.samples.sort(function(e,t){return e.pts-t.pts});var r,n=e.samples.length;if(n){for(var i=0;n>i;i++)r=e.samples[i],r.pts=(r.pts-this._initPTS)/this.PES_TIMESCALE;this.observer.trigger(s["default"].FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[],t=t}},{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}}]),e}();t["default"]=c},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),n=0;nNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(e){var t=/^(\d+)x(\d+)$/.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){for(var t,r=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,n={};null!==(t=r.exec(e));){var i=t[2],a='"';0===i.indexOf(a)&&i.lastIndexOf(a)===i.length-1&&(i=i.slice(1,-1)),n[t[1]]=i}return n}}]),e}();t["default"]=i},function(e,t){"use strict";var r={search:function(e,t){for(var r=0,n=e.length-1,i=null,a=null;n>=r;){i=(r+n)/2|0,a=e[i];var o=t(a);if(o>0)r=i+1;else{if(!(0>o))return a;n=i-1}}return null}};e.exports=r},function(e,t){"use strict";function r(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(e,t){for(var r=0;r0;)e.removeCue(e.cues[0])}},{key:"push",value:function(e,t){this.cue||this._createCue();for(var r,n,i,a,o,s=31&t[0],l=2,u=0;s>u;u++)if(r=t[l++],n=127&t[l++],i=127&t[l++],a=0!==(4&r),o=3&r,(0!==n||0!==i)&&a&&0===o){if(32&n||64&n)this.cue.text+=this._fromCharCode(n)+this._fromCharCode(i);else if((17===n||25===n)&&i>=48&&63>=i)switch(i){case 48:this.cue.text+="®";break;case 49:this.cue.text+="°";break;case 50:this.cue.text+="½";break;case 51:this.cue.text+="¿";break;case 52:this.cue.text+="™";break;case 53:this.cue.text+="¢";break;case 54:this.cue.text+="";break;case 55:this.cue.text+="£";break;case 56:this.cue.text+="♪";break;case 57:this.cue.text+=" ";break;case 58:this.cue.text+="è";break;case 59:this.cue.text+="â";break;case 60:this.cue.text+="ê";break;case 61:this.cue.text+="î";break;case 62:this.cue.text+="ô";break;case 63:this.cue.text+="û"}if((17===n||25===n)&&i>=32&&47>=i)switch(i){case 32:break;case 33:break;case 34:break;case 35:break;case 36:break;case 37:break;case 38: break;case 39:break;case 40:break;case 41:break;case 42:break;case 43:break;case 44:break;case 45:break;case 46:break;case 47:}if((20===n||28===n)&&i>=32&&47>=i)switch(i){case 32:this._clearActiveCues(e);break;case 33:this.cue.text=this.cue.text.substr(0,this.cue.text.length-1);break;case 34:break;case 35:break;case 36:break;case 37:break;case 38:break;case 39:break;case 40:break;case 41:this._clearActiveCues(e);break;case 42:break;case 43:break;case 44:this._clearActiveCues(e);break;case 45:break;case 46:this._text="";break;case 47:this._flipMemory(e)}if((23===n||31===n)&&i>=33&&35>=i)switch(i){case 33:break;case 34:break;case 35:}}}},{key:"_fromCharCode",value:function(e){switch(e){case 42:return"á";case 2:return"á";case 2:return"é";case 4:return"í";case 5:return"ó";case 6:return"ú";case 3:return"ç";case 4:return"÷";case 5:return"Ñ";case 6:return"ñ";case 7:return"█";default:return String.fromCharCode(e)}}},{key:"_flipMemory",value:function(e){this._clearActiveCues(e),this._flushCaptions(e)}},{key:"_flushCaptions",value:function(e){this._has708||(this._textTrack=this.media.addTextTrack("captions","English","en"),this._has708=!0);var t=!0,r=!1,n=void 0;try{for(var i,a=this.memory[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;o.startTime=e,this._textTrack.addCue(o),this.display.push(o)}}catch(s){r=!0,n=s}finally{try{!t&&a["return"]&&a["return"]()}finally{if(r)throw n}}this.memory=[],this.cue=null}},{key:"_clearActiveCues",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,a=this.display[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;o.endTime=e}}catch(s){r=!0,n=s}finally{try{!t&&a["return"]&&a["return"]()}finally{if(r)throw n}}this.display=[]}},{key:"_clearBufferedCues",value:function(){}}]),e}();t["default"]=i},function(e,t){"use strict";function r(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(e,t){for(var r=0;r-1;s=n+r)r=/^\/(?:\.\.\/)*/.exec(o.slice(n))[0].length,a=(a+o.substring(s,n)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(r-1)/3+"}$"),"/");return a+o.substr(s)}};e.exports=r},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r=200&&300>r?(window.clearTimeout(this.timeoutHandle),n.tload=Math.max(n.tfirst,performance.now()),this.onSuccess(e,n)):n.retry>>0;if(0===r)return-1;var n=0;if(arguments.length>0&&(n=Number(arguments[1]),isNaN(n)?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=r)return-1;for(var i=n>=0?n:Math.max(r-Math.abs(n),0);r>i;i++)if(i in t&&t[i]===e)return i;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if(0===r)return-1;var n=r;arguments.length>1&&(n=Number(arguments[1]),n!==n?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))));for(var i=n>=0?Math.min(n,r-1):r-Math.abs(n);i>=0;i--)if(i in t&&t[i]===e)return i;return-1}),Array.prototype.every||(Array.prototype.every=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();var n,i=arguments[1];for(n=0;r>n;n++)if(n in t&&!e.call(i,t[n],n,t))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();var n,i=arguments[1];for(n=0;r>n;n++)if(n in t&&e.call(i,t[n],n,t))return!0;return!1}),Array.prototype.forEach||(Array.prototype.forEach=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();var n,i=arguments[1];for(n=0;r>n;n++)n in t&&e.call(i,t[n],n,t)}),Array.prototype.map||(Array.prototype.map=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();var n=[];n.length=r;var i,a=arguments[1];for(i=0;r>i;i++)i in t&&(n[i]=e.call(a,t[i],i,t));return n}),Array.prototype.filter||(Array.prototype.filter=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();var n,i=[],a=arguments[1];for(n=0;r>n;n++)if(n in t){var o=t[n];e.call(a,o,n,t)&&i.push(o)}return i}),Array.prototype.reduce||(Array.prototype.reduce=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();if(0===r&&1===arguments.length)throw TypeError();var n,i=0;if(arguments.length>=2)n=arguments[1];else for(;;){if(i in t){n=t[i++];break}if(++i>=r)throw TypeError()}for(;r>i;)i in t&&(n=e.call(void 0,n,t[i],i,t)),i++;return n}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(e){if(void 0===this||null===this)throw TypeError();var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw TypeError();if(0===r&&1===arguments.length)throw TypeError();var n,i=r-1;if(arguments.length>=2)n=arguments[1];else for(;;){if(i in this){n=this[i--];break}if(--i<0)throw TypeError()}for(;i>=0;)i in t&&(n=e.call(void 0,n,t[i],i,t)),i--;return n}),String.prototype.trim||(String.prototype.trim=function(){return String(this).replace(/^\s+/,"").replace(/\s+$/,"")}),Date.now||(Date.now=function(){return Number(new Date)}),Date.prototype.toISOString||(Date.prototype.toISOString=function(){function e(e){return("00"+e).slice(-2)}function t(e){return("000"+e).slice(-3)}return this.getUTCFullYear()+"-"+e(this.getUTCMonth()+1)+"-"+e(this.getUTCDate())+"T"+e(this.getUTCHours())+":"+e(this.getUTCMinutes())+":"+e(this.getUTCSeconds())+"."+t(this.getUTCMilliseconds())+"Z"})},function(e,t){var r=arguments[2],n=r.m,i=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};t.m=e,t.c=r,t.oe=function(e){throw e},t.p="";var n=t(t.s=entryModule);return n["default"]||n};e.exports=function(e){for(var t,a=0,o=n.length;o>a;a++)if(n[a]){var s=n[a].toString(),l=e.toString(),u=r(a);if(u&&(u===e||u["default"]===e)){t=a;break}if(s.indexOf(l)>-1){n[a]=s.substring(0,s.length-1)+"\n"+l.match(/function\s?(.+?)\s?\(.*/)[1]+"();\n}",t=a;break}}var f="window = {};\nvar fn = ("+i.toString().replace("entryModule",t)+")(["+n.map(function(e){return e.toString()}).join(",")+']);\n(typeof fn === "function") && fn(self);',d=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(d.createObjectURL(new Blob([f],{type:"text/javascript"})))}},function(e,t){e.exports=flowplayer}]);