webpackJsonpjwplayer([1],{12:function(e,t,r){var i,a;i=[r(1),r(14),r(2),r(19),r(18)],a=function(e,t,r,i,a){function n(t){if(this._currentTextTrackIndex=-1,t){if(this._textTracks?(this._textTracks=e.reject(this._textTracks,function(e){if(this.renderNatively&&"nativecaptions"===e._id)return delete this._tracksById[e._id],!0},this),delete this._tracksById.nativemetadata):this._initTextTracks(),t.length){var i=0,n=t.length;for(i;ithis._textTracks.length)return!0;for(var t=0;t=0&&(i.metadata={mpegts:a+r})}(this.state===t.PLAYING||this.seeking)&&this.trigger("time",i)},click:function(e){this.trigger("click",e)},volumechange:function(){var e=this.video;this.trigger("volume",{volume:Math.round(100*e.volume)}),this.trigger("mute",{mute:e.muted})},seeked:function(){this.seeking&&(this.seeking=!1,this.trigger("seeked"))},playing:function(){this.setState(t.PLAYING),this.video.hasAttribute("jw-gesture-required")&&this.video.removeAttribute("jw-gesture-required")},pause:function(){this.state!==t.COMPLETE&&(this.video.ended||this.video.currentTime!==this.video.duration&&this.setState(t.PAUSED))},progress:function(){var t=this.getDuration();if(!(t<=0||t===1/0)){var r=this.video.buffered;if(r&&0!==r.length){var i=e.between(r.end(r.length-1)/t,0,1);this.trigger("bufferChange",{bufferPercent:100*i,position:this.getCurrentTime(),duration:t})}}},ended:function(){if(this.stopStallCheck(),this._helperLastVideoHeight=0,this.state!==t.IDLE&&this.state!==t.COMPLETE){if(this.beforeComplete=!0,this.attached=!0,this.trigger("beforeComplete"),!this.attached)return;this.playbackComplete_()}},loadeddata:function(){this.setTextTracks(this.video.textTracks),this.video.setAttribute("jw-loaded","data")},error:function(){var e=this.video.error&&this.video.error.code||-1,t={1:"Unknown operation aborted",2:"Unknown network error",3:"Unknown decode error",4:"Source not supported"}[e]||"Unknown";this.trigger("mediaError",{code:e,message:"Error playing file: "+t})}}}.apply(t,i),!(void 0!==a&&(e.exports=a))},43:function(e,t,r){"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")}t.__esModule=!0;var n=r(111),s=i(n),o=r(79),l=i(o),u=r(78),d=i(u),h=r(80),c=r(76),f=i(c),v=r(77),g=i(v),p=r(1),y=r(42),m=r(40),E=r(41),T=r(12),b=r(5),k=r(4),_=r(3),R=r(2),A=r(16),S=function(){function e(t,r){a(this,e),this.bufferStallTimeout=1e3,this.currentHlsjsLevel=null,this.currentJwItem=null,this.eventHandler=null,this.hlsjs=null,this.hlsjsConfig=null,this.jwConfig=r,this.jwLevels=null,this.lastRecoveryTime=null,this.levelDuration=0,this.live=!1,this.maxRetries=3,this.playerId=t,this.preloaded=!1,this.preloadMetaOnly=!1,this.bufferFull=!1,this.recoveryInterval=5e3,this.recoveringMediaError=!1,this.recoveringNetworkError=!1,this.renderNatively=O(),this.retryCount=0,this.stallTimeout=null,this.state=b.IDLE,this.streamType="VOD",this.supports=e.supports,this.video=this.getVideo(t)}return e.prototype.initHlsjs=function(){this.hlsjs||(this.video=this.getVideo(this.playerId,this.container),this.restoreVideoProperties(),this.setContainer(this.container),this.hlsjsConfig=(0,f["default"])(this.jwConfig.withCredentials),this.hlsjs=new s["default"](this.hlsjsConfig),this.eventHandler=new d["default"](this.video,this.createVideoListeners(),this.hlsjs,this.createHlsjsListeners()))},e.prototype.init=function(e){if(this.video&&this.video.textTracks.length&&(this.saveVideoProperties(),this.remove()),this.initHlsjs(),this.attached){if("none"!==e.preload&&this.preload(e),this.video.textTracks.length){var t=this.video.textTracks[0];t&&t.textTrack1&&(this.video.textTracks[0].inuse=!0)}e.tracks&&e.tracks.length&&this.setupSideloadedTracks(e.tracks)}},e.prototype.load=function(e,t){if(this.initHlsjs(),this.attached){if(t||this.setState(b.LOADING),this.preloaded)return this.preloadMetaOnly&&this.hlsjs.startLoad(),void this.resetPreload();w("load",e),this.bufferFull=!1,this.currentJwItem=e,this.eventsOn_(),this.hlsjs.attachMedia(this.video),this.hlsjs.nextLevel=-1,this.hlsjs.config.startPosition=e.starttime||-1,this.hlsjs.loadSource(e.sources[0].file)}},e.prototype.preload=function(e){this.preloaded||(w("preload",e),this.preloadMetaOnly="auto"!==e.preload,this.load(e,!0),this.preloaded=!0)},e.prototype.resetPreload=function(){this.preloaded=!1,this.preloadMetaOnly=!1},e.prototype.play=function(){var e=this.video.play();e&&e["catch"]&&e["catch"](function(e){w(e)})},e.prototype.pause=function(){this.video.pause(),this.setState(b.PAUSED)},e.prototype.stop=function(){this.attached&&(this.stopStallTimeout(),this.video.pause(),this.clearTracks(),this.setState(b.IDLE),this.hlsjs&&this.eventsOff_())},e.prototype.seek=function(e){var t=this.video.duration;if(!this.attached||t===1/0)return void D("Returned early from seek","Attached",this.attached,"Duration",t);var r=e>=0?e:e+t;this.trigger(_.JWPLAYER_MEDIA_SEEK,{position:this.getCurrentTime(),offset:r});var i=this.getDuration();0!==i&&i!==1/0&&(this.seeking=!0,this.video.currentTime=r,this.trigger("time",{duration:i,position:this.getCurrentTime()}))},e.prototype.getCurrentQuality=function(){var e=0;return this.hlsjs&&!this.hlsjs.autoLevelEnabled&&(e=(0,h.toJwLevel)(this.getCurrentHlsjsLevel(),this.jwLevels)),e},e.prototype.getQualityLevels=function(){return this.jwLevels},e.prototype.getCurrentAudioTrack=function(){return p.isNumber(this.currentAudioTrackIndex)?this.currentAudioTrackIndex:-1},e.prototype.getAudioTracks=function(){return this.audioTracks||[]},e.prototype.getCurrentTime=function(){var e=this.video.currentTime;return this.live&&"DVR"===this.streamType&&(e-=this.video.duration),e},e.prototype.getDuration=function(){var e=this.currentJwItem.minDvrWindow,t=this.video.duration;return this.live&&(t=R.isDvr(-t,e)?-this.levelDuration:1/0),this.streamType=R.streamType(t,e),t},e.prototype.getCurrentHlsjsLevel=function(){var e=0;if(this.hlsjs){var t=this.hlsjs,r=t.firstLevel,i=t.currentLevel;e=i>0?i:r}return e},e.prototype.getName=function(){return L()},e.prototype.setCurrentQuality=function(e){if(!(e<0)){var t=this.hlsjs.levels,r=(0,h.toHlsjsLevel)(e,this.jwLevels);this.hlsjs.nextLevel=r,this.trigger(_.JWPLAYER_MEDIA_LEVEL_CHANGED,{levels:this.jwLevels,currentQuality:e}),this.jwConfig.qualityLabel=this.jwLevels[e].label,w("Setting level to ",r,t[Math.max(r,0)],this.jwLevels[e])}},e.prototype.setCurrentAudioTrack=function(e){var t=this.getCurrentHlsjsLevel(),r=(0,h.toJwLevel)(t,this.jwLevels);if(this.jwLevels[r]){var i=this.jwLevels[r].audioGroupId;p.size(this.audioTracksMap)&&(this.audioTracks=this.audioTracksMap[i],p.isNumber(e)&&p.size(this.audioTracks)&&this.audioTracks[e]&&this.currentAudioTrackIndex!==e&&(this.trigger(_.JWPLAYER_AUDIO_TRACKS,{tracks:this.audioTracks,currentTrack:e}),null!==this.currentAudioTrackIndex&&this.audioTracks[e].hlsjsIndex!==this.hlsjs.audioTrack&&this.trigger(_.JWPLAYER_AUDIO_TRACK_CHANGED,{tracks:this.audioTracks,currentTrack:e}),this.currentAudioTrackIndex=e,this.hlsjs.audioTrack=this.audioTracks[e].hlsjsIndex,w("Setting audio track to",this.audioTracks[e])))}},e.prototype.updateAudioTrack=function(e){if(this.hlsjs.audioTracks.length){var t=this.currentAudioTrackIndex;p.isNumber(t)?this.audioTracks[t].hlsjsIndex!==this.hlsjs.audioTrack&&(this.currentAudioTrackIndex=null):t=(0,h.getDefaultJwTrackIndex)(this.audioTracksMap[e.attrs.AUDIO]),this.setCurrentAudioTrack(t)}},e.prototype.onAdaptation=function(e){var t=this.hlsjs,r=t.levels,i=t.autoLevelEnabled,a=this.video.videoWidth||r[e].width,n=this.video.videoHeight||r[e].height,s=(0,h.toJwLevel)(e,this.jwLevels);this.trigger("visualQuality",{reason:i?"auto":"api",mode:i?"auto":"manual",type:"visualQuality",level:{index:i?0:s+1,label:i?"auto":this.jwLevels[s].label,bitrate:r[e].bitrate,width:a,height:n}}),this.trigger("providerFirstFrame",{}),this.triggerMediaType(a,n)},e.prototype.triggerMediaType=function(e,t){var r="video";e&&t||(r="audio"),w("Media Type",r),this.trigger(_.JWPLAYER_MEDIA_TYPE,{mediaType:r})},e.prototype.createVideoListeners=function(){var e=this,t={};return p.each(y,function(r,i){"function"==typeof r&&(t[i]=r.bind(e))}),t},e.prototype.createHlsjsListeners=function(){var e=this,t={};return t[s["default"].Events.MEDIA_ATTACHED]=function(){w("Media attached"),e.recoveringMediaError&&(e.hlsjs.startLoad(),e.recoveringMediaError=!1,e.resetRecovery(),e.stopStallTimeout())},t[s["default"].Events.MEDIA_DETACHED]=function(){w("Media detached")},t[s["default"].Events.MANIFEST_LOADED]=function(e,t){w("Manifest loaded",t)},t[s["default"].Events.MANIFEST_PARSED]=function(t,r){w("Manifest parsed",r);var i=r.levels,a=r.firstLevel,n=a,s=0;e.currentHlsjsLevel=null,e.jwLevels=(0,h.formatLevels)(i);var o=p.find(e.jwLevels,function(t){return t.label===e.jwConfig.qualityLabel});o&&o.hlsjsIndex>-1&&(n=o.hlsjsIndex,s=(0,h.toJwLevel)(n,e.jwLevels),e.hlsjs.nextLevel=n),e.hlsjs.startLevel=n,e.preloadMetaOnly||e.hlsjs.startLoad(e.hlsjs.config.startPosition),e.trigger(_.JWPLAYER_MEDIA_LEVELS,{levels:e.jwLevels,currentQuality:s})},t[s["default"].Events.LEVEL_SWITCH]=function(t,r){w("Level switch requested",r,e.hlsjs.levels,"ABR:",e.hlsjs.autoLevelEnabled)},t[s["default"].Events.LEVEL_LOADED]=function(e,t){w("Level loaded",t)},t[s["default"].Events.LEVEL_UPDATED]=function(t,r){w("Level updated",r);var i=r.details,a=i.live,n=i.totalduration;e.live=a,e.levelDuration=n},t[s["default"].Events.LEVEL_PTS_UPDATED]=function(t,r){w("Level PTS updated",r),e.levelDuration=r.details.totalduration},t[s["default"].Events.FRAG_CHANGED]=function(t,r){w("Frag changed",r);var i=e.hlsjs.levels,a=r.frag.level,n=i[a];a!==e.currentHlsjsLevel&&(w("Level switch complete",a,n),e.currentHlsjsLevel=a,e.onAdaptation(a),e.updateAudioTrack(i[a]))},t[s["default"].Events.FRAG_PARSING_METADATA]=function(t,r){w("Frag metadata parsed",r);var i=e.hlsjs.levels;p.each(r.samples,function(t){var a=t.unit,n=t.data,s=t.pts,o=(0,l["default"])(a||n).cues;if(!o)return void D("No cues found in ID3 byte array");var u=R.parseID3(o);if(!u)return void D("No metadata found in the ID3 cues");var d=i[r.level],h=d&&d.details;if(!h){if(u.PRIV&&"com.apple.streaming.transportStreamTimestamp"in u.PRIV)return;return void D("No matching level found for ID3 metadata")}var c=p.find(d.details.fragments,function(e){return e.sn===r.sn});if(!c)return void D("No matching fragment found for ID3 level");if(!c.endPTS)return void D("No endPTS found for matching ID3 fragment");var f=new VTTCue(Math.max(s,0),c.endPTS,JSON.stringify(u));e.addVTTCue({type:"metadata",cue:f})})},t[s["default"].Events.BUFFER_APPENDING]=function(e,t){w("Buffer appending",t)},t[s["default"].Events.BUFFER_APPENDED]=function(t,r){var i=e.video.buffered.length;w("Buffer appended",r,e.state,i,i&&e.video.buffered.end(i-1)),e.stopStallTimeout(),e.recoveringNetworkError&&(e.resetRecovery(),e.recoveringNetworkError=!1)},t[s["default"].Events.FRAG_BUFFERED]=function(t,r){w("Frag buffered",r),e.bufferFull||(e.bufferFull=!0,e.trigger(_.JWPLAYER_MEDIA_BUFFER_FULL))},t[s["default"].Events.KEY_LOADING]=function(t,r){w("Key loading",r),e.supports("drm")||e.shutdown("AES decryption not supported with this license")},t[s["default"].Events.SUBTITLE_TRACKS_UPDATED]=function(e,t){w("Subtitle tracks updated",t)},t[s["default"].Events.AUDIO_TRACKS_UPDATED]=function(t,r){w("Audio tracks updated");var i=r.audioTracks,a=e.hlsjs.levels,n=e.getCurrentHlsjsLevel();i&&i.length&&(e.currentAudioTrackIndex=null,e.audioTracksMap=(0,h.formatAudioTracks)(i),e.updateAudioTrack(a[n]))},t[s["default"].Events.ERROR]=function(t,r){var i=(0,g["default"])(r),a=r.fatal,n=r.type,s=i.stalling,o=i.recoverable,l=i.message,u=i.doCodecSwap;if(D(i),s&&!e.stallTimeout&&e.startStallTimeout(),a){var d=Date.now();o&&e.retryCount=e.lastRecoveryTime+e.recoveryInterval?(D("Attempting to recover, retry count:",e.retryCount),"networkError"===n?(e.recoveringNetworkError=!0,e.hlsjs.startLoad()):"mediaError"===n&&(e.recoveringMediaError=!0,u&&e.hlsjs.swapAudioCodec(),e.hlsjs.recoverMediaError()),e.retryCount+=1,e.lastRecoveryTime=d):D("Recovery not attempted - too little time between attempts",d-e.lastRecoveryTime):e.shutdown(l,r)}},t},e.prototype.eventsOn_=function(){w("eventsOn_"),this.eventHandler.on()},e.prototype.eventsOff_=function(){w("eventsOff_"),this.clearCues(),this.hlsjs.detachMedia(),this.eventHandler.off(),this.resetPreload()},e.prototype.shutdown=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Fatal Error",t=arguments[1];console.error("Hlsjs shutdown",e,t),this.trigger(_.JWPLAYER_MEDIA_ERROR,{message:e}),this.destroy()},e.prototype.destroy=function(){this.resetRecovery(),this.hlsjs&&(this.eventsOff_(),this.hlsjs.destroy(),this.hlsjs=null,w("Hlsjs destroyed"))},e.prototype.startStallTimeout=function(){var e=this;this.stallTimeout||(this.stallTimeout=setTimeout(function(){e.video.ended||e.setState(b.STALLED)},this.bufferStallTimeout))},e.prototype.stopStallTimeout=function(){clearTimeout(this.stallTimeout),this.stallTimeout=null},e.prototype.saveVideoProperties=function(){this.jwConfig.volume=100*this.video.volume,this.jwConfig.mute=this.video.muted},e.prototype.restoreVideoProperties=function(){this.volume(this.jwConfig.volume),this.mute(this.jwConfig.mute)},e.prototype.resetRecovery=function(){this.retryCount=0},e.getName=function(){return L()},e.setEdition=function(t){e.supports=A(t)},e}();t["default"]=S;var L=function(){return{name:"hlsjs"}},w=function(){if(window.jwplayer.debug){var e;(e=console).info.apply(e,arguments)}},D=function(){if(window.jwplayer.debug){var e;(e=console).warn.apply(e,arguments)}},O=function(){return R.isChrome()||R.isIOS()||R.isSafari()||R.isEdge()||R.isFF()};delete y.error;var I=Object.assign({},k,m,E,T);S.prototype=Object.assign(Object.create(I),S.prototype)},76:function(e,t){"use strict";function r(e){var t={liveSyncDuration:25,autoStartLoad:!1,maxBufferSize:2e7,maxMaxBufferLength:90};return e&&(t=Object.assign({},t,i())),t}function i(){return{xhrSetup:function(e,t){e.withCredentials=!0},fetchSetup:function(e,t){return t.credentials="include",new Request(e.url,t)}}}t.__esModule=!0,t["default"]=r},77:function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){var t=e.details,r=n.indexOf(s,t)<0,i=n.indexOf(o,t)>=0,a=n.indexOf(l,t)>=0,h=u(e);switch(e.type){case"networkError":h="Cannot load M3U8: "+h;break;case"mediaError":h="Media Error: "+h;break;case"otherError":h="Error: "+h+";"}return new d(h,r,i,a,e)}t.__esModule=!0,t["default"]=a;var n=r(1),s=["manifestLoadError","manifestParsingError","manifestIncompatibleCodecsError","levelLoadError"],o=["bufferStalledError","bufferSeekOverHole"],l=["fragLoopLoadingError"],u=function(e){var t="";if(e)if(e.response){var r=e.response,i=r.code,a=r.text,n=e.url;t=i?i+" "+a:n&&"http:"===n.substring(0,5)&&"https:"===document.location.protocol?"Unable to fetch HTTP resource over HTTPS":"Crossdomain access denied"}else t=e.reason?""+e.reason:""+e.details;return t},d=t.HlsjsError=function h(e,t,r,a,n){i(this,h),this.message=e,this.recoverable=t,this.stalling=r,this.doCodecSwap=a,this.hlsjsError=n}},78:function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var a=r(1),n=function(){function e(t,r,a,n){i(this,e),this.video=t,this.hlsjs=a,this.videoListeners=r,this.hlsjsListeners=n}return e.prototype.on=function(){var e=this;this.off(),a.each(this.videoListeners,function(t,r){e.video.addEventListener(r,t,!1)}),a.each(this.hlsjsListeners,function(t,r){e.hlsjs.on(r,t)})},e.prototype.off=function(){var e=this;a.each(this.videoListeners,function(t,r){e.video.removeEventListener(r,t)}),a.each(this.hlsjsListeners,function(t,r){e.hlsjs.off(r,t)})},e}();t["default"]=n},79:function(e,t,r){"use strict";function i(e){for(var t=0,r=0,i=10,o=[];t+s0)return s;var d=e[a];3!==d&&0!==d||(l-=1,a+=1);var h=e.buffer.slice(o-10,a+l+1);s.push({data:h}),a+=l+1}return s}t.__esModule=!0,t["default"]=i;var n=r(14),s=9},80:function(e,t,r){"use strict";function i(e,t){var r=l.map(e,function(e,t){var r=e;return r.hlsjsIndex=t,r.attrs&&(r.bandwidth=r.attrs.BANDWIDTH,r.audioGroupId=r.attrs.AUDIO),r});r=u(r);var i=d(r);return r=l.map(r,function(e){return{contentType:t,label:h(e,i),level_id:e.id,hlsjsIndex:e.hlsjsIndex,bandwidth:e.bandwidth,audioGroupId:e.audioGroupId}}),r.length>1&&r.unshift({label:"Auto",level_id:"auto",hlsjsIndex:-1}),r}function a(e,t){return Math.max(0,l.indexOf(t,l.find(t,function(t){return t.hlsjsIndex===e})))}function n(e,t){var r=-1;return e>-1&&t[e]&&(r=t[e].hlsjsIndex),r}function s(e){var t=l.reduce(e,function(e,t,r){var i=t.groupId;return e[i]=e[i]||[],e[i].push({autoselect:t.autoselect,defaulttrack:t["default"],groupid:i,language:t.lang,name:t.name,hlsjsIndex:r}),e},{});return t}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return l.indexOf(e,l.find(e,function(e){return e.defaulttrack}))}t.__esModule=!0,t.formatLevels=i,t.toJwLevel=a,t.toHlsjsLevel=n,t.formatAudioTracks=s,t.getDefaultJwTrackIndex=o;var l=r(1),u=function(e){return e.sort(function(e,t){var r=void 0;return r=e.height&&t.height?e.height===t.height?t.bandwidth-e.bandwidth:t.height-e.height:t.bandwidth-e.bandwidth})},d=function(e){return l.some(e,function(e){var t=e.height||"@"+e.bandwidth,r=this[t];return this[t]=1,r},{})},h=function(e,t){var r=e.height,i=e.bandwidth,a=Math.floor(i/1e3)+" kbps",n=a;return r&&(n=r+"p",t&&(n+=" ("+a+")")),n}},111:function(e,t){!function(r){if("object"==typeof t&&"undefined"!=typeof e)e.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var i;i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,i.Hls=r()}}(function(){return function e(t,r,i){function a(s,o){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(n)return n(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=r[s]={exports:{}};t[s][0].call(d.exports,function(e){var r=t[s][1][e];return a(r?r:e)},d,d.exports,e,t,r,i)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s0&&this._events[e].length>r&&(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},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!a(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},i.prototype.removeListener=function(e,t){var r,i,n,o;if(!a(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this; if(r=this._events[e],n=r.length,i=-1,r===t||a(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(o=n;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){i=o;break}if(i<0)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},i.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],a(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?a(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(a(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,r){var i=arguments[3],a=arguments[4],n=arguments[5],s=JSON.stringify;t.exports=function(e,t){function r(e){p[e]=!0;for(var t in a[e][1]){var i=a[e][1][t];p[i]||r(i)}}for(var o,l=Object.keys(n),u=0,d=l.length;u500*r.duration/s){var o=e.levels,l=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/n),d=a.total?a.total:Math.max(a.loaded,Math.round(r.duration*o[r.level].bitrate/8)),h=t.currentTime,c=(d-a.loaded)/l,v=(f["default"].bufferInfo(t,h,e.config.maxBufferHole).end-h)/s;if(v<2*r.duration/s&&c>v){var p=void 0,y=void 0;for(y=r.level-1;y>=0&&(p=r.duration*o[y].bitrate/(6.4*l),!(p=i;u--){var d=l[u],h=d.details,c=h?h.totalduration/h.fragments.length:t,f=!!h&&h.live,v=void 0;v=u<=e?s*r:o*r;var p=l[u].bitrate,y=p*c/v;if(g.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(v)+"/"+p+"/"+c+"/"+n+"/"+y),v>p&&(!y||f||yr)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.hls.levels,r=this._autoLevelCapping;return e=r===-1&&t&&t.length?t.length-1:r}},{key:"nextABRAutoLevel",get:function(){var e=this.hls,t=this.maxAutoLevel,r=e.levels,i=e.config,a=this.minAutoLevel,n=e.media,s=this.lastLoadedFragLevel,o=this.fragCurrent?this.fragCurrent.duration:0,l=n?n.currentTime:0,u=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,h=(f["default"].bufferInfo(n,l,i.maxBufferHole).end-l)/u,c=this.findBestLevel(s,o,d,a,t,h,i.abrBandWidthFactor,i.abrBandWidthUpFactor,r);if(c>=0)return c;g.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var v=i.maxStarvationDelay,p=i.abrBandWidthFactor,y=i.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;m&&(v=i.maxLoadingDelay-m,g.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),p=y=1)}return c=this.findBestLevel(s,o,d,a,t,h+v,p,y,r),Math.max(c,0)}}]),t}(h["default"]);r["default"]=m},{27:27,28:28,29:29,31:31,46:46,8:8}],4:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){var e,t,r,i=this.hls,a=i.config;switch(this.state){case R.ERROR:case R.PAUSED:break;case R.STARTING:this.state=R.WAITING_TRACK,this.loadedmetadata=!1;break;case R.IDLE:if(!this.media&&(this.startFragRequested||!a.startFragPrefetch))break;e=this.loadedmetadata?this.media.currentTime:this.nextLoadPosition;var n=this.mediaBuffer?this.mediaBuffer:this.media,s=h["default"].bufferInfo(n,e,a.maxBufferHole),o=s.len,l=s.end,d=this.fragPrevious,c=a.maxMaxBufferLength;if(oy-t&&(t=0),e=u["default"].search(f,function(e){return e.start+e.duration-t<=l?1:e.start-t>l?-1:0})):e=f[v-1],e&&(m=e,p=e.start,d&&m.level===d.level&&m.sn===d.sn&&(m.snE&&Math.abs(this.fragLoadIdx-m.loadIdx)=b||A)&&(_.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=R.IDLE);break;case R.STOPPED:case R.FRAG_LOADING:case R.PARSING:case R.PARSED:case R.ENDED:}}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(_.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.tracks;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("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeking",value:function(){this.state===R.ENDED&&(this.state=R.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaEnded",value:function(){this.startPosition=this.lastCurrentTime=0}},{key:"onAudioTracksUpdated",value:function(e){_.logger.log("audio tracks updated"),this.tracks=e.audioTracks}},{key:"onAudioTrackSwitch",value:function(e){var t=!!e.url;this.trackId=e.id,this.state=R.IDLE,this.fragCurrent=null,this.state=R.PAUSED,t?this.timer||(this.timer=setInterval(this.ontick,100)):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.hls.trigger(g["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),this.tick()}},{key:"onAudioTrackLoaded",value:function(e){var t=e.details,r=e.id,i=this.tracks[r],a=t.totalduration;if(_.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.PTSKnown=!1,i.details=t,!this.startFragRequested){if(this.startPosition===-1){var n=t.startTimeOffset;isNaN(n)?this.startPosition=0:(_.logger.log("start time offset found in playlist, adjust startPosition to "+n),this.startPosition=n)}this.nextLoadPosition=this.startPosition}this.state===R.WAITING_TRACK&&(this.state=R.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===R.KEY_LOADING&&(this.state=R.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent;if(this.state===R.FRAG_LOADING&&t&&"audio"===e.frag.type&&e.frag.level===t.level&&e.frag.sn===t.sn){this.state=R.PARSING,this.stats=e.stats;var r=this.tracks[this.trackId],i=r.details,a=i.totalduration,n=t.start,s=t.level,o=t.sn,l=this.config.defaultAudioCodec||r.audioCodec;this.pendingAppending=0,this.demuxer||(this.demuxer=new f["default"](this.hls,"audio")),_.logger.log("Demuxing "+o+" of ["+i.startSN+" ,"+i.endSN+"],track "+s);var u=i.PTSKnown||!i.live;this.demuxer.push(e.payload,l,null,n,t.cc,s,o,a,t.decryptdata,u)}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent;if(t&&"audio"===e.id&&e.sn===t.sn&&e.level===t.level&&this.state===R.PARSING){var r=e.tracks,i=void 0;if(i=r.audio){i.levelCodec="mp4a.40.2",i.id=e.id,this.hls.trigger(g["default"].BUFFER_CODECS,r),_.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var a=i.initSegment;a&&(this.pendingAppending++,this.hls.trigger(g["default"].BUFFER_APPENDING,{type:"audio",data:a,parent:"audio",content:"initSegment"})),this.tick()}}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent;if(r&&"audio"===e.id&&e.sn===r.sn&&e.level===r.level&&this.state===R.PARSING){var i=this.tracks[this.trackId],a=this.fragCurrent;_.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),E["default"].updateFragPTSDTS(i.details,a.sn,e.startPTS,e.endPTS),[e.data1,e.data2].forEach(function(r){r&&(t.pendingAppending++,t.hls.trigger(g["default"].BUFFER_APPENDING,{type:e.type,data:r,parent:"audio",content:"data"}))}),this.nextLoadPosition=e.endPTS,this.tick()}}},{key:"onFragParsed",value:function(e){var t=this.fragCurrent;t&&"audio"===e.id&&e.sn===t.sn&&e.level===t.level&&this.state===R.PARSING&&(this.stats.tparsed=performance.now(),this.state=R.PARSED,this._checkAppendedParsed())}},{key:"onBufferCreated",value:function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0)}},{key:"onBufferAppended",value:function(e){if("audio"===e.parent)switch(this.state){case R.PARSING:case R.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===R.PARSED&&0===this.pendingAppending){var e=this.fragCurrent,t=this.stats;if(e){this.fragPrevious=e,t.tbuffered=performance.now(),this.hls.trigger(g["default"].FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var r=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("audio buffered : "+b["default"].toString(r.buffered)),this.state=R.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!e.fatal){var r=this.fragLoadError;r?r++:r=1;var i=this.config;if(r<=i.fragLoadingMaxRetry){this.fragLoadError=r,t.loadCounter=0;var a=Math.min(Math.pow(2,r-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);_.logger.warn("audioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=performance.now()+a,this.state=R.FRAG_LOADING_WAITING_RETRY}else _.logger.error("audioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.trigger(g["default"].ERROR,e),this.state=R.ERROR}break;case k.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case k.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==R.ERROR&&(this.state=e.fatal?R.ERROR:R.IDLE,_.logger.warn("audioStreamController: "+e.details+" while loading frag,switch to "+this.state+" state ..."))}}},{key:"onBufferFlushed",value:function(){this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=R.IDLE,this.fragPrevious=null,this.tick()}}]),t}(y["default"]);r["default"]=A},{23:23,27:27,28:28,29:29,31:31,32:32,42:42,46:46,48:48}],5:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=0&&ethis._msDuration&&i>e.duration&&(c.logger.log("Updating mediasource duration to "+i.toFixed(3)),this._msDuration=t.duration=i)}}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))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;for(var i in r)t+=r[i].buffered.length;this.appended=t,this.hls.trigger(u["default"].BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.sourceBuffer,r=this.segments;if(Object.keys(t).length){if(this.media.error)return this.segments=[],void c.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var i=r.shift();try{var a=i.type;t[a]?(t[a].ended=!1,this.parent=i.parent,t[a].appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(n){c.logger.error("error while trying to append buffer:"+n.message),r.unshift(i);var s={type:f.ErrorTypes.MEDIA_ERROR};if(22===n.code)return this.segments=[],s.details=f.ErrorDetails.BUFFER_FULL_ERROR,void e.trigger(u["default"].ERROR,s);if(this.appendError?this.appendError++:this.appendError=1,s.details=f.ErrorDetails.BUFFER_APPEND_ERROR,s.frag=this.fragCurrent,this.appendError>e.config.appendErrorMaxRetry)return c.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],s.fatal=!0,void e.trigger(u["default"].ERROR,s);s.fatal=!1,e.trigger(u["default"].ERROR,s)}}}}},{key:"flushBuffer",value:function(e,t,r){var i,a,n,s,o,l,u=this.sourceBuffer;if(Object.keys(u).length){if(c.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime+"/"+e+"/"+t),this.flushBufferCounter.5)return this.flushBufferCounter++,c.logger.log("flush "+d+" ["+o+","+l+"], of ["+n+","+s+"], pos:"+this.media.currentTime),i.remove(o,l),!1}}else c.logger.warn("abort flushing too many retries");c.logger.log("buffer flushed")}return!0}}]),t}(h["default"]);r["default"]=v},{27:27,28:28,29:29,46:46 }],7:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;rthis.autoLevelCapping&&this.hls.streamController.nextLevelSwitch(),this.autoLevelCapping=this.hls.autoLevelCapping)}}},{key:"getMaxLevel",value:function(e){var t=0,r=void 0,i=void 0,a=this.mediaWidth,n=this.mediaHeight,s=0,o=0;for(r=0;r<=e&&(i=this.levels[r],!this.isLevelRestricted(r))&&(t=r,s=i.width,o=i.height,!(a<=s||n<=o));r++);return t}},{key:"isLevelRestricted",value:function(e){return!(!this.restrictedLevels||this.restrictedLevels.indexOf(e)===-1)}},{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}(h["default"]);r["default"]=c},{28:28,29:29}],8:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();r["default"]=l},{45:45}],9:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r0&&n>this.hls.config.fpsDroppedMonitoringThreshold*s){var l=this.hls.currentLevel;c.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(this.hls.autoLevelCapping===-1||this.hls.autoLevelCapping>=l)&&(l-=1,this.hls.trigger(u["default"].FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:this.hls.currentLevel}),this.hls.autoLevelCapping=l,this.hls.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){if(this.video)if(this.isVideoPlaybackQualityAvailable){var e=this.video.getVideoPlaybackQuality();this.checkFPS(this.video,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(this.video,this.video.webkitDecodedFrameCount,this.video.webkitDroppedFrameCount)}}]),t}(h["default"]);r["default"]=f},{28:28,29:29,46:46}],10:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r0})}else l.trigger(u["default"].ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:l.url,reason:"no level with compatible codecs found in manifest"})}},{key:"setLevelInternal",value:function(e){var t=this._levels;if(e>=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),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return this._manualLevel!==-1?this._manualLevel:this.hls.abrController.nextAutoLevel},set:function(e){this.level=e,this._manualLevel===-1&&(this.hls.abrController.nextAutoLevel=e)}}]),t}(h["default"]);r["default"]=p},{27:27,28:28,29:29,31:31,46:46}],11:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r0?(_.logger.log("configure startPosition @"+r.toFixed(3)),this.lastPaused||(_.logger.log("resuming video"),t.play())):this.lastCurrentTime=this.startPosition?this.startPosition:e,!this.startFragRequested){var a=i.startLevel;a===-1&&(a=0,this.bitrateTest=!0),this.level=i.nextLoadLevel=a,this.loadedmetadata=!1}this.state=R.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else _.logger.warn("cannot start loading as manifest not parsed yet"),this.state=R.STOPPED}},{key:"stopLoad",value:function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=R.STOPPED}},{key:"tick",value:function(){this.ticks++,1===this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){switch(this.state){case R.ERROR:break;case R.BUFFER_FLUSHING:this.fragLoadError=0;break;case R.IDLE:if(!this._doTickIdle())return;break;case R.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=R.IDLE);break;case R.FRAG_LOADING_WAITING_RETRY:var t=performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(_.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=R.IDLE);break;case R.ERROR:case R.PAUSED:case R.STOPPED:case R.FRAG_LOADING:case R.PARSING:case R.PARSED:case R.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"_doTickIdle",value:function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&!r&&(this.startFragRequested||!t.startFragPrefetch))return!0;var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=e.nextLoadLevel,n=this.levels[a],s=n.bitrate,o=void 0;o=s?Math.max(8*t.maxBufferSize/s,t.maxBufferLength):t.maxBufferLength,o=Math.min(o,t.maxMaxBufferLength);var l=h["default"].bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,t.maxBufferHole),u=l.len;if(u>=o)return!0;_.logger.trace("buffer length of "+u.toFixed(3)+" is below max of "+o.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=a;var d=n.details;if("undefined"==typeof d||d.live&&this.levelLastLoaded!==a)return this.state=R.WAITING_LEVEL,!0;var c=this.fragPrevious;if(!d.live&&c&&c.sn===d.endSN&&(!r.seeking&&l.len||r.duration-l.end<=c.duration/2)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(g["default"].BUFFER_EOS,f),this.state=R.ENDED,!0}return this._fetchPayloadOrEos({pos:i,bufferInfo:l,levelDetails:d})}},{key:"_fetchPayloadOrEos",value:function(e){var t=e.pos,r=e.bufferInfo,i=e.levelDetails,a=this.fragPrevious,n=this.level,s=i.fragments,o=s.length;if(0===o)return!1;var l=s[0].start,u=s[o-1].start+s[o-1].duration,d=r.end,h=void 0;if(i.live){var c=this.config.initialLiveManifestSize;if(oc&&(u.currentTime=c)}if(t.PTSKnown&&r>a&&u&&u.readyState)return null;if(this.startFragRequested&&!t.PTSKnown){if(n){var f=n.sn+1;f>=t.startSN&&f<=t.endSN&&(d=s[f-t.startSN],_.logger.log("live playlist, switching playlist, load frag with next SN: "+d.sn))}d||(d=s[Math.min(o-1,Math.round(o/2))],_.logger.log("live playlist, switching playlist, unknown, load middle frag : "+d.sn))}return d}},{key:"_findFragment",value:function(e){var t=e.start,r=e.fragPrevious,i=e.fragLen,a=e.fragments,n=e.bufferEnd,s=e.end,o=e.levelDetails,l=this.hls.config,d=void 0,h=void 0,c=l.maxFragLookUpTolerance;if(ns-c&&(c=0),h=u["default"].search(a,function(e){return e.start+e.duration-c<=n?1:e.start-c>n&&e.start?-1:0})):h=a[i-1],h&&(d=h,t=h.start,r&&d.level===r.level&&d.sn===r.sn))if(d.snl.maxBufferHole&&r.dropped&&v?(d=a[v-1],_.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this"),r.loadCounter--):(d=a[v+1],_.logger.log("SN just loaded, load next one: "+d.sn))}else d=null;return d}},{key:"_loadFragmentOrKey",value:function(e){var t=e.frag,r=e.level,i=e.levelDetails,a=e.pos,n=e.bufferEnd,s=this.hls,o=s.config;if(null==t.decryptdata.uri||null!=t.decryptdata.key){if(_.logger.log("Loading "+t.sn+" of ["+i.startSN+" ,"+i.endSN+"],level "+r+", currentTime:"+a.toFixed(3)+",bufferEnd:"+n.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,t.loadCounter){t.loadCounter++;var l=o.fragLoadingLoopThreshold;if(t.loadCounter>l&&Math.abs(this.fragLoadIdx-t.loadIdx)=0;t--)if(r=i[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:"_checkFragmentChanged",value:function(){var e,t,r=this.media;if(r&&r.readyState&&r.seeking===!1&&(t=r.currentTime,t>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=t),h["default"].isBuffered(r,t)?e=this.getBufferRange(t):h["default"].isBuffered(r,t+.1)&&(e=this.getBufferRange(t+.1)),e)){var i=e.frag;i!==this.fragPlaying&&(this.fragPlaying=i,this.hls.trigger(g["default"].FRAG_CHANGED,{frag:i}))}}},{key:"immediateLevelSwitch",value:function(){if(_.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e=this.media,t=void 0;e?(t=e.paused,e.pause()):t=!0,this.previouslyPaused=t}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=R.BUFFER_FLUSHING,this.hls.trigger(g["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY})}},{key:"immediateLevelSwitchEnd",value:function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,h["default"].isBuffered(e,e.currentTime)&&(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,i=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferRange(e.currentTime),r&&r.start>1&&(this.state=R.BUFFER_FLUSHING,this.hls.trigger(g["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:r.start-1})),e.paused)t=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}if(i=this.getBufferRange(e.currentTime+t),i&&(i=this.followingBufferRange(i))){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.state=R.BUFFER_FLUSHING,this.hls.trigger(g["default"].BUFFER_FLUSHING,{startOffset:i.start,endOffset:Number.POSITIVE_INFINITY})}}}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(_.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(){var e=this.media,t=e?e.currentTime:void 0,r=this.config;if(_.logger.log("media seeking to "+t.toFixed(3)),this.state===R.FRAG_LOADING){var i=h["default"].bufferInfo(e,t,this.config.maxBufferHole),a=this.fragCurrent;if(0===i.len&&a){var n=r.maxFragLookUpTolerance,s=a.start-n,o=a.start+a.duration+n;to?(a.loader&&(_.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),a.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=R.IDLE):_.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===R.ENDED&&(this.state=R.IDLE);e&&(this.lastCurrentTime=t),this.state!==R.FRAG_LOADING&&void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*r.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){_.logger.log("media seeked to "+this.media.currentTime.toFixed(3)),this.tick()}},{key:"onMediaEnded",value:function(){_.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){_.logger.log("trigger BUFFER_RESET"),this.hls.trigger(g["default"].BUFFER_RESET),this.bufferRange=[],this.stalled=!1,this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(e){var t,r=!1,i=!1;e.levels.forEach(function(e){t=e.audioCodec,t&&(t.indexOf("mp4a.40.2")!==-1&&(r=!0),t.indexOf("mp4a.40.5")!==-1&&(i=!0))}),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&_.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startLevelLoaded=!1,this.startFragRequested=!1;var a=this.config;a.autoStartLoad&&this.hls.startLoad(a.startPosition)}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,i=this.levels[r],a=t.totalduration,n=0;if(_.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),this.levelLastLoaded=r,t.live){var s=i.details;s&&t.fragments.length>0?(E["default"].mergeDetails(s,t),n=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(n,s),t.PTSKnown?_.logger.log("live playlist sliding:"+n.toFixed(3)):_.logger.log("live playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,_.logger.log("live playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(i.details=t,this.hls.trigger(g["default"].LEVEL_UPDATED,{details:t,level:r}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var o=t.startTimeOffset;isNaN(o)?t.live?(this.startPosition=this.computeLivePosition(n,t),_.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(o<0&&(_.logger.log("negative start time offset "+o+", count from end of last fragment"),o=n+a+o),_.logger.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o)}this.nextLoadPosition=this.startPosition}this.state===R.WAITING_LEVEL&&(this.state=R.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===R.KEY_LOADING&&(this.state=R.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===R.FRAG_LOADING&&t&&"main"===r.type&&r.level===t.level&&r.sn===t.sn){var i=e.stats,a=this.levels[t.level],n=a.details;if(_.logger.log("Loaded "+t.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+t.level),this.bitrateTest=!1,r.bitrateTest===!0&&this.hls.nextLoadLevel)this.state=R.IDLE,this.startFragRequested=!1,i.tparsed=i.tbuffered=performance.now(),this.hls.trigger(g["default"].FRAG_BUFFERED,{stats:i,frag:t,id:"main"}),this.tick();else{this.state=R.PARSING,this.stats=i;var s=n.totalduration,o=isNaN(t.startDTS)?t.start:t.startDTS,l=t.level,u=t.sn,d=this.config.defaultAudioCodec||a.audioCodec;this.audioCodecSwap&&(_.logger.log("swapping playlist audio codec"),void 0===d&&(d=this.lastAudioCodec),d&&(d=d.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5")),this.pendingAppending=0,_.logger.log("Parsing "+u+" of ["+n.startSN+" ,"+n.endSN+"],level "+l+", cc "+t.cc);var h=this.demuxer;h||(h=this.demuxer=new f["default"](this.hls,"main"));var c=n.PTSKnown||!n.live;h.push(e.payload,d,a.videoCodec,o,t.cc,l,u,s,t.decryptdata,c)}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent;if(t&&"main"===e.id&&e.sn===t.sn&&e.level===t.level&&this.state===R.PARSING){var r,i,a=e.tracks;if(a.audio&&this.altAudio&&delete a.audio,i=a.audio){var n=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();n&&this.audioCodecSwap&&(_.logger.log("swapping playlist audio codec"),n=n.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==i.metadata.channelCount&&s.indexOf("firefox")===-1&&(n="mp4a.40.5"),s.indexOf("android")!==-1&&(n="mp4a.40.2",_.logger.log("Android: force audio codec to"+n)),i.levelCodec=n,i.id=e.id}if(i=a.video,i&&(i.levelCodec=this.levels[this.level].videoCodec,i.id=e.id),e.unique){var o={codec:"",levelCodec:""};for(r in e.tracks)i=a[r],o.container=i.container,o.codec&&(o.codec+=",",o.levelCodec+=","),i.codec&&(o.codec+=i.codec),i.levelCodec&&(o.levelCodec+=i.levelCodec);a={audiovideo:o}}this.hls.trigger(g["default"].BUFFER_CODECS,a);for(r in a){i=a[r],_.logger.log("main track:"+r+",container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var l=i.initSegment;l&&(this.pendingAppending++,this.hls.trigger(g["default"].BUFFER_APPENDING,{type:r,data:l,parent:"main",content:"initSegment"}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent;if(r&&"main"===e.id&&e.sn===r.sn&&e.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===R.PARSING){var i=this.levels[this.level],a=this.fragCurrent;_.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0));var n=E["default"].updateFragPTSDTS(i.details,a.sn,e.startPTS,e.endPTS,e.startDTS,e.endDTS),s=this.hls;s.trigger(g["default"].LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:n}),"video"===e.type&&(a.dropped=e.dropped),[e.data1,e.data2].forEach(function(r){r&&(t.pendingAppending++,s.trigger(g["default"].BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))}),this.nextLoadPosition=e.endPTS,this.bufferRange.push({type:e.type,start:e.startPTS,end:e.endPTS,frag:a}),this.tick()}}},{key:"onFragParsed",value:function(e){var t=this.fragCurrent;t&&"main"===e.id&&e.sn===t.sn&&e.level===t.level&&this.state===R.PARSING&&(this.stats.tparsed=performance.now(),this.state=R.PARSED,this._checkAppendedParsed())}},{key:"onAudioTrackSwitch",value:function(e){var t=!!e.url;if(t)this.videoBuffer&&this.mediaBuffer!==this.videoBuffer&&(_.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=this.videoBuffer);else if(this.mediaBuffer!==this.media){_.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var r=this.fragCurrent;r.loader&&(_.logger.log("switching to main audio track, cancel main fragment load"),r.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(), this.demuxer=null),this.state=R.IDLE}this.altAudio=t}},{key:"onBufferCreated",value:function(e){var t=e.tracks,r=void 0,i=void 0,a=!1;for(var n in t){var s=t[n];"main"===s.id?(i=n,r=s,"video"===n&&(this.videoBuffer=t[n].buffer)):a=!0}a&&r?(_.logger.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onBufferAppended",value:function(e){if("main"===e.parent)switch(this.state){case R.PARSING:case R.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===R.PARSED&&0===this.pendingAppending){var e=this.fragCurrent,t=this.stats;if(e){this.fragPrevious=e,t.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*t.total/(t.tbuffered-t.tfirst)),this.hls.trigger(g["default"].FRAG_BUFFERED,{stats:t,frag:e,id:"main"});var r=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("main buffered : "+b["default"].toString(r.buffered)),this.state=R.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=this.media,i=r&&h["default"].isBuffered(r,r.currentTime)&&h["default"].isBuffered(r,r.currentTime+.5);switch(e.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal){var a=this.fragLoadError;a?a++:a=1;var n=this.config;if(a<=n.fragLoadingMaxRetry||i||t.autoLevel&&t.level){this.fragLoadError=a,t.loadCounter=0;var s=Math.min(Math.pow(2,a-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);_.logger.warn("mediaController: frag loading failed, retry in "+s+" ms"),this.retryDate=performance.now()+s,this.state=R.FRAG_LOADING_WAITING_RETRY}else _.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.trigger(g["default"].ERROR,e),this.state=R.ERROR}break;case k.ErrorDetails.FRAG_LOOP_LOADING_ERROR:e.fatal||(i?(this._reduceMaxBufferLength(t.duration),this.state=R.IDLE):t.autoLevel&&0!==t.level||(e.fatal=!0,this.hls.trigger(g["default"].ERROR,e),this.state=R.ERROR));break;case k.ErrorDetails.LEVEL_LOAD_ERROR:case k.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==R.ERROR&&(e.fatal?(this.state=R.ERROR,_.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):this.state===R.WAITING_LEVEL&&(this.state=R.IDLE));break;case k.ErrorDetails.BUFFER_FULL_ERROR:this.state!==R.PARSING&&this.state!==R.PARSED||(i?(this._reduceMaxBufferLength(t.duration),this.state=R.IDLE):(_.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.state=R.PAUSED,this.hls.trigger(g["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY})))}}}},{key:"_reduceMaxBufferLength",value:function(e){var t=this.config;t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,_.logger.warn("reduce max buffer length to "+t.maxMaxBufferLength+"s and switch to IDLE state"),this.fragLoadIdx+=2*t.fragLoadingLoopThreshold)}},{key:"_checkBuffer",value:function(){var e=this.media;if(e&&e.readyState){var t=e.currentTime,r=e.buffered;if(!this.loadedmetadata&&r.length){this.loadedmetadata=!0;var i=this.startPosition,a=h["default"].isBuffered(e,i);t===i&&a||(_.logger.log("target start position:"+i),a||(i=r.start(0),_.logger.log("target start position not buffered, seek to buffered.start(0) "+i)),_.logger.log("adjust currentTime from "+t+" to "+i),e.currentTime=i)}else if(this.immediateSwitch)this.immediateLevelSwitchEnd();else{var n=h["default"].bufferInfo(e,t,0),s=!(e.paused||e.ended||0===e.buffered.length),o=.5,l=t>e.playbackRate*this.lastCurrentTime,u=this.config;if(this.stalled&&l&&(this.stalled=!1,_.logger.log("playback not stuck anymore @"+t)),s&&n.len<=o&&(l?(o=0,this.seekHoleNudgeDuration=0):this.stalled?this.seekHoleNudgeDuration+=u.seekHoleNudgeDuration:(this.seekHoleNudgeDuration=0,_.logger.log("playback seems stuck @"+t),this.hls.trigger(g["default"].ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0),n.len<=o)){var d=n.nextStart,c=d-t;if(d&&c0){_.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+d+" + nudge "+this.seekHoleNudgeDuration);var f=d+this.seekHoleNudgeDuration-e.currentTime;e.currentTime=d+this.seekHoleNudgeDuration,this.hls.trigger(g["default"].ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:f})}}}}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=R.IDLE,this.loadedmetadata||(this.startFragRequested=!1),this.tick()}},{key:"onBufferFlushed",value:function(){var e=this.mediaBuffer?this.mediaBuffer:this.media,t=this.bufferRange,r=[],i=void 0,a=void 0;for(a=0;a-1&&this.vttFragQueues[this.currentTrackId].length){var e=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.hls.trigger(u["default"].FRAG_LOADING,{frag:e})}}},{key:"onSubtitleFragProcessed",value:function(e){e.success&&this.vttFragSNsProcessed[e.frag.trackId].push(e.frag.sn),this.currentlyProcessing=null,this.nextFrag()}},{key:"onError",value:function(e){var t=e.frag;t&&"subtitle"!==t.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())}},{key:"onSubtitleTracksUpdated",value:function(e){var t=this;c.logger.log("subtitle tracks updated"),this.tracks=e.subtitleTracks,this.clearVttFragQueues(),this.vttFragSNsProcessed={},this.tracks.forEach(function(e){t.vttFragSNsProcessed[e.id]=[]})}},{key:"onSubtitleTrackSwitch",value:function(e){this.currentTrackId=e.id,this.clearVttFragQueues()}},{key:"onSubtitleTrackLoaded",value:function(e){var t=this.vttFragSNsProcessed[e.id],r=this.vttFragQueues[e.id],i=this.currentlyProcessing?this.currentlyProcessing.sn:-1,a=function(e){return t.indexOf(e.sn)>-1},n=function(e){return r.some(function(t){return t.sn===e.sn})};e.details.fragments.forEach(function(t){a(t)||t.sn===i||n(t)||(t.trackId=e.id,r.push(t))}),this.nextFrag()}}]),t}(h["default"]);r["default"]=f},{28:28,29:29,46:46}],13:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=0&&e0;)e.removeCue(e.cues[0])}},{key:"getExistingTrack",value:function(e){var t=this.media;if(t)for(var r=0;r>>8^255&v^99,e[h]=v,t[v]=h;var g=d[h],p=d[g],y=d[p],m=257*d[v]^16843008*v;r[h]=m<<24|m>>>8,i[h]=m<<16|m>>>16,a[h]=m<<8|m>>>24,n[h]=m,m=16843009*y^65537*p^257*g^16843008*h,s[v]=m<<24|m>>>8,o[v]=m<<16|m>>>16,l[v]=m<<8|m>>>24,u[v]=m,h?(h=g^d[d[d[y^g]]],c^=d[d[c]]):h=c=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var i,a,n=this.keySize+6,s=this.invKeySchedule,o=this.invSBox,l=this.invSubMix[0],u=this.invSubMix[1],d=this.invSubMix[2],h=this.invSubMix[3],c=this.uint8ArrayToUint32Array_(r),f=c[0],v=c[1],g=c[2],p=c[3],y=new Int32Array(e),m=new Int32Array(y.length),E=void 0,T=void 0,b=void 0,k=void 0,_=void 0,R=void 0,A=void 0,S=void 0,L=void 0,w=void 0,D=void 0,O=void 0;t>>24]^u[R>>16&255]^d[A>>8&255]^h[255&S]^s[i],T=l[R>>>24]^u[A>>16&255]^d[S>>8&255]^h[255&_]^s[i+1],b=l[A>>>24]^u[S>>16&255]^d[_>>8&255]^h[255&R]^s[i+2],k=l[S>>>24]^u[_>>16&255]^d[R>>8&255]^h[255&A]^s[i+3],_=E,R=T,A=b,S=k,i+=4;E=o[_>>>24]<<24^o[R>>16&255]<<16^o[A>>8&255]<<8^o[255&S]^s[i],T=o[R>>>24]<<24^o[A>>16&255]<<16^o[S>>8&255]<<8^o[255&_]^s[i+1],b=o[A>>>24]<<24^o[S>>16&255]<<16^o[_>>8&255]<<8^o[255&R]^s[i+2],k=o[S>>>24]<<24^o[_>>16&255]<<16^o[R>>8&255]<<8^o[255&A]^s[i+3],i+=3,m[t]=this.networkToHostOrderSwap(E^f),m[t+1]=this.networkToHostOrderSwap(k^v),m[t+2]=this.networkToHostOrderSwap(b^g),m[t+3]=this.networkToHostOrderSwap(T^p),f=L,v=w,g=D,p=O,t+=4}return m.buffer}},{key:"destroy",value:function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0}}]),e}();r["default"]=n},{}],17:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r>>5,g-=E,g>0&&m+E+g<=b);)for(T=f+y*p,k={unit:e.subarray(m+E,m+E+g),pts:T,dts:T},c.samples.push(k),c.len+=g,m+=g+E,y++;m>>6)+1,o=(60&t[r+2])>>>2,o>c.length-1?void e.trigger(Event.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o}):(u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,n.logger.log("manifest codec:"+i+",ADTS data:type:"+a+",sampleingIndex:"+o+"["+c[o]+"Hz],channelConfig:"+u),/firefox|OPR/i.test(h)?o>=6?(a=5,d=new Array(4),l=o-3):(a=2,d=new Array(2),l=o):h.indexOf("android")!==-1?(a=2,d=new Array(2),l=o):(a=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&o>=6?l=o-3:((i&&i.indexOf("mp4a.40.2")!==-1&&o>=6&&1===u||!i&&1===u)&&(a=2,d=new Array(2)),l=o)),d[0]=a<<3,d[0]|=(14&o)>>1,d[1]|=(1&o)<<7,d[1]|=u<<3,5===a&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:c[o],channelCount:u,codec:"mp4a.40."+a})}}]),e}();r["default"]=o},{27:27,46:46}],21:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:null;a(this,e),this.hls=t,this.id=r,this.config=this.hls.config||n,this.typeSupported=i}return n(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(e,t,r,i,a,n,s,u,h){var f=this.demuxer;if(!f){var g=this.hls,y=this.id;if(c["default"].probe(e))f=this.typeSupported.mp2t===!0?new c["default"](g,y,p["default"],this.config):new c["default"](g,y,v["default"],this.config);else{if(!d["default"].probe(e))return void g.trigger(o["default"].ERROR,{type:l.ErrorTypes.MEDIA_ERROR,id:y,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});f=new d["default"](g,y,v["default"],this.config)}this.demuxer=f}f.push(e,t,r,i,a,n,s,u,h)}}]),e}();r["default"]=y},{19:19,26:26,27:27,29:29,39:39,40:40}],22:[function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(r,"__esModule",{value:!0});var a=e(21),n=i(a),s=e(29),o=i(s),l=e(46),u=e(1),d=i(u),h=function(e){var t=new d["default"];t.trigger=function(e){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a1?r-1:0),a=1;a0&&null!=u&&null!=u.key&&"AES-128"===u.method){null==this.decrypter&&(this.decrypter=new v["default"](this.hls));var h=this,c=performance.now();this.decrypter.decrypt(e,u.key.buffer,u.iv.buffer,function(e){h.hls.trigger(o["default"].FRAG_DECRYPTED,{level:n,sn:s,stats:{tstart:c,tdecrypt:performance.now()}}),h.pushDecrypted(e,t,r,i,a,n,s,l,d)})}else this.pushDecrypted(e,t,r,i,a,n,s,l,d)}},{key:"onWorkerMessage",value:function(e){var t=e.data,r=this.hls;switch(t.event){case"init":URL.revokeObjectURL(this.w.objectURL);break;case o["default"].FRAG_PARSING_DATA:t.data.data1=new Uint8Array(t.data1),t.data.data2=new Uint8Array(t.data2);default:r.trigger(t.event,t.data)}}}]),t}();r["default"]=p},{17:17,2:2,21:21,22:22,27:27,29:29,46:46}],24:[function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;re?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),t=e-t,t>0&&this.bitsAvailable?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,i=8,a=8;for(t=0;t>4,g>1){if(p=d+5+e[d+4],p===d+188)continue}else p=d+4;switch(v){case A:if(h){if(D&&(y=x(D))&&(M(y,!1),E&&k.codec&&(S===-1||_.codec)))return void this.remux(n,s,e,i);D={data:[],size:0}}D&&(D.data.push(e.subarray(p,d+188)),D.size+=d+188-p);break;case S:if(h){if(O&&(y=x(O))&&(N(y),E&&_.codec&&(A===-1||k.codec)))return void this.remux(n,s,e,i);O={data:[],size:0}}O&&(O.data.push(e.subarray(p,d+188)),O.size+=d+188-p);break;case L:h&&(I&&(y=x(I))&&F(y),I={data:[],size:0}),I&&(I.data.push(e.subarray(p,d+188)),I.size+=d+188-p);break;case 0:h&&(p+=e[p]+1),w=this._pmtId=C(e,p);break;case w:h&&(p+=e[p]+1);var U=P(e,p);A=U.avc,A>0&&(k.id=A),S=U.aac,S>0&&(_.id=S),L=U.id3,L>0&&(R.id=L),T&&!b&&(c.logger.log("reparse from beginning"),T=!1,d=-188),b=this.pmtParsed=!0;break;case 17:case 8191:break;default:T=!0}}else this.observer.trigger(u["default"].ERROR,{type:f.ErrorTypes.MEDIA_ERROR,id:this.id,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});D&&(y=x(D))?(M(y,!0),k.pesData=null):k.pesData=D,O&&(y=x(O))?(N(y),_.pesData=null):(O&&O.size&&c.logger.log("last AAC PES packet truncated,might overlap between fragments"),_.pesData=O),I&&(y=x(I))?(F(y),R.pesData=null):R.pesData=I,this.remux(n,s,null,i)}},{key:"remux",value:function(e,t,r,i){var a=this._avcTrack,n=a.samples,s=n.reduce(function(e,t){var r=t.units.units.reduce(function(e,t){return{len:e.len+t.data.length,nbNalu:e.nbNalu+1}},{len:0,nbNalu:0});return t.length=r.len,{len:e.len+r.len,nbNalu:e.nbNalu+r.nbNalu}},{len:0,nbNalu:0});a.len=s.len,a.nbNalu=s.nbNalu,this.remuxer.remux(e,t,this._aacTrack,this._avcTrack,this._id3Track,this._txtTrack,i,this.contiguous,this.accurateTimeOffset,r)}},{key:"destroy",value:function(){this.switchLevel(),this._initPTS=this._initDTS=void 0,this._duration=0}},{key:"_parsePAT",value:function(e,t){return(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(e,t){var r,i,a,n,s={aac:-1,avc:-1,id3:-1};for(r=(15&e[t+1])<<8|e[t+2],i=t+3+r-4,a=(15&e[t+10])<<8|e[t+11],t+=12+a;t1;){var c=new Uint8Array(h[0].length+h[1].length);c.set(h[0]),c.set(h[1],h[0].length),h[0]=c,h.splice(1,1)}if(t=h[0],i=(t[0]<<16)+(t[1]<<8)+t[2],1===i){if(a=(t[4]<<8)+t[5],a&&a>e.size-6)return null;for(r=t[7],192&r&&(o=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,o>4294967295&&(o-=8589934592),64&r?(l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,l>4294967295&&(l-=8589934592)):l=o),n=t[8],u=n+9,e.size-=u,s=new Uint8Array(e.size);h.length;){t=h.shift();var f=t.byteLength;if(u){if(u>f){u-=f;continue}t=t.subarray(u),f-=u,u=0}s.set(t,d),d+=f}return a&&(a-=n+3),{data:s,pts:o,dts:l,len:a}}return null}},{key:"pushAccesUnit",value:function(e,t){e.units.units.length&&(!this.config.forceKeyFrameOnDiscontinuity||e.key===!0||t.sps&&(t.samples.length||this.contiguous)?t.samples.push(e):t.dropped++),e.debug.length&&c.logger.log(e.pts+"/"+e.dts+":"+e.debug+","+e.units.length)}},{key:"_parseAVCPES",value:function(e,t){var r,i,a,n=this,s=this._avcTrack,o=this._parseAVCNALu(e.data),l=!1,u=this.avcSample;e.data=null,o.forEach(function(t){switch(t.type){case 1:i=!0,l&&u&&(u.debug+="NDR ");break;case 5:i=!0,u||(u=n.avcSample=n._createAVCSample(!0,e.pts,e.dts,"")),l&&(u.debug+="IDR "),u.key=!0;break;case 6:i=!0,l&&u&&(u.debug+="SEI "),r=new h["default"](n.discardEPB(t.data)),r.readUByte();for(var o=0,d=0,c=!1,f=0;!c&&r.bytesAvailable>1;){o=0;do f=r.readUByte(),o+=f;while(255===f);d=0;do f=r.readUByte(),d+=f;while(255===f);if(4===o&&0!==r.bytesAvailable){c=!0;var v=r.readUByte();if(181===v){var g=r.readUShort();if(49===g){var p=r.readUInt();if(1195456820===p){var y=r.readUByte();if(3===y){var m=r.readUByte(),E=r.readUByte(),T=31&m,b=[m,E];for(a=0;a0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts=0)i={data:e.subarray(c,s-u-1),type:n},h.push(i);else{var f=this._getLastNalUnit();if(f&&(d&&s<=4-d&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-d)),r=s-u-1,r>0)){var v=new Uint8Array(f.data.byteLength+r);v.set(f.data,0),v.set(e.subarray(0,r),f.data.byteLength),f.data=v}}s=0&&u>=0&&(i={data:e.subarray(c,o),type:n,state:u},h.push(i)),0===h.length){var g=this._getLastNalUnit();if(g){var p=new Uint8Array(g.data.byteLength+e.byteLength);p.set(g.data,0),p.set(e,g.data.byteLength),g.data=p}}return l.naluState=u,h}},{key:"discardEPB",value:function(e){for(var t,r,i=e.byteLength,a=[],n=1;n1&&(c.logger.log("AAC: align PTS for overlapping frames by "+Math.round((_-p)/90)),p=_)}for(;n+5>>5,r-=s,r>0&&n+s+r<=d);)for(l=p+a*i,h={unit:g.subarray(n+s,n+s+r),pts:l,dts:l},v.samples.push(h),v.len+=r,n+=r+s,a++;n=564&&71===e[0]&&71===e[188]&&71===e[376]}}]),e}();r["default"]=v},{20:20,24:24,27:27,29:29,46:46}],27:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",OTHER_ERROR:"otherError"},r.ErrorDetails={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",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_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",INTERNAL_EXCEPTION:"internalException",WEBVTT_EXCEPTION:"webVTTException"}},{}],28:[function(e,t,r){"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(r,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=function(){function e(e,t){for(var r=0;r1?r-1:0),n=1;n=r.start(i)&&t<=r.end(i))return!0;return!1}},{key:"bufferInfo",value:function(e,t,r){if(!e)return{len:0,start:0,end:0,nextStart:void 0};try{var i,a=e.buffered,n=[];for(i=0;id&&(l[u-1].end=e[o].end):l.push(e[o])}else l.push(e[o])}for(o=0,i=0,a=n=t;o=h&&t=0&&ot.endSN)return 0;if(o=r-t.startSN,l=t.fragments,u=l[o],!isNaN(u.startPTS)){var h=Math.abs(u.startPTS-i);isNaN(u.deltaPTS)?u.deltaPTS=h:u.deltaPTS=Math.max(h,u.deltaPTS),i=Math.min(i,u.startPTS),a=Math.max(a,u.endPTS),n=Math.min(n,u.startDTS),s=Math.max(s,u.endDTS)}var c=i-u.start;for(u.start=u.startPTS=i,u.endPTS=a,u.startDTS=n,u.endDTS=s,u.duration=a-i,d=o;d>0;d--)e.updatePTS(l,d,d-1);for(d=o;dt?a.start=i.start+i.duration:a.start=i.start-a.duration:r>t?(i.duration=s-i.start,i.duration<0&&n.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(a.duration=i.start-s,a.duration<0&&n.logger.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!"))}}]),e}();r["default"]=s},{46:46}],33:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};a(this,e);var r=e.DefaultConfig;if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var i in r)i in t||(t[i]=r[i]);if(void 0!==t.liveMaxLatencyDurationCount&&t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(t.liveMaxLatencyDuration<=t.liveSyncDuration||void 0===t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');(0,M.enableLogs)(t.debug),this.config=t;var n=this.observer=new B["default"];n.trigger=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:-1;M.logger.log("startLoad"),this.levelController.startLoad(),this.streamController.startLoad(e),this.audioStreamController.startLoad(e)}},{key:"stopLoad",value:function(){M.logger.log("stopLoad"),this.levelController.stopLoad(),this.streamController.stopLoad(),this.audioStreamController.stopLoad()}},{key:"swapAudioCodec",value:function(){M.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){M.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){M.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){M.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){M.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){M.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){M.logger.log("set startLevel:"+e),this.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this.abrController.autoLevelCapping},set:function(e){M.logger.log("set autoLevelCapping:"+e),this.abrController.autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"audioTracks",get:function(){return this.audioTrackController.audioTracks}},{key:"audioTrack",get:function(){return this.audioTrackController.audioTrack},set:function(e){this.audioTrackController.audioTrack=e}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){return this.subtitleTrackController.subtitleTracks}},{key:"subtitleTrack",get:function(){return this.subtitleTrackController.subtitleTrack},set:function(e){this.subtitleTrackController.subtitleTrack=e}}]),e}();r["default"]=K},{1:1,10:10,11:11,12:12,13:13,14:14,27:27,29:29,3:3,35:35,36:36,37:37,4:4,44:44,46:46,5:5,53:53,6:6,7:7,9:9}],34:[function(e,t,r){"use strict";t.exports=e(33)["default"]},{33:33}],35:[function(e,t,r){"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")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r>8*(15-r)&255;return t}},{key:"fragmentDecryptdataFromLevelkey",value:function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&(r=this.cloneObj(e),r.iv=this.createInitializationVector(t)),r}},{key:"avc1toavcoti",value:function(e){var t,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(e,t,r,i){var a,n,s,o=0,l=0,u={type:null,version:null,url:t,fragments:[],live:!0,startSN:0},d={method:null,key:null,iv:null,uri:null},h=0,c=null,f=null,v=null,g=null,m=null,E=null,T=[];for(s=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT(INF): *(\d+(?:\.\d+)?)(?:,(.*))?)|(?:(?!#)()(\S.+))|(?:#EXT-X-(BYTERANGE): *(\d+(?:@\d+(?:\.\d+)?)?)|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.+))|(?:#EXT-X-(VERSION):(\d+))|(?:(#)(.*):(.*))|(?:(#)(.*)))(?:.*)\r?\n?/g;null!==(n=s.exec(e));)switch(n.shift(),n=n.filter(function(e){return void 0!==e}),n[0]){case"PLAYLIST-TYPE":u.type=n[1].toUpperCase();break;case"MEDIA-SEQUENCE":o=u.startSN=parseInt(n[1]);break;case"TARGETDURATION":u.targetduration=parseFloat(n[1]);break;case"VERSION":u.version=parseInt(n[1]);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"DIS":h++,T.push(n);break;case"DISCONTINUITY-SEQ":h=parseInt(n[1]);break;case"BYTERANGE":var b=n[1].split("@");E=1===b.length?m:parseInt(b[1]),m=parseInt(b[0])+E;break;case"INF":v=parseFloat(n[1]),g=n[2]?n[2]:null,T.push(n);break;case"":if(!isNaN(v)){var k=o++;a=this.fragmentDecryptdataFromLevelkey(d,k);var _=n[1]?this.resolve(n[1],t):null;f={url:_,type:i,duration:v,title:g,start:l,sn:k,level:r,cc:h,decryptdata:a,programDateTime:c,tagList:T},null!==E&&(f.byteRangeStartOffset=E,f.byteRangeEndOffset=m),u.fragments.push(f),l+=v,v=null,g=null,E=null,c=null,T=[]}break;case"KEY":var R=n[1],A=new p["default"](R),S=A.enumeratedString("METHOD"),L=A.URI,w=A.hexadecimalInteger("IV");S&&(d={method:null,key:null,iv:null,uri:null},L&&"AES-128"===S&&(d.method=S,d.uri=this.resolve(L,t),d.key=null,d.iv=w));break;case"START":var D=n[1],O=new p["default"](D),I=O.decimalFloatingPoint("TIME-OFFSET");isNaN(I)||(u.startTimeOffset=I);break;case"PROGRAM-DATE-TIME":c=new Date(Date.parse(n[1])),T.push(n);break;case"#":n.shift(),T.push(n);break;default:y.logger.warn("line parsed but not handled: "+n)}return f&&!f.url&&(u.fragments.pop(),l-=f.duration),u.totalduration=l,u.averagetargetduration=l/u.fragments.length,u.endSN=o-1,u}},{key:"loadsuccess",value:function(e,t,r){var i=e.data,a=e.url,n=r.type,s=r.id,o=r.level,l=this.hls;if(this.loaders[n]=void 0,void 0!==a&&0!==a.indexOf("data:")||(a=r.url),t.tload=performance.now(),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0){var d="audioTrack"!==n&&"subtitleTrack"!==n,h=this.parseLevelPlaylist(i,a,o||s||0,"audioTrack"===n?"audio":"subtitleTrack"===n?"subtitle":"main");h.tload=t.tload,"manifest"===n&&l.trigger(u["default"].MANIFEST_LOADED,{levels:[{url:a,details:h}],audioTracks:[],url:a,stats:t}),t.tparsed=performance.now(),h.targetduration?d?l.trigger(u["default"].LEVEL_LOADED,{details:h,level:o||0,id:s||0,stats:t}):"audioTrack"===n?l.trigger(u["default"].AUDIO_TRACK_LOADED,{details:h,id:s,stats:t}):"subtitleTrack"===n&&l.trigger(u["default"].SUBTITLE_TRACK_LOADED,{details:h,id:s,stats:t}):l.trigger(u["default"].ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"invalid targetduration"})}else{var f=this.parseMasterPlaylist(i,a);if(f.length){var v=this.parseMasterPlaylistMedia(i,a,"AUDIO"),g=this.parseMasterPlaylistMedia(i,a,"SUBTITLES");if(v.length){var p=!1;v.forEach(function(e){e.url||(p=!0)}),p===!1&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(y.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main"}))}l.trigger(u["default"].MANIFEST_LOADED,{levels:f,audioTracks:v,subtitles:g,url:a,stats:t})}else l.trigger(u["default"].ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no level found in manifest"})}else l.trigger(u["default"].ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(e,t){var r,i,a=t.loader;switch(t.type){case"manifest":r=c.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case"level":r=c.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case"audioTrack":r=c.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1}a&&(a.abort(),this.loaders[t.type]=void 0),this.hls.trigger(u["default"].ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:t.url,loader:a,response:e,context:t})}},{key:"loadtimeout",value:function(e,t){var r,i,a=t.loader;switch(t.type){case"manifest":r=c.ErrorDetails.MANIFEST_LOAD_TIMEOUT,i=!0;break;case"level":r=c.ErrorDetails.LEVEL_LOAD_TIMEOUT,i=!1;break;case"audioTrack":r=c.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT,i=!1}a&&(a.abort(),this.loaders[t.type]=void 0),this.hls.trigger(u["default"].ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:t.url,loader:a,context:t})}}]),t}(h["default"]);r["default"]=m},{27:27,28:28,29:29,41:41,46:46,49:49}],38:[function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a>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(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))}},{key:"mvhd",value:function(t,r){r*=t;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(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(i=0;i>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height;return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}},{key:"mp4a",value:function(t){var r=t.audiosamplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"stsd",value:function(t){return"audio"===t.type?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,i=t.duration*t.timescale,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(t,r){var i=e.sdtp(t),a=t.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.trun(t,i.length+16+16+8+16+8+8),i)}},{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 i,a,n,s,o,l,u=t.samples||[],d=u.length,h=12+16*d,c=new Uint8Array(h);for(r+=8+h,c.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var r,i=e.moov(t);return r=new Uint8Array(e.FTYP.byteLength+i.byteLength),r.set(e.FTYP),r.set(i,e.FTYP.byteLength),r}}]),e}();r["default"]=n},{}],39:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=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)}(),d.logger.log("audio mp4 timescale :"+e.timescale),h.audio={container:"audio/mp4",codec:e.codec,initSegment:c["default"].initSegment([e]),metadata:{channelCount:e.channelCount}},g&&(i=a=s[0].pts-l*r)),t.sps&&t.pps&&o.length&&(t.timescale=this.MP4_TIMESCALE,h.video={container:"video/mp4",codec:t.codec,initSegment:c["default"].initSegment([t]),metadata:{width:t.width,height:t.height}},g&&(i=Math.min(i,o[0].pts-l*r),a=Math.min(a,o[0].dts-l*r),this.observer.trigger(u["default"].INIT_PTS_FOUND,{initPTS:i}))),Object.keys(h).length?(n.trigger(u["default"].FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,g&&(this._initPTS=i,this._initDTS=a)):n.trigger(u["default"].ERROR,{type:f.ErrorTypes.MEDIA_ERROR,id:this.id,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r,i){var a,n,s,o,l,h,f,v,g=8,p=this.PES_TIMESCALE,y=this.PES2MP4SCALEFACTOR,m=e.samples,E=[],T=m.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);if(T<0){d.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(T/90)+" ms to overcome this issue");for(var b=0;b1?d.logger.log("AVC:"+R+" ms hole between fragments detected,filling it"):R<-1&&d.logger.log("AVC:"+-R+" ms overlapping between fragments detected"),l=k,m[0].dts=l+this._initDTS,o=Math.max(o-R,k),m[0].pts=o+this._initDTS,d.logger.log("Video/PTS/DTS adjusted: "+Math.round(o/90)+"/"+Math.round(l/90)+",delta:"+R+" ms")),h=l,_=m[m.length-1],v=Math.max(this._PTSNormalize(_.dts-this._initDTS,k),0),f=Math.max(this._PTSNormalize(_.pts-this._initDTS,k),0),f=Math.max(f,v);var A=navigator.vendor,S=navigator.userAgent,L=A&&A.indexOf("Apple")>-1&&S&&!S.match("CriOS");L&&(a=Math.round((v-l)/(y*(m.length-1))));for(var w=0;w0?I-1:I].dts;if(N.stretchShortVideoTrack){var U=N.maxBufferHole,B=N.maxSeekHole,G=Math.floor(Math.min(U,B)*p),j=(i?o+i*p:this.nextAacPts)-C.pts;j>G?(a=j-F,a<0&&(a=F),d.logger.log("It is approximately "+j/90+" ms to the next segment; using duration "+a/90+" ms for the last video frame.")):a=F}else a=F}a/=y,x=Math.round((C.pts-C.dts)/y)}E.push({size:P,duration:a,cts:x,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:C.key?2:1,isNonSync:C.key?0:1}})}this.nextAvcDts=v+a*y;var H=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,E.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var V=E[0].flags;V.dependsOn=2,V.isNonSync=0}e.samples=E,s=c["default"].moof(e.sequenceNumber++,l/y,e),e.samples=[];var K={id:this.id,level:this.level,sn:this.sn,data1:s,data2:n,startPTS:o/p,endPTS:(f+y*a)/p,startDTS:l/p,endDTS:this.nextAvcDts/p,type:"video",nb:E.length,dropped:H};return this.observer.trigger(u["default"].FRAG_PARSING_DATA,K),K}},{key:"remuxAudio",value:function(e,t,r,i){var a,n,s,l,h,f,v,g,p,y,m,E,T,b,k,_,R=this.PES_TIMESCALE,A=e.timescale,S=R/A,L=1024*e.timescale/e.audiosamplerate,w=L*S,D=8,O=[],I=[];if(e.samples.sort(function(e,t){return e.pts-t.pts}),I=e.samples,_=this.nextAacPts,r|=I.length&&_&&(Math.abs(t-_/R)<.1||Math.abs(I[0].pts-_)<20*w),r||(_=t*R),i)for(var C=0,P=_;C=w){var F=Math.round(N/w);d.logger.warn("Injecting "+F+" audio frame @ "+Math.round(P/90)/1e3+"s due to "+Math.round(N/90)+" ms gap.");for(var U=0;U.1*w,P+=w,0===C?x.pts=x.dts=this._initDTS+_:x.pts=x.dts=I[C-1].pts+w,C+=1}for(;I.length;){if(n=I.shift(),l=n.unit,y=n.pts-this._initDTS,m=n.dts-this._initDTS,void 0!==p)E=this._PTSNormalize(y,p),T=this._PTSNormalize(m,p),s.duration=Math.round((T-p)/S);else{E=this._PTSNormalize(y,_),T=this._PTSNormalize(m,_);var B=Math.round(1e3*(E-_)/R),G=0;if(r&&B){if(B>0)G=Math.round((E-_)/w),d.logger.log(B+" ms hole between AAC samples detected,filling it"),G>0&&(b=o["default"].getSilentFrame(e.channelCount),b||(b=l.slice(0)),e.len+=G*b.length);else if(B<-12){d.logger.log(-B+" ms overlapping between AAC samples detected, drop frame"),e.len-=l.byteLength;continue}E=T=_}if(v=Math.max(0,E),g=Math.max(0,T),!(e.len>0))return;h=new Uint8Array(e.len+8),a=new DataView(h.buffer),a.setUint32(0,h.byteLength),h.set(c["default"].types.mdat,4);for(var j=0;j=2&&(H=O[V-2].duration,s.duration=H),V){this.nextAacPts=E+S*H,e.len=0,e.samples=O,f=c["default"].moof(e.sequenceNumber++,g/S,e),e.samples=[];var K={id:this.id,level:this.level,sn:this.sn,data1:f,data2:h,startPTS:v/R,endPTS:this.nextAacPts/R,startDTS:g/R,endDTS:(T+S*H)/R,type:"audio",nb:V};return this.observer.trigger(u["default"].FRAG_PARSING_DATA,K),K}return null}},{key:"remuxEmptyAudio",value:function(e,t,r,i){var a=this.PES_TIMESCALE,n=e.timescale?e.timescale:e.audiosamplerate,s=a/n,l=this.nextAacPts,u=(void 0!==l?l:i.startDTS*a)+this._initDTS,h=i.endDTS*a+this._initDTS,c=1024,f=s*c,v=Math.ceil((h-u)/f),g=o["default"].getSilentFrame(e.channelCount);if(d.logger.warn("remux empty Audio"),!g)return void d.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var p=[],y=0;y4294967296;)e+=r;return e}},{key:"passthrough",get:function(){return!1}}]),e}();r["default"]=v},{27:27,29:29,30:30,38:38,46:46,47:47}],40:[function(e,t,r){"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(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;iNumber.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,i={};null!==(t=r.exec(e));){var a=t[2],n='"';0===a.indexOf(n)&&a.lastIndexOf(n)===a.length-1&&(a=a.slice(1,-1)),i[t[1]]=a}return i}}]),e}();r["default"]=n},{}],42:[function(e,t,r){"use strict";var i={search:function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){a=(r+i)/2|0,n=e[a];var s=t(n);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null}};t.exports=i},{}],43:[function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r=r&&console.log(this.time+" ["+e+"] "+t)}},g=function(e){for(var t=[],r=0;rl&&(v.log("ERROR","Too large cursor position "+this.pos),this.pos=l)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r=144&&this.backSpace();var t=s(e);return this.pos>=l?void v.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),void this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),T=function(){function e(t,r){i(this,e),this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new E,this.nonDisplayedMemory=new E,this.lastOutputScreen=new E,this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return a(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e,this.lastOutputScreen)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,v.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset(),this.lastOutputScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}v.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=v.time;null!==e&&this.outputFilter&&(this.outputFilter.updateData&&this.outputFilter.updateData(e,this.displayedMemory),null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),b=function(){function e(t,r,a){i(this,e),this.field=t||1,this.outputs=[r,a],this.channels=[new T(1,r),new T(2,a)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,"char":0,cmd:0,other:0}}return a(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r,i,a,n=!1;this.lastTime=e,v.setTime(e);for(var s=0;s ("+g([i,a])+")"),r=this.parseCmd(i,a),r||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(n=this.parseChars(i,a)))if(this.currChNr&&this.currChNr>=0){var o=this.channels[this.currChNr-1];o.insertChars(n)}else v.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters["char"]+=2:(this.dataCounters.other+=2,v.log("WARNING","Couldn't parse cleaned data "+g([i,a])+" orig: "+g([t[s],t[s+1]])))}else this.dataCounters.padding+=2}},{key:"parseCmd",value:function(e,t){var r=null,i=(20===e||28===e)&&32<=t&&t<=47,a=(23===e||31===e)&&33<=t&&t<=35;if(!i&&!a)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,v.log("DEBUG","Repeated command ("+g([e,t])+") is dropped"),!0;r=20===e||23===e?1:2;var n=this.channels[r-1];return 20===e||28===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"parseMidrow",value:function(e,t){var r=null;if((17===e||25===e)&&32<=t&&t<=47){if(r=17===e?1:2,r!==this.currChNr)return v.log("ERROR","Mismatch channel in midrow parsing"),!1;var i=this.channels[r-1];return i.ccMIDROW(t),v.log("DEBUG","MIDROW ("+g([e,t])+")"),!0}return!1}},{key:"parsePAC",value:function(e,t){var r=null,i=null,a=(17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127,n=(16===e||24===e)&&64<=t&&t<=95;if(!a&&!n)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=e<=23?1:2,i=64<=t&&t<=95?1===r?u[e]:h[e]:1===r?d[e]:c[e];var s=this.interpretPAC(i,t),o=this.channels[r-1];return o.setPAC(s),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"interpretPAC",value:function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1===(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r=null,i=null,a=null;if(e>=25?(r=2,a=e-8):(r=1,a=e),17<=a&&a<=19){var n=t;n=17===a?t+80:18===a?t+112:t+144,v.log("INFO","Special char '"+s(n)+"' in channel "+r),i=[n]}else 32<=e&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var o=g(i);v.log("DEBUG","Char codes = "+o.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i}},{key:"parseBackgroundAttributes",value:function(e,t){var r,i,a,n,s=(16===e||24===e)&&32<=t&&t<=47,o=(23===e||31===e)&&45<=t&&t<=47;return!(!s&&!o)&&(r={},16===e||24===e?(i=Math.floor((t-32)/2),r.background=f[i],t%2===1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),a=e<24?1:2,n=this.channels[a-1],n.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)}},{key:"reset",value:function(){for(var e=0;e=16?o--:o++,navigator.userAgent.match(/Firefox\//)?n.line=d+1:n.line=d>7?d-2:d+1,n.align="left",n.position=Math.max(0,Math.min(100,100*(o/32)+(navigator.userAgent.match(/Firefox\//)?50:0))),e.addCue(n)}}};t.exports=i},{}],45:[function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r "+t}function n(e){var t=self.console[e];return t?function(){for(var r=arguments.length,i=Array(r),n=0;n1?t-1:0),i=1;i-1;o=i+r)r=/^\/(?:\.\.\/)*/.exec(s.slice(i))[0].length,n=(n+s.substring(o,i)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(r-1)/3+"}$"),"/");return n+s.substr(o)}};t.exports=i},{}],50:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=function(){function e(e){if("string"!=typeof e)return!1;var t=n[e.toLowerCase()];return!!t&&e.toLowerCase()}function t(e){if("string"!=typeof e)return!1;var t=s[e.toLowerCase()];return!!t&&e.toLowerCase()}function r(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},u,{get:function(){return b},set:function(e){var r=t(e);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");b=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},u,{get:function(){return _},set:function(e){var r=t(e);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");_=r,this.hasBeenReset=!0}})),o.displayState=void 0,l)return o}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var a="auto",n={ "":!0,lr:!0,rl:!0},s={start:!0,middle:!0,end:!0,left:!0,right:!0};return i.prototype.getCueAsHTML=function(){var e=window.WebVTT;return e.convertCueToDOMTree(window,this.text)},i}()},{}],51:[function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function a(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new h,this.regionList=[]}function n(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}function s(){this.values=Object.create(null)}function o(e,t,r,i){var a=i?e.split(i):[e];for(var n in a)if("string"==typeof a[n]){var s=a[n].split(r);if(2===s.length){var o=s[0],l=s[1];t(o,l)}}}function l(e,t,r){function i(){var t=n(e);if(null===t)throw new Error("Malformed timestamp: "+u);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(e,t){var i=new s;o(e,function(e,t){switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),s=n[0];i.integer(e,s),i.percent(e,s)&&i.set("snapToLines",!1),i.alt(e,s,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",f,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",f,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",f,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&c.line===-1&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",f);var n=i.get("position","auto");"auto"===n&&50===c.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}function l(){e=e.replace(/^\s+/,"")}var u=e;if(l(),t.startTime=i(),l(),"-->"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);e=e.substr(3),l(),t.endTime=i(),l(),a(e,t)}Object.defineProperty(r,"__esModule",{value:!0});var u=e(50),d=i(u),h=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};s.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i=0&&t<=100))&&(this.set(e,t),!0)}};var c=new d["default"](0,0,0),f="middle"===c.align?"middle":"center";a.prototype={parse:function(e){function t(){for(var e=i.buffer,t=0;t")===-1){i.cue.id=a;continue}case"CUE":try{l(a,i.cue,i.regionList)}catch(u){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var h=a.indexOf("-->")!==-1;if(!a||h&&(s=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+="\n"),i.cue.text+=a;continue;case"BADCUE":a||(i.state="ID");continue}}}catch(u){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),(e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){throw t}return e.onflush&&e.onflush(),this}},r["default"]=a},{50:50}],52:[function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var a=e(51),n=i(a),s=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;return isNaN(t)||isNaN(r)||isNaN(i)||isNaN(a)?-1:(t+=1e3*r,t+=6e4*i,t+=36e5*a)},o={parse:function(e,t,r,i){var a=/\r\n|\n\r|\n|\r/g,o=String.fromCharCode.apply(null,new Uint8Array(e)).trim().replace(a,"\n").split("\n"),l="00:00.000",u=0,d=0,h=[],c=void 0,f=!0,v=new n["default"];v.oncue=function(e){e.startTime=Math.max(0,e.startTime+d/1e3),e.endTime+=d/1e3,e.text=decodeURIComponent(escape(e.text)),e.endTime>0&&h.push(e)},v.onparsingerror=function(e){c=e},v.onflush=function(){return c&&i?void i(c):void r(h)},o.forEach(function(e){if(f){if(e.startsWith("X-TIMESTAMP-MAP=")){f=!1,e.substr(16).split(",").forEach(function(e){e.startsWith("LOCAL:")?l=e.substr(6):e.startsWith("MPEGTS:")&&(u=parseInt(e.substr(7)))});try{t=t<0?t+8589934592:t,u-=t,d=s(l)+Math.floor(u/90),d===-1&&(c=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(r){c=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(f=!1)}v.parse(e+"\n")}),v.flush()}};t.exports=o},{51:51}],53:[function(e,t,r){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r=2&&(0===i.tfirst&&(i.tfirst=Math.max(performance.now(),i.trequest),this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout-(i.tfirst-i.trequest))),4===r))){var o=t.status;if(o>=200&&o<300){i.tload=Math.max(i.tfirst,performance.now());var l=void 0,u=void 0;"arraybuffer"===a.responseType?(l=t.response,u=l.byteLength):(l=t.responseText,u=l.length),i.loaded=i.total=u;var d={url:t.responseURL,data:l};this.callbacks.onSuccess(d,i,a)}else i.retry>=s.maxRetry||o>=400&&o<499?(n.logger.error(o+" while loading "+a.url),this.callbacks.onError({code:o,text:t.statusText},a)):(n.logger.warn(o+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),i.retry++)}}},{key:"loadtimeout",value:function(){n.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total);var r=this.callbacks.onProgress;r&&r(t,this.context,null)}}]),e}();r["default"]=s},{46:46}]},{},[34])(34)})}});