/*! JW Player version 8.9.5 Copyright (c) 2019, JW Player, All Rights Reserved This source code and its use and distribution is subject to the terms and conditions of the applicable license agreement. https://www.jwplayer.com/tos/ This product includes portions of other software. For the full text of licenses, see https://ssl.p.jwpcdn.com/player/v/8.9.5/notice.txt */ (window.webpackJsonpjwplayer=window.webpackJsonpjwplayer||[]).push([[13],{107:function(e,t,r){"use strict";var i=r(3),n=r(51),a={canplay:function(){this.trigger(i.E)},play:function(){this.stallTime=-1,this.video.paused||this.state===i.qb||this.setState(i.ob)},loadedmetadata:function(){var e={metadataType:"media",duration:this.getDuration(),height:this.video.videoHeight,width:this.video.videoWidth,seekRange:this.getSeekRange()},t=this.drmUsed;t&&(e.drm=t),this.trigger(i.K,e)},timeupdate:function(){var e=this.video.currentTime,t=this.getCurrentTime(),r=this.getDuration();if(!isNaN(r)){this.seeking||this.video.paused||this.state!==i.rb&&this.state!==i.ob||this.stallTime===e||(this.stallTime=-1,this.setState(i.qb),this.trigger(i.gb));var n={position:t,duration:r,currentTime:e,seekRange:this.getSeekRange(),metadata:{currentTime:e}};if(this.getPtsOffset){var a=this.getPtsOffset();a>=0&&(n.metadata.mpegts=a+t)}var o=this.getLiveLatency();null!==o&&(n.latency=o),(this.state===i.qb||this.seeking)&&this.trigger(i.S,n)}},click:function(e){this.trigger(i.n,e)},volumechange:function(){var e=this.video;this.trigger(i.V,{volume:Math.round(100*e.volume)}),this.trigger(i.M,{mute:e.muted})},seeked:function(){this.seeking&&(this.seeking=!1,this.trigger(i.R))},playing:function(){-1===this.stallTime&&this.setState(i.qb),this.trigger(i.gb)},pause:function(){this.state!==i.lb&&(this.video.ended||this.video.error||this.video.currentTime!==this.video.duration&&this.setState(i.pb))},progress:function(){var e=this.getDuration();if(!(e<=0||e===1/0)){var t=this.video.buffered;if(t&&0!==t.length){var r=Object(n.a)(t.end(t.length-1)/e,0,1);this.trigger(i.D,{bufferPercent:100*r,position:this.getCurrentTime(),duration:e,currentTime:this.video.currentTime,seekRange:this.getSeekRange()})}}},ratechange:function(){this.trigger(i.P,{playbackRate:this.video.playbackRate})},ended:function(){this.videoHeight=0,this.streamBitrate=-1,this.state!==i.nb&&this.state!==i.lb&&this.trigger(i.F)},loadeddata:function(){this.renderNatively&&this.setTextTracks(this.video.textTracks)}};t.a=a},108:function(e,t,r){"use strict";var i=r(5),n=r(11),a=r(80),o={container:null,volume:function(e){this.video.volume=Math.min(Math.max(0,e/100),1)},mute:function(e){this.video.muted=!!e,this.video.muted||this.video.removeAttribute("muted")},resize:function(e,t,r){var a=this.video,o=a.videoWidth,s=a.videoHeight;if(e&&t&&o&&s){var l={objectFit:"",width:"",height:""};if("uniform"===r){var u=e/t,d=o/s,c=Math.abs(u-d);c<.09&&c>.0025&&(l.objectFit="fill",r="exactfit")}if(i.Browser.ie||i.OS.iOS&&i.OS.version.major<9||i.Browser.androidNative)if("uniform"!==r){l.objectFit="contain";var f=e/t,h=o/s,p=1,g=1;"none"===r?p=g=f>h?Math.ceil(100*s/t)/100:Math.ceil(100*o/e)/100:"fill"===r?p=g=f>h?f/h:h/f:"exactfit"===r&&(f>h?(p=f/h,g=1):(p=1,g=h/f)),Object(n.e)(a,"matrix(".concat(p.toFixed(2),", 0, 0, ").concat(g.toFixed(2),", 0, 0)"))}else l.top=l.left=l.margin="",Object(n.e)(a,"");Object(n.d)(a,l)}},getContainer:function(){return this.container},setContainer:function(e){this.container=e,this.video.parentNode!==e&&e.appendChild(this.video)},remove:function(){this.stop(),this.destroy();var e=this.container;e&&e===this.video.parentNode&&e.removeChild(this.video)},atEdgeOfLiveStream:function(){if(!this.isLive())return!1;return Object(a.a)(this.video.buffered)-this.video.currentTime<=2}};t.a=o},109:function(e,t,r){"use strict";t.a={attachMedia:function(){this.eventsOn_()},detachMedia:function(){return this.eventsOff_(),this.video}}},110:function(e,t,r){"use strict";r.d(t,"b",function(){return n}),r.d(t,"a",function(){return a});var i=r(1);function n(e,t,r){var n=e+1e3,o=i.o;return t>0?(403===t&&(o=i.q),n+=a(t)):"http:"===(""+r).substring(0,5)&&"https:"===document.location.protocol?n+=12:0===t&&(n+=11),{code:n,key:o}}var a=function(e){return e>=400&&e<600?e:6}},129:function(e,t,r){"use strict";r.d(t,"b",function(){return i}),r.d(t,"a",function(){return n});var i=1,n=25},130:function(e,t,r){"use strict";function i(e,t,r){if(!e)return"";var i=e.bitrate||e.bandwidth;return function(e,t){var r=null;if(t&&e){var i=Object.keys(e),a=parseFloat(t);i.length&&!isNaN(a)&&(r=e[function(e,t){var r,i=null,n=1/0;Array.isArray(e)&&e.forEach(function(e){(r=Math.abs(e-t))0)return o;var u=e[a];3!==u&&0!==u||(l-=1,a+=1);var d=e.buffer.slice(s-10,a+l+1);o.push({data:d}),a+=l+1}return o}function s(e,t){for(var r=0;r1&&n.unshift({label:"Auto",level_id:"auto",hlsjsIndex:-1}),n}function c(e,t){return Math.max(0,Object(i.q)(t,Object(i.m)(t,function(t){return t.hlsjsIndex===e})))}var f=function(e){return e.sort(function(e,t){return e.height&&t.height?e.height===t.height?t.bitrate-e.bitrate:t.height-e.height:t.bitrate-e.bitrate})},h=window.jwplayer&&window.jwplayer.debug,p=function(){},g=function(e){return h?console[e].bind(console,"[Hls.js ".concat(e,"] ->")):p},v=(g("debug"),g("log"),g("info"),g("warn"),g("error"),h),y=r(129);function m(e){var t=e.withCredentials,r=e.aesToken,n=e.renderNatively,a=e.capLevelToPlayerSize,o=e.onXhrOpen,s={liveSyncDuration:25,autoStartLoad:!1,maxBufferSize:2e7,maxMaxBufferLength:y.a,capLevelToPlayerSize:a,renderNatively:n,debug:v,captionsTextTrack1Label:"Unknown CC",captionsTextTrack2Label:"Unknown CC"};return(t||r||o)&&(s=Object(i.k)({},s,function(e,t,r){return{xhrSetup:function(i,n){if(e&&(i.withCredentials=!0),t){var a=n.indexOf("?")>0?"&token=":"?token=";i.open("GET",n+a+t,!0)}"function"==typeof r&&r(i,n)},fetchSetup:function(r,i){if(t){var n=r.url.indexOf("?")>0?"&token=":"?token=";r.url=r.url+n+t}return e&&(i.credentials="include"),new Request(r.url,i)}}}(t,r,o))),s}var T=r(110),b=r(1),E=23e4,S=230001,_=232002,R=230002,w=232600,k=232631,A=232632,L=233600,D=233650,O=234001,I=234002;function C(e){if(e){if(/^frag/.test(e))return 2e3;if(/^(manifest|level|audioTrack)/.test(e))return 1e3;if(/^key/.test(e))return 4e3}return 0}var x=r(108),P=r(109),F=r(78),N=r(9);function M(e){return(M="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})(e)}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function B(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var G=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=function(e,t){return!t||"object"!==M(t)&&"function"!=typeof t?B(e):t}(this,U(t).call(this)),Object(i.k)(B(e),x.a,P.a,F.a),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(t,N["a"]),t}(),K=r(82);function H(e,t){var r=e[t];return!Object(i.v)(r)&&r>=0?r:null}var V=r(74),W=r(5),Y=r(3),q=r(18),X=r(107),z=r(23),J=r(75),Q=r(131);function $(e){return($="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})(e)}function Z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],i=!0,n=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(i=(o=s.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){n=!0,a=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function ee(e,t){for(var r=0;r=0,S=y.indexOf(r)>=0,x=b.o,P=E;switch(r){case i:P=w;break;case n:P=k;break;case a:x=b.n,P=A;break;case o:P=L;break;case s:P=D;break;case l:P=O;break;case u:P=I;break;case d:P=239e3;break;default:if(f===t)if(navigator.onLine){if(/TimeOut$/.test(r))P=E+1001+C(r);else if(c){var F=Object(T.b)(E,c.code,e.url,c.text);P=F.code,x=F.key,P+=C(r)}}else p=!1,S=!1,P=(h="manifestLoadError"===r)?_:R,x=b.l}return{key:x,code:P,recoverable:p,stalling:m,suppressLevel:S,fatal:h,error:e}}}(e);return function(t){function T(e,t,r){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,T),(i=function(e,t){return!t||"object"!==$(t)&&"function"!=typeof t?te(e):t}(this,ie(T).call(this))).bandwidthMonitor=Object(Q.a)(te(i),t.bandwidthEstimate),i.bitrateSelection=t.bitrateSelection,i.bufferStallTimeout=1e3,i.connectionTimeout=null,i.connectionTimeoutDuration=1e4,i.currentHlsjsLevel=null,i.currentJwItem=null,i.dvrEnd=null,i.dvrPosition=null,i.dvrUpdatedTime=0,i.eventHandler=null,i.hlsjs=null,i.hlsjsConfig=null,i.hlsjsOptions=null,i.jwConfig=t,i.jwLevels=null,i.lastEndSn=null,i.lastPosition=0,i.lastRecoveryTime=null,i.levelDuration=0,i.live=!1,i.liveEdgePosition=null,i.livePaused=!1,i.maxRetries=3,i.playerId=e,i.recoveringMediaError=!1,i.recoveringNetworkError=!1,i.recoveryInterval=5e3,i.renderNatively=ce(t.renderCaptionsNatively),i.retryCount=0,i.savedVideoProperties=!1,i.seeking=!1,i.src=null,i.staleManifestDurationMultiplier=3e3,i.staleManifestTimeout=null,i.state=Y.nb,i.streamBitrate=-1,i.streamType="VOD",i.supports=T.supports,i.supportsPlaybackRate=!0,i.video=r,i.videoFound=!1,i.videoHeight=0,i}var E,_,w;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ne(e,t)}(T,G),E=T,w=[{key:"setEdition",value:function(e){T.supports=Object(z.a)(e)}}],(_=[{key:"trigger",value:function(e,t){if(e===Y.bb&&t.newstate===Y.qb&&!this.videoHeight){var r=this.getCurrentHlsjsLevel();this.checkAdaptation(r)}re(ie(T.prototype),"trigger",this).call(this,e,t)}},{key:"initHlsjs",value:function(t){var r={withCredentials:!!fe(t,this.jwConfig,"withCredentials"),aesToken:fe(t,this.jwConfig,"aestoken"),renderNatively:this.renderNatively,capLevelToPlayerSize:!t.stereomode,onXhrOpen:t.sources[0].onXhrOpen};this.setupSideloadedTracks(t.tracks),this.hlsjs&&Object(i.C)(this.hlsjsOptions)(r)||(this.hlsjsOptions=r,this.restoreVideoProperties(),this.stopStaleTimeout(),this.stopConnectionTimeout(),this.hlsjsConfig=m(r),this.hlsjs=new e(this.hlsjsConfig),this.eventHandler=new l(this.video,this.createVideoListeners(),this.hlsjs,this.createHlsjsListeners()))}},{key:"init",value:function(e){this.destroy(),this.initHlsjs(e)}},{key:"preload",value:function(e){ue("preload",e),"metadata"===e.preload&&(this.maxBufferLength=y.b),this.load(e)}},{key:"load",value:function(e){var t=this.hlsjs,r=this.video,n=this.src,a=e.sources[0].file,o=a.url?a.url:a;if(n!==o||this.videoSrc!==r.src){var s=e.starttime||-1;s<-1&&(s=this.lastPosition);var l=this.bandwidthMonitor.getEstimate();Object(i.A)(l)&&(t.config.abrEwmaDefaultEstimate=l,t.config.testBandwidth=!1),ue("load",e),this.initHlsjs(e),this.currentJwItem=e,this.src=o,this.videoHeight=0,this.eventsOn_(),t.attachMedia(r),t.config.startPosition=s,t.loadSource(o),this.videoSrc=r.src}else this.maxBufferLength=y.a}},{key:"play",value:function(){if(this.livePaused){this.livePaused=!1;var e=Object(i.k)({},this.currentJwItem);delete e.startTime,this.src=null,this._clearNonNativeCues(),this.clearMetaCues(),this.clearTracks(),this.init(e),this.load(e)}return this.video.play()||Object(J.a)(this.video)}},{key:"pause",value:function(){this.stopConnectionTimeout(),this.live&&"LIVE"===this.streamType&&!this.livePaused&&this.livePause(),this.video.pause()}},{key:"livePause",value:function(){this.livePaused=!0,this.hlsjs.stopLoad(),this.stopStaleTimeout()}},{key:"stop",value:function(){this.clearTracks(),this.hlsjs&&(this.hlsjs.trigger(r),this.eventsOff_(),this.hlsjs.stopLoad()),this.pause(),this.setState(Y.nb)}},{key:"seek",value:function(e){var t=this.getDuration();if(t&&t!==1/0&&!Object(i.v)(t)){this.stopStaleTimeout(),this.stopConnectionTimeout();var r=e>=0?e:e+this.video.duration,n=this.getSeekRange();if("DVR"===this.streamType)if(this.dvrPosition=r-this.dvrEnd,e<0)r+=Math.min(12,(Object(q.a)()-this.dvrUpdatedTime)/1e3);this.seeking=!0,this.trigger(Y.Q,{position:this.getCurrentTime(),offset:r}),this.video.currentTime=r;var a=this.video.currentTime,o={position:this.getCurrentTime(),duration:t,currentTime:a,seekRange:n,metadata:{currentTime:a}};this.trigger("time",o)}else de("Returned early from seek","Duration",t)}},{key:"getCurrentQuality",value:function(){var e=0;return this.hlsjs&&!this.hlsjs.autoLevelEnabled&&(e=c(this.hlsjs.manualLevel,this.jwLevels)),e}},{key:"getQualityLevels",value:function(){return Object(i.B)(this.jwLevels,function(e){return Object(K.a)(e)})}},{key:"getCurrentAudioTrack",value:function(){return Object(i.w)(this.currentAudioTrackIndex)?this.currentAudioTrackIndex:-1}},{key:"getAudioTracks",value:function(){return this.audioTracks||[]}},{key:"getCurrentTime",value:function(){return this.live&&"DVR"===this.streamType?(this.dvrPosition||this.updateDvrPosition(this.getSeekRange()),this.dvrPosition):this.video.currentTime}},{key:"getDuration",value:function(){if(this.live&&this.currentJwItem){var e=this.levelDuration,t=this.currentJwItem.minDvrWindow;return Object(V.a)(e,t)?(this.streamType="DVR",-e):(this.streamType="LIVE",1/0)}return this.streamType="VOD",this.video.duration}},{key:"getCurrentHlsjsLevel",value:function(){var e=0;if(this.hlsjs){var t=this.hlsjs,r=t.firstLevel,i=t.currentLevel;e=i>0?i:r}return e}},{key:"getName",value:function(){return oe()}},{key:"getPlaybackRate",value:function(){return this.video.playbackRate}},{key:"getSeekRange",value:function(){var e=this.levelDuration,t=this.video,r=t.seekable,n=t.duration,a=r.length?Math.max(r.end(0),r.end(r.length-1)):n;return Object(i.v)(n)?{start:0,end:0}:{start:Math.max(0,a-e),end:a}}},{key:"getBandwidthEstimate",value:function(){var e=this.hlsjs;if(e)return e.bandwidthEstimate}},{key:"getLiveLatency",value:function(){var e=null;return this.live&&null!==this.liveEdgePosition&&(e=this.liveEdgePosition-this.video.currentTime),e}},{key:"setCurrentQuality",value:function(e){if(!(e<0)){var t,r,i,n=this.hlsjs.levels,a=(t=e,r=this.jwLevels,i=-1,t>-1&&r[t]&&(i=r[t].hlsjsIndex),i);this.hlsjs.nextLevel=a,this.trigger(Y.J,{levels:this.jwLevels,currentQuality:e}),this.bitrateSelection=this.jwLevels[e].bitrate,ue("Setting level to ",a,n[Math.max(a,0)],this.jwLevels[e])}}},{key:"setCurrentAudioTrack",value:function(e){var t=c(this.getCurrentHlsjsLevel(),this.jwLevels);if(this.jwLevels&&this.jwLevels[t]){var r=this.jwLevels[t].audioGroupId;Object(i.H)(this.audioTracksMap)&&(this.audioTracks=this.audioTracksMap[r],Object(i.w)(e)&&Object(i.H)(this.audioTracks)&&this.audioTracks[e]&&this.currentAudioTrackIndex!==e&&(this.trigger(Y.f,{tracks:this.audioTracks,currentTrack:e}),null!==this.currentAudioTrackIndex&&this.audioTracks[e].hlsjsIndex!==this.hlsjs.audioTrack&&this.trigger(Y.g,{tracks:this.audioTracks,currentTrack:e}),this.currentAudioTrackIndex=e,this.audioTracks[e].hlsjsIndex!==this.hlsjs.audioTrack&&(this.hlsjs.audioTrack=this.audioTracks[e].hlsjsIndex,ue("Setting audio track to",this.audioTracks[e]))))}}},{key:"updateAudioTrack",value:function(e){if(this.hlsjs.audioTracks.length){var t=this.currentAudioTrackIndex;Object(i.w)(t)?this.audioTracks[t].hlsjsIndex!==this.hlsjs.audioTrack&&(this.currentAudioTrackIndex=null):t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Math.max(Object(i.q)(e,Object(i.m)(e,function(e){return e.defaulttrack})),0)}(this.audioTracksMap[e.attrs.AUDIO]),this.setCurrentAudioTrack(t)}}},{key:"updateDvrPosition",value:function(e){this.dvrPosition=this.video.currentTime-e.end,this.dvrEnd=e.end,this.dvrUpdatedTime=Object(q.a)()}},{key:"setCurrentSubtitleTrack",value:function(e){this.hlsjs.subtitleTrack=e}},{key:"setPlaybackRate",value:function(e){this.video.playbackRate=this.video.defaultPlaybackRate=e}},{key:"isLive",value:function(){return this.live}},{key:"checkAdaptation",value:function(e){var t=this,r=this.hlsjs,i=r.levels,n=r.autoLevelEnabled,a=i[e];if(a){var o=a.width,s=a.height,l=a.bitrate;if(o=o||this.video.videoWidth,(s=s||this.video.videoHeight)!==this.videoHeight||l!==this.streamBitrate){var u=c(e,this.jwLevels),d="api";-1!==this.streamBitrate&&this.streamBitrate||this.videoHeight?n&&(d="auto"):d="initial choice",this.videoHeight=s,this.streamBitrate=l;var f=n?"auto":"manual",h=n&&i.length>1?"auto":this.jwLevels[u].label,p=function(){t.trigger(Y.U,{reason:d,mode:f,level:{bitrate:l,index:u,label:h,width:o,height:s}})};W.Browser.ie?this.once("time",p,this):p()}}}},{key:"createVideoListeners",value:function(){var e=this,t={waiting:function(){e.startConnectionTimeout(),e.seeking?e.setState(Y.ob):e.state===Y.qb&&(e.atEdgeOfLiveStream()&&e.setPlaybackRate(1),e.stallTime=e.video.currentTime,e.setState(Y.rb))}};return Object(i.j)(X.a,function(r,i){"error"!==i&&(t[i]=r.bind(e))}),t}},{key:"createHlsjsListeners",value:function(){var e=this,t={};t[s]=function(){ue("Media attached"),e.recoveringMediaError&&(e.hlsjs.startLoad(),e.recoveringMediaError=!1,e.resetRecovery(),e.stopStaleTimeout(),e.stopConnectionTimeout())},t[u]=function(){ue("Media detached"),e._clearNonNativeCues()},t[f]=function(e,t){ue("Manifest loaded",t)},t[h]=function(t,r){ue("Manifest parsed",r);var n=r.levels,a=e.bitrateSelection,o=e.hlsjs,s=e.jwConfig,l=-1,u=-1;e.currentHlsjsLevel=null,e.jwLevels=d(n,s.qualityLabels),Object(i.A)(a)&&(u=l=function(e,t){if(!t)return-1;for(var r=Number.MAX_VALUE,i=-1,n=0;n1;if("DVR"===e.streamType&&l&&e.updateDvrPosition(s),n&&e.state===Y.nb&&e.livePause(),a.length){var u=a[a.length-1];e.liveEdgePosition=u.start+u.duration}},t[x]=function(t,r){ue("Level PTS updated",r),e.levelDuration=r.details.totalduration},t[P]=function(e,t){ue("Frag changed",t)},t[F]=function(t,r){ue("Level changed",r);var i=r.level,n=e.hlsjs.levels[i];i!==e.currentHlsjsLevel?(ue("Level switch complete",i,n),e.setCurrentLevel(i)):e.checkAdaptation(i)},t[N]=function(t,r){ue("Frag metadata parsed",r);var s=e.hlsjs.levels[r.frag.level],l=s?s.details:null,u=l?Object(i.m)(l.fragments,function(e){return e.sn===r.frag.sn}):null;Object(i.j)(r.samples,function(t){var r=t.unit,s=t.data,d=t.pts,c=function(e){for(var t=0,r=0,i=10,s=[];t+a=e.lastRecoveryTime+e.recoveryInterval?(de("Attempting to recover, retry count:",e.retryCount),n===Te?(e.recoveringNetworkError=!0,e.hlsjs.startLoad()):n===me&&(e.recoveringMediaError=!0,e.hlsjs.recoverMediaError()),e.retryCount+=1,e.lastRecoveryTime=f):de("Recovery not attempted - too little time between attempts",f-e.lastRecoveryTime):e.handleError(i.code,r,a)}},t}},{key:"eventsOn_",value:function(){var e=this.bandwidthMonitor,t=this.eventHandler;ue("eventsOn_"),t.on(),e.start()}},{key:"eventsOff_",value:function(){var e=this.bandwidthMonitor,t=this.eventHandler,r=this.hlsjs;ue("eventsOff_"),r&&(this.disableTextTrack(),this.lastPosition=this.video.currentTime,r.detachMedia(),t.off()),this.off(null,null,this),e.stop(),this.resetLifecycleVariables()}},{key:"handleError",value:function(e,t,r){this.resetLifecycleVariables(),this.trigger(Y.G,new b.s(r,e,t))}},{key:"destroy",value:function(){this.hlsjs&&(this.eventsOff_(),this.hlsjs.destroy(),this.hlsjs=null,ue("Hlsjs destroyed"))}},{key:"stopStaleTimeout",value:function(){clearTimeout(this.staleManifestTimeout),this.staleManifestTimeout=null}},{key:"startConnectionTimeout",value:function(){var e=this;this.connectionTimeout||(this.connectionTimeout=setTimeout(function(){navigator.onLine?e.hlsjs.startLoad():e.handleError(R,null,b.l)},this.connectionTimeoutDuration))}},{key:"stopConnectionTimeout",value:function(){clearTimeout(this.connectionTimeout),this.connectionTimeout=null}},{key:"restoreVideoProperties",value:function(){this.savedVideoProperties&&(this.volume(this.jwConfig.volume),this.mute(this.jwConfig.mute),this.savedVideoProperties=!1)}},{key:"resetRecovery",value:function(){this.retryCount=0}},{key:"checkStaleManifest",value:function(e,t,r){var i=this,n=null!==this.jwConfig.liveTimeout?this.jwConfig.liveTimeout:this.staleManifestDurationMultiplier*r;0!==n&&(t&&this.lastEndSn===e?this.staleManifestTimeout||(this.staleManifestTimeout=setTimeout(function(){i.checkStreamEnded()},n)):this.stopStaleTimeout(),this.lastEndSn=e,this.live=t)}},{key:"checkStreamEnded",value:function(){this.hlsjs&&(this.video.ended||this.atEdgeOfLiveStream())&&(this.hlsjs.stopLoad(),this.handleError(S,null,b.p))}},{key:"resetLifecycleVariables",value:function(){this.resetRecovery(),this.stopStaleTimeout(),this.stopConnectionTimeout(),this.streamBitrate=-1,this.videoFound=!1,this.videoHeight=0,this.src=null,this.currentHlsjsLevel=null,this.currentJwItem=null,this.jwLevels=null,this.lastRecoveryTime=null,this.lastEndSn=null,this.levelDuration=0,this.live=!1,this.liveEdgePosition=null,this.livePaused=!1,this.recoveringMediaError=!1,this.recoveringNetworkError=!1,this.staleManifestTimeout=null,this.streamType="VOD"}},{key:"setCurrentLevel",value:function(e){this.currentHlsjsLevel=e,this.checkAdaptation(e),this.updateAudioTrack(this.hlsjs.levels[e])}},{key:"_clearNonNativeCues",value:function(){var e=this;!this.renderNatively&&this._textTracks&&this._textTracks.forEach(function(t){e.clearCueData(t._id)})}},{key:"maxBufferLength",set:function(e){this.hlsjs&&(this.hlsjs.config.maxMaxBufferLength=e)}}])&&ee(E.prototype,_),w&&ee(E,w),T}()}r.d(t,"a",function(){return ae});var oe=function(){return{name:"hlsjs"}},se=window.jwplayer&&window.jwplayer.debug,le=function(e){return se?console[e].bind(console):function(){}},ue=le("info"),de=le("warn"),ce=function(e){return!(!W.OS.iOS&&!W.Browser.safari)||W.Browser.chrome&&e},fe=function(e,t,r){var i=e.sources[0];return void 0!==i[r]?i[r]:void 0!==e[r]?e[r]:t[r]}},141:function(e,t){var r,i;r=window,i=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js": /*!*********************************************!*\ !*** ./node_modules/eventemitter3/index.js ***! \*********************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,n="~";function a(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,i||e,a),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function u(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,o=new Array(a);i0&&o.length>n&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,s=l,console&&console.warn&&console.warn(s)}return e}function c(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=function(){for(var e=[],t=0;t0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)a(l,this,t);else{var u=l.length,d=p(l,u);for(r=0;r=0;a--)if(r[a]===t||r[a].listener===t){o=r[a].listener,n=a;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},"./node_modules/url-toolkit/src/url-toolkit.js": /*!*****************************************************!*\ !*** ./node_modules/url-toolkit/src/url-toolkit.js ***! \*****************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){var i,n,a,o,s;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=s.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=s.normalizePath(i.path),s.buildURLFromParts(i)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=n.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,c=d.substring(0,d.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(c)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(o,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=s},"./node_modules/webworkify-webpack/index.js": /*!**************************************************!*\ !*** ./node_modules/webworkify-webpack/index.js ***! \**************************************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var n="[\\.|\\-|\\+|\\w|/|@]+",a="\\((/\\*.*?\\*/)?s?.*?("+n+").*?\\)";function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function s(e,t,i){var s={};s[i]=[];var l=t.toString(),u=l.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return s;for(var d,c=u[1],f=new RegExp("(\\\\n|\\W)"+o(c)+a,"g");d=f.exec(l);)"dll-reference"!==d[3]&&s[i].push(d[3]);for(f=new RegExp("\\("+o(c)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+a,"g");d=f.exec(l);)e[d[2]]||(s[i].push(d[1]),e[d[2]]=r(d[1]).m),s[d[2]]=s[d[2]]||[],s[d[2]].push(d[4]);for(var h,p=Object.keys(s),g=0;g0},!1)}e.exports=function(e,t){t=t||{};var n={main:r.m},a=t.all?{main:Object.keys(n.main)}:function(e,t){for(var r={main:[t]},i={main:[]},n={main:{}};l(r);)for(var a=Object.keys(r),o=0;o>>8^255&v^99,e[h]=v,t[v]=h;var y=f[h],m=f[y],T=f[m],b=257*f[v]^16843008*v;i[h]=b<<24|b>>>8,n[h]=b<<16|b>>>16,a[h]=b<<8|b>>>24,o[h]=b,b=16843009*T^65537*m^257*y^16843008*h,l[v]=b<<24|b>>>8,u[v]=b<<16|b>>>16,d[v]=b<<8|b>>>24,c[v]=b,h?(h=y^f[f[f[T^y]]],p^=f[f[p]]):h=p=1}},e.prototype.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i2&&void 0!==arguments[2]?arguments[2]:{}).removePKCS7Padding,n=void 0===i||i;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.logEnabled=!0,this.observer=t,this.config=r,this.removePKCS7Padding=n,n)try{var a=d.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}return e.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},e.prototype.decrypt=function(e,t,r,o){var l=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(s.logger.log("JS AES decrypt"),this.logEnabled=!1);var u=this.decryptor;u||(this.decryptor=u=new a),u.expandKey(t),o(u.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(s.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var d=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new n(d,t)),this.fastAesKey.expandKey().then(function(n){new i(d,r).decrypt(e,n).catch(function(i){l.onWebCryptoError(i,e,t,r,o)}).then(function(e){o(e)})}).catch(function(i){l.onWebCryptoError(i,e,t,r,o)})}},e.prototype.onWebCryptoError=function(e,t,r,i,n){this.config.enableSoftwareAES?(s.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,i,n)):(s.logger.error("decrypting error : "+e.message),this.observer.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},e.prototype.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},e}();t.default=c},"./src/demux/demuxer-inline.js": /*!**************************************************!*\ !*** ./src/demux/demuxer-inline.js + 11 modules ***! \**************************************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/errors.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number-isFinite.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/hls.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.js */function(e,t,r){"use strict";r.r(t);var i=r("./src/events.js"),n=r("./src/errors.js"),a=r("./src/crypt/decrypter.js"),o=r("./src/polyfills/number-isFinite.js"),s=r("./src/utils/logger.js"),l=r("./src/utils/get-self-scope.js");function u(e,t){return 255===e[t]&&240==(246&e[t+1])}function d(e,t){return 1&e[t+1]?7:9}function c(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function f(e,t){return!!(t+1>>6),!((o=(60&t[r+2])>>>2)>p.length-1))return d=(1&t[r+2])<<2,d|=(192&t[r+3])>>>6,s.logger.log("manifest codec:"+a+",ADTS data:type:"+l+",sampleingIndex:"+o+"["+p[o]+"Hz],channelConfig:"+d),/firefox/i.test(f)?o>=6?(l=5,c=new Array(4),u=o-3):(l=2,c=new Array(2),u=o):-1!==f.indexOf("android")?(l=2,c=new Array(2),u=o):(l=5,c=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&o>=6?u=o-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(o>=6&&1===d||/vivaldi/i.test(f))||!a&&1===d)&&(l=2,c=new Array(2)),u=o)),c[0]=l<<3,c[0]|=(14&o)>>1,c[1]|=(1&o)<<7,c[1]|=d<<3,5===l&&(c[1]|=(14&u)>>1,c[2]=(1&u)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:p[o],channelCount:d,codec:"mp4a.40."+l,manifestCodec:h};e.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})}(t,r,a,o);e.config=l.config,e.samplerate=l.samplerate,e.channelCount=l.channelCount,e.codec=l.codec,e.manifestCodec=l.manifestCodec,s.logger.log("parsed codec:"+e.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)}}function g(e){return 9216e4/e}function v(e,t,r,i,n){var a=function(e,t,r,i,n){var a,o=void 0,s=e.length;if(a=d(e,t),o=c(e,t),(o-=a)>0&&t+a+o<=s)return{headerLength:a,frameLength:o,stamp:r+i*n}}(t,r,i,n,g(e.samplerate));if(a){var o=a.stamp,s=a.headerLength,l=a.frameLength,u={unit:t.subarray(r+s,r+s+l),pts:o,dts:o};return e.samples.push(u),e.len+=l,{sample:u,length:l+s}}}var y=r("./src/demux/id3.js");var m=function(){function e(t,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=i,this.remuxer=r}return e.prototype.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},e.prototype.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(y.default.getID3Data(e,0)||[]).length,r=e.length;tt.length)){var a=this.parseHeader(t,r);if(a&&r+a.frameLength<=t.length){var o=i+n*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:t.subarray(r,r+a.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(s),e.len+=a.frameLength,{sample:s,length:a.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3,o=e[t+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==a){var s=3===r?3-i:3===i?3:4,l=1e3*b.BitratesMap[14*s+n-1],u=3===r?0:2===r?1:2,d=b.SamplingRateMap[3*u+a],c=e[t+3]>>6==3?1:2,f=b.SamplesCoefficients[r][i],h=b.BytesInSlot[i],p=8*f*h;return{sampleRate:d,channelCount:c,frameLength:parseInt(f*l/d+o,10)*h,samplesPerFrame:p}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},e.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&s.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)>0&&this.bitsAvailable?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},e.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},e.prototype.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},e.prototype.readBoolean=function(){return 1===this.readBits(1)},e.prototype.readUByte=function(){return this.readBits(8)},e.prototype.readUShort=function(){return this.readBits(16)},e.prototype.readUInt=function(){return this.readBits(32)},e.prototype.skipScalingList=function(e){var t=8,r=8,i=void 0;for(i=0;i=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},e.prototype.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<=e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},e.prototype.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},e.prototype.decryptAvcSample=function(e,t,r,i,n,a){var o=this.discardEPB(n.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,function(s){n.data=l.getAvcDecryptedUnit(o,s),a||l.decryptAvcSamples(e,t,r+1,i)})},e.prototype.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.length<=48||1!==a.type&&5!==a.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,a,o),!o)return}}}},e}();var R={video:1,audio:2,id3:3,text:4},w=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=i,this.typeSupported=n,this.remuxer=r,this.sampleAes=null}return e.prototype.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new _(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0)&&(r&&s.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)},e._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r>4>1){if((f=l+5+t[l+4])===l+188)continue}else f=l+4;switch(c){case T:d&&(_&&(h=L(_))&&void 0!==h.pts&&D(h,!1),_={data:[],size:0}),_&&(_.data.push(t.subarray(f,l+188)),_.size+=l+188-f);break;case b:d&&(R&&(h=L(R))&&void 0!==h.pts&&(y.isAAC?O(h):I(h)),R={data:[],size:0}),R&&(R.data.push(t.subarray(f,l+188)),R.size+=l+188-f);break;case E:d&&(w&&(h=L(w))&&void 0!==h.pts&&C(h),w={data:[],size:0}),w&&(w.data.push(t.subarray(f,l+188)),w.size+=l+188-f);break;case 0:d&&(f+=t[f]+1),S=this._pmtId=k(t,f);break;case S:d&&(f+=t[f]+1);var P=A(t,f,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(T=P.avc)>0&&(v.pid=T),(b=P.audio)>0&&(y.pid=b,y.isAAC=P.isAAC),(E=P.id3)>0&&(m.pid=E),p&&!g&&(s.logger.log("reparse from beginning"),p=!1,l=x-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=!0}}else this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});_&&(h=L(_))&&void 0!==h.pts?(D(h,!0),v.pesData=null):v.pesData=_,R&&(h=L(R))&&void 0!==h.pts?(y.isAAC?O(h):I(h),y.pesData=null):(R&&R.size&&s.logger.log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=R),w&&(h=L(w))&&void 0!==h.pts?(C(h),m.pesData=null):m.pesData=w,null==this.sampleAes?this.remuxer.remux(y,v,m,this._txtTrack,r,a,o):this.decryptAndRemux(y,v,m,this._txtTrack,r,a,o)},e.prototype.decryptAndRemux=function(e,t,r,i,n,a,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){s.decryptAndRemuxAvc(e,t,r,i,n,a,o)})}else this.decryptAndRemuxAvc(e,t,r,i,n,a,o)},e.prototype.decryptAndRemuxAvc=function(e,t,r,i,n,a,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){s.remuxer.remux(e,t,r,i,n,a,o)})}else this.remuxer.remux(e,t,r,i,n,a,o)},e.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e.prototype._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e.prototype._parsePMT=function(e,t,r,i){var n,a=void 0,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(n=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t1;){var f=new Uint8Array(c[0].length+c[1].length);f.set(c[0]),f.set(c[1],c[0].length),c[0]=f,c.splice(1,1)}if(1===((r=c[0])[0]<<16)+(r[1]<<8)+r[2]){if((n=(r[4]<<8)+r[5])&&n>e.size-6)return null;192&(i=r[7])&&((l=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2)>4294967295&&(l-=8589934592),64&i?((u=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>4294967295&&(u-=8589934592),l-u>54e5&&(s.logger.warn(Math.round((l-u)/9e4)+"s delta between PTS and DTS, align them"),l=u)):u=l),d=(a=r[8])+9,e.size-=d,o=new Uint8Array(e.size);for(var h=0,p=c.length;hg){d-=g;continue}r=r.subarray(d),g-=d,d=0}o.set(r,t),t+=g}return n&&(n-=a+3),{data:o,pts:l,dts:u,len:n}}return null},e.prototype.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&s.logger.log(e.pts+"/"+e.dts+":"+e.debug)},e.prototype._parseAVCPES=function(e,t){var r=this,i=this._avcTrack,n=this._parseAVCNALu(e.data),a=void 0,o=this.avcSample,s=void 0,l=!1,u=void 0,d=this.pushAccesUnit.bind(this),c=function(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}};e.data=null,o&&n.length&&!i.audFound&&(d(o,i),o=this.avcSample=c(!1,e.pts,e.dts,"")),n.forEach(function(t){switch(t.type){case 1:s=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.frame=!0;var n=t.data;if(l&&n.length>4){var f=new S(n).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(o.key=!0)}break;case 5:s=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.key=!0,o.frame=!0;break;case 6:s=!0,(a=new S(r.discardEPB(t.data))).readUByte();for(var h=0,p=0,g=!1,v=0;!g&&a.bytesAvailable>1;){h=0;do{h+=v=a.readUByte()}while(255===v);p=0;do{p+=v=a.readUByte()}while(255===v);if(4===h&&0!==a.bytesAvailable){if(g=!0,181===a.readUByte())if(49===a.readUShort())if(1195456820===a.readUInt())if(3===a.readUByte()){var y=a.readUByte(),m=31&y,T=[y,a.readUByte()];for(u=0;u0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts=0)u={data:e.subarray(d,t-o-1),type:c},l.push(u);else{var f=this._getLastNalUnit();if(f&&(s&&t<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),(n=t-o-1)>0)){var h=new Uint8Array(f.data.byteLength+n);h.set(f.data,0),h.set(e.subarray(0,n),f.data.byteLength),f.data=h}}t=0&&o>=0&&(u={data:e.subarray(d,r),type:c,state:o},l.push(u)),0===l.length){var p=this._getLastNalUnit();if(p){var g=new Uint8Array(p.data.byteLength+e.byteLength);g.set(p.data,0),g.set(e,p.data.byteLength),p.data=g}}return a.naluState=o,l},e.prototype.discardEPB=function(e){for(var t,r=e.byteLength,i=[],n=1,a=void 0;n1&&(s.logger.log("AAC: align PTS for overlapping frames by "+Math.round((E-l)/90)),l=E)}for(;h>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(e,4),i=0,r=8;i>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=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))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=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)))},e.mvex=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))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(L+1)),n=Math.floor(r%(L+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var r=t.samples||[],i=new Uint8Array(4+r.length),n=void 0,a=void 0;for(a=0;a>>8&255),r.push(255&o),r=r.concat(Array.prototype.slice.call(a));for(n=0;n>>8&255),i.push(255&o),i=i.concat(Array.prototype.slice.call(a));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(i))),l=t.width,u=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},e.esds=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]))},e.mp4a=function(t){var r=t.samplerate;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)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],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.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,a=t.height,o=Math.floor(i/(L+1)),s=Math.floor(i%(L+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(L+1)),o=Math.floor(r%(L+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=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]))},e.trun=function(t,r){var i=t.samples||[],n=i.length,a=12+16*n,o=new Uint8Array(a),s=void 0,l=void 0,u=void 0,d=void 0,c=void 0,f=void 0;for(r+=8+a,o.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),s=0;s>>24&255,u>>>16&255,u>>>8&255,255&u,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s);return e.box(e.types.trun,o)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),i=void 0;return(i=new Uint8Array(e.FTYP.byteLength+r.byteLength)).set(e.FTYP),i.set(r,e.FTYP.byteLength),i},e}();var O=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=r,this.typeSupported=i;var a=navigator.userAgent;this.isSafari=n&&n.indexOf("Apple")>-1&&a&&!a.match("CriOS"),this.ISGenerated=!1}return e.prototype.destroy=function(){},e.prototype.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},e.prototype.resetInitSegment=function(){this.ISGenerated=!1},e.prototype.remux=function(e,t,r,n,a,o,l){if(this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated){var u=e.samples.length,d=t.samples.length,c=a,f=a;if(u&&d){var h=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;c+=Math.max(0,h),f+=Math.max(0,-h)}if(u){e.timescale||(s.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a));var p=this.remuxAudio(e,c,o,l);if(d){var g=void 0;p&&(g=p.endPTS-p.startPTS),t.timescale||(s.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,f,o,g,l)}}else if(d){var v=this.remuxVideo(t,f,o,0,l);v&&e.codec&&this.remuxEmptyAudio(e,c,o,v)}}r.samples.length&&this.remuxID3(r,a),n.samples.length&&this.remuxText(n,a),this.observer.trigger(i.default.FRAG_PARSED)},e.prototype.generateIS=function(e,t,r){var a=this.observer,o=e.samples,l=t.samples,u=this.typeSupported,d="audio/mp4",c={},f={tracks:c},h=void 0===this._initPTS,p=void 0,g=void 0;if(h&&(p=g=1/0),e.config&&o.length&&(e.timescale=e.samplerate,s.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(u.mpeg?(d="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3")),c.audio={container:d,codec:e.codec,initSegment:!e.isAAC&&u.mpeg?new Uint8Array:D.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=g=o[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&l.length){var v=t.inputTimeScale;t.timescale=v,c.video={container:"video/mp4",codec:t.codec,initSegment:D.initSegment([t]),metadata:{width:t.width,height:t.height}},h&&(p=Math.min(p,l[0].pts-v*r),g=Math.min(g,l[0].dts-v*r),this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:p}))}Object.keys(c).length?(a.trigger(i.default.FRAG_PARSING_INIT_SEGMENT,f),this.ISGenerated=!0,h&&(this._initPTS=p,this._initDTS=g)):a.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},e.prototype.remuxVideo=function(e,t,r,a,o){var l,u,d,c=8,f=void 0,h=void 0,p=void 0,g=void 0,v=e.timescale,y=e.samples,m=[],T=y.length,b=this._PTSNormalize,E=this._initPTS,S=this.nextAvcDts,_=this.isSafari;if(0!==T){_&&(r|=y.length&&S&&(o&&Math.abs(t-S/v)<.1||Math.abs(y[0].pts-S-E)1?s.logger.log("AVC:"+A+" ms hole between fragments detected,filling it"):A<-1&&s.logger.log("AVC:"+-A+" ms overlapping between fragments detected"),g=S,y[0].dts=g,p=Math.max(p-A,S),y[0].pts=p,s.logger.log("Video/PTS/DTS adjusted: "+Math.round(p/90)+"/"+Math.round(g/90)+",delta:"+A+" ms")),k=y[y.length-1],d=Math.max(k.dts,0),u=Math.max(k.pts,0,d),_&&(f=Math.round((d-g)/(y.length-1)));for(var L=0,O=0,I=0;I0?B-1:B].dts;if(z.stretchShortVideoTrack){var Q=z.maxBufferHole,$=Math.floor(Q*v),Z=(a?p+a*v:this.nextAudioPts)-j.pts;Z>$?((f=Z-J)<0&&(f=J),s.logger.log("It is approximately "+Z/90+" ms to the next segment; using duration "+f/90+" ms for the last video frame.")):f=J}else f=J}H=Math.round(j.pts-j.dts)}m.push({size:K,duration:f,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:j.key?2:1,isNonSync:j.key?0:1}})}this.nextAvcDts=d+f;var ee=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,m.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var te=m[0].flags;te.dependsOn=2,te.isNonSync=0}e.samples=m,l=D.moof(e.sequenceNumber++,g,e),e.samples=[];var re={data1:l,data2:h,startPTS:p/v,endPTS:(u+f)/v,startDTS:g/v,endDTS:this.nextAvcDts/v,type:"video",hasAudio:!1,hasVideo:!0,nb:m.length,dropped:ee};return this.observer.trigger(i.default.FRAG_PARSING_DATA,re),re}},e.prototype.remuxAudio=function(e,t,r,a){var o=e.inputTimeScale,l=e.timescale,u=o/l,d=(e.isAAC?1024:1152)*u,c=this._PTSNormalize,f=this._initPTS,h=!e.isAAC&&this.typeSupported.mpeg,p=void 0,g=void 0,v=void 0,y=void 0,m=void 0,T=void 0,b=void 0,E=e.samples,S=[],_=this.nextAudioPts;if(r|=E.length&&_&&(a&&Math.abs(t-_/o)<.1||Math.abs(E[0].pts-_-f)<20*d),E.forEach(function(e){e.pts=e.dts=c(e.pts-f,t*o)}),0!==(E=E.filter(function(e){return e.pts>=0})).length){if(r||(_=a?t*o:E[0].pts),e.isAAC)for(var R=this.config.maxAudioFramesDrift,w=0,k=_;w=R*d&&I<1e4&&k){var C=Math.round(L/d);s.logger.warn("Injecting "+C+" audio frame @ "+(k/o).toFixed(3)+"s due to "+Math.round(1e3*L/o)+" ms gap.");for(var x=0;x0&&j<1e4)G=Math.round((B-_)/d),s.logger.log(j+" ms hole between AAC samples detected,filling it"),G>0&&((v=A.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(v=U.subarray()),e.len+=G*v.length);else if(j<-12){s.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(_/o).toFixed(3)+"s/"+(B/o).toFixed(3)+"s/"+-j+"ms"),e.len-=U.byteLength;continue}B=_}if(T=B,!(e.len>0))return;var K=h?e.len:e.len+8;p=h?0:8;try{y=new Uint8Array(K)}catch(e){return void this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MUX_ERROR,details:n.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating audio mdat "+K})}h||(new DataView(y.buffer).setUint32(0,K),y.set(D.types.mdat,4));for(var H=0;H=2&&(W=S[Y-2].duration,g.duration=W),Y){this.nextAudioPts=_=b+u*W,e.len=0,e.samples=S,m=h?new Uint8Array:D.moof(e.sequenceNumber++,T/u,e),e.samples=[];var q=T/o,X=_/o,z={data1:m,data2:y,startPTS:q,endPTS:X,startDTS:q,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.observer.trigger(i.default.FRAG_PARSING_DATA,z),z}return null}},e.prototype.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),o=this.nextAudioPts,l=(void 0!==o?o:i.startDTS*n)+this._initDTS,u=i.endDTS*n+this._initDTS,d=1024*a,c=Math.ceil((u-l)/d),f=A.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(s.logger.warn("remux empty Audio"),f){for(var h=[],p=0;p4294967296;)e+=r;return e},e}();var I=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t}return e.prototype.destroy=function(){},e.prototype.resetTimeStamp=function(){},e.prototype.resetInitSegment=function(){},e.prototype.remux=function(e,t,r,n,a,o,s,l){var u=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),u.trigger(i.default.FRAG_PARSING_DATA,{data1:l,startPTS:a,startDTS:a,type:d,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(i.default.FRAG_PARSED)},e}();var C=Object(l.getSelfScope)(),x=void 0;try{x=C.performance.now.bind(C.performance)}catch(e){s.logger.debug("Unable to use Performance API on this environment"),x=C.Date.now}var P=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.typeSupported=r,this.config=i,this.vendor=n}return e.prototype.destroy=function(){var e=this.demuxer;e&&e.destroy()},e.prototype.push=function(e,t,r,n,o,s,l,u,d,c,f,h){var p=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new a.default(this.observer,this.config));var v=x();g.decrypt(e,t.key.buffer,t.iv.buffer,function(e){var a=x();p.observer.trigger(i.default.FRAG_DECRYPTED,{stats:{tstart:v,tdecrypt:a}}),p.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,o,s,l,u,d,c,f,h)})}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,o,s,l,u,d,c,f,h)},e.prototype.pushDecrypted=function(e,t,r,a,o,s,l,u,d,c,f,h){var p=this.demuxer;if(!p||(l||u)&&!this.probe(e)){for(var g=this.observer,v=this.typeSupported,y=this.config,b=[{demux:w,remux:O},{demux:T.default,remux:I},{demux:m,remux:O},{demux:k,remux:O}],E=0,S=b.length;E1?r-1:0),n=1;n1?r-1:0),n=1;n0)return t.subarray(i,i+n)},e._readSize=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},e.getTimeStamp=function(t){for(var r=e.getID3Frames(t),i=0;i1&&void 0!==arguments[1]&&arguments[1],r=e.length,i=void 0,n=void 0,a=void 0,o="",s=0;s>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(i);break;case 12:case 13:n=e[s++],o+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[s++],a=e[s++],o+=String.fromCharCode((15&i)<<12|(63&n)<<6|(63&a)<<0)}}return o},e}(),n=i._utf8ArrayToStr;t.default=i},"./src/demux/mp4demuxer.js": /*!*********************************!*\ !*** ./src/demux/mp4demuxer.js ***! \*********************************/ /*! exports provided: default */function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger */"./src/utils/logger.js"),n=r(/*! ../events */"./src/events.js");var a=Math.pow(2,32)-1,o=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.remuxer=r}return e.prototype.resetTimeStamp=function(e){this.initPTS=e},e.prototype.resetInitSegment=function(t,r,i,a){if(t&&t.byteLength){var o=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==i&&(i="avc1.42e01e");var s={};o.audio&&o.video?s.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:a?t:null}:(o.audio&&(s.audio={container:"audio/mp4",codec:r,initSegment:a?t:null}),o.video&&(s.video={container:"video/mp4",codec:i,initSegment:a?t:null})),this.observer.trigger(n.default.FRAG_PARSING_INIT_SEGMENT,{tracks:s})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)},e.probe=function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.bin2str=function(e){return String.fromCharCode.apply(null,e)},e.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r},e.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r},e.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},e.findBox=function(t,r){var i=[],n=void 0,a=void 0,o=void 0,s=void 0,l=void 0,u=void 0;if(t.data?(l=t.start,o=t.end,t=t.data):(l=0,o=t.byteLength),!r.length)return null;for(n=l;n1?n+a:o,e.bin2str(t.subarray(n+4,n+8))===r[0]&&(1===r.length?i.push({data:t,start:n+8,end:u}):(s=e.findBox({data:t,start:n+8,end:u},r.slice(1))).length&&(i=i.concat(s))),n=u;return i},e.parseSegmentIndex=function(t){var r=e.findBox(t,["moov"])[0],i=r?r.end:null,n=0,a=e.findBox(t,["sidx"]),o=void 0;if(!a||!a[0])return null;o=[];var s=(a=a[0]).data[0];n=0===s?8:16;var l=e.readUint32(a,n);n+=4;n+=0===s?8:16,n+=2;var u=a.end+0,d=e.readUint16(a,n);n+=2;for(var c=0;c>>31)return void console.warn("SIDX has hierarchical references (not supported)");var g=e.readUint32(a,f);f+=4,o.push({referenceSize:p,subsegmentDuration:g,info:{duration:g/l,start:u,end:u+p-1}}),u+=p,n=f+=4}return{earliestPresentationTime:0,timescale:l,version:s,referencesCount:d,references:o,moovEndOffset:i}},e.parseInitSegment=function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach(function(t){var n=e.findBox(t,["tkhd"])[0];if(n){var a=n.data[n.start],o=0===a?12:20,s=e.readUint32(n,o),l=e.findBox(t,["mdia","mdhd"])[0];if(l){o=0===(a=l.data[l.start])?12:20;var u=e.readUint32(l,o),d=e.findBox(t,["mdia","hdlr"])[0];if(d){var c={soun:"audio",vide:"video"}[e.bin2str(d.data.subarray(d.start+8,d.start+12))];if(c){var f=e.findBox(t,["mdia","minf","stbl","stsd"]);if(f.length){f=f[0];var h=e.bin2str(f.data.subarray(f.start+12,f.start+16));i.logger.log("MP4Demuxer:"+c+":"+h+" found")}r[s]={timescale:u,type:c},r[c]={timescale:u,id:s}}}}}}),r},e.getStartDTS=function(t,r){var i,n,a=void 0;return a=e.findBox(r,["moof","traf"]),i=[].concat.apply([],a.map(function(r){return e.findBox(r,["tfhd"]).map(function(i){var n,a;return n=e.readUint32(i,4),a=t[n].timescale||9e4,e.findBox(r,["tfdt"]).map(function(t){var r,i=void 0;return r=t.data[t.start],i=e.readUint32(t,4),1===r&&(i*=Math.pow(2,32),i+=e.readUint32(t,8)),i})[0]/a})})),n=Math.min.apply(null,i),isFinite(n)?n:0},e.offsetStartDTS=function(t,r,i){e.findBox(r,["moof","traf"]).map(function(r){return e.findBox(r,["tfhd"]).map(function(n){var o=e.readUint32(n,4),s=t[o].timescale||9e4;e.findBox(r,["tfdt"]).map(function(t){var r=t.data[t.start],n=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,n-i*s);else{n*=Math.pow(2,32),n+=e.readUint32(t,8),n-=i*s,n=Math.max(n,0);var o=Math.floor(n/(a+1)),l=Math.floor(n%(a+1));e.writeUint32(t,4,o),e.writeUint32(t,8,l)}})})})},e.prototype.append=function(t,r,i,a){var o=this.initData;o||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),o=this.initData);var s,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(o,t);this.initPTS=l=u-r,this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(o,t,l),s=e.getStartDTS(o,t),this.remuxer.remux(o.audio,o.video,null,null,s,i,a,t)},e.prototype.destroy=function(){},e}();t.default=o},"./src/errors.js": /*!***********************!*\ !*** ./src/errors.js ***! \***********************/ /*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){"use strict";r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return n});var i={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},n={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_EMPTY_ERROR:"levelEmptyError",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_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",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",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},"./src/events.js": /*!***********************!*\ !*** ./src/events.js ***! \***********************/ /*! exports provided: default */function(e,t,r){"use strict";r.r(t);t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVELS_UPDATED:"hlsLevelsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACKS_CLEARED:"hlsSubtitleTracksCleared",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",CUES_PARSED:"hlsCuesParsed",NON_NATIVE_TEXT_TRACKS_FOUND:"hlsNonNativeTextTracksFound",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"}},"./src/hls.js": /*!*********************************!*\ !*** ./src/hls.js + 48 modules ***! \*********************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/demuxer-inline.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/errors.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number-isFinite.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/eventemitter3/index.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/url-toolkit/src/url-toolkit.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.r(t);var i={};r.r(i),r.d(i,"createCues",function(){return $e});var n=r("./node_modules/url-toolkit/src/url-toolkit.js"),a=r("./src/errors.js"),o=r("./src/polyfills/number-isFinite.js"),s=r("./src/events.js"),l=r("./src/utils/logger.js"),u="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};var d={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},c=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.onEvent=this.onEvent.bind(this);for(var r=arguments.length,i=Array(r>1?r-1:0),n=1;n>8*(15-r)&255;return t},e.prototype.fragmentDecryptdataFromLevelkey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new p).method=e.method,r.baseuri=e.baseuri,r.reluri=e.reluri,r.iv=this.createInitializationVector(t)),r},g(e,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=n.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var e=[];if(this.rawByteRange){var t=this.rawByteRange.split("@",2);if(1===t.length){var r=this.lastByteRangeEndOffset;e[0]=r||0}else e[0]=parseInt(t[1]);e[1]=parseInt(t[0])+e[0],this._byteRange=e}return e}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata}},{key:"endProgramDateTime",get:function(){if(!Object(o.isFiniteNumber)(this.programDateTime))return null;var e=Object(o.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}],[{key:"ElementaryStreamTypes",get:function(){return{AUDIO:"audio",VIDEO:"video"}}}]),e}(),y=function(){function e(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},e.prototype.hexadecimalInteger=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},e.prototype.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.prototype.enumeratedString=function(e){return this[e]},e.prototype.decimalResolution=function(e){var t=T.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t=void 0,r={};for(b.lastIndex=0;null!==(t=b.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}(),S={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function _(e,t){return window.MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var R=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,w=/#EXT-X-MEDIA:(.*)/g,k=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),A=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,L=/\.(mp4|m4s|m4v|m4a)$/i,D=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.findGroup=function(e,t){if(!e)return null;for(var r=null,i=0;i2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i=[],n=void 0;function a(e,t){["video","audio"].forEach(function(r){var i=e.filter(function(e){return function(e,t){var r=S[t];return!!r&&!0===r[e.slice(0,4)]}(e,r)});if(i.length){var n=i.filter(function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)});t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter(function(e){return-1===i.indexOf(e)})}}),t.unknownCodecs=e}for(R.lastIndex=0;null!=(n=R.exec(t));){var o={},s=o.attrs=new E(n[1]);o.url=e.resolve(n[2],r);var l=s.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),o.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),o.name=s.NAME,a([].concat((s.CODECS||"").split(/[ ,]+/)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=e.convertAVC1ToAVCOTI(o.videoCodec)),i.push(o)}return i},e.parseMasterPlaylistMedia=function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=void 0,o=[],s=0;for(w.lastIndex=0;null!==(a=w.exec(t));){var l={},u=new E(a[1]);if(u.TYPE===i){if(l.groupId=u["GROUP-ID"],l.instreamId=u["INSTREAM-ID"],l.name=u.NAME,l.type=i,l.default="YES"===u.DEFAULT,l.autoselect="YES"===u.AUTOSELECT,l.forced="YES"===u.FORCED,u.URI&&(l.url=e.resolve(u.URI,r)),l.lang=u.LANGUAGE,l.name||(l.name=l.lang),n.length){var d=e.findGroup(n,l.groupId);l.audioCodec=d?d.codec:n[0].codec}l.id=s++,o.push(l)}}return o},e.parseLevelPlaylist=function(e,t,r,i,n){var a=0,s=0,u=new m(t),d=new p,c=0,f=null,h=new v,g=void 0,y=void 0,T=null;for(k.lastIndex=0;null!==(g=k.exec(e));){var b=g[1];if(b){h.duration=parseFloat(b);var S=(" "+g[2]).slice(1);h.title=S||null,h.tagList.push(S?["INF",b,S]:["INF",b])}else if(g[3]){if(Object(o.isFiniteNumber)(h.duration)){var _=a++;h.type=i,h.start=s,h.levelkey=d,h.sn=_,h.level=r,h.cc=c,h.urlId=n,h.baseurl=t,h.relurl=(" "+g[3]).slice(1),O(h,f),u.fragments.push(h),f=h,s+=h.duration,h=new v}}else if(g[4]){if(h.rawByteRange=(" "+g[4]).slice(1),f){var R=f.byteRangeEndOffset;R&&(h.lastByteRangeEndOffset=R)}}else if(g[5])h.rawProgramDateTime=(" "+g[5]).slice(1),h.tagList.push(["PROGRAM-DATE-TIME",h.rawProgramDateTime]),null===T&&(T=u.fragments.length);else{for(g=g[0].match(A),y=1;y=0&&(d.method=C,d.baseuri=t,d.reluri=x,d.key=null,d.iv=P));break;case"START":var F=new E(w).decimalFloatingPoint("TIME-OFFSET");Object(o.isFiniteNumber)(F)&&(u.startTimeOffset=F);break;case"MAP":var N=new E(w);h.relurl=N.URI,h.rawByteRange=N.BYTERANGE,h.baseurl=t,h.level=r,h.type=i,h.sn="initSegment",u.initSegment=h,(h=new v).rawProgramDateTime=u.initSegment.rawProgramDateTime;break;default:l.logger.warn("line parsed but not handled: "+g)}}}return(h=f)&&!h.relurl&&(u.fragments.pop(),s-=h.duration),u.totalduration=s,u.averagetargetduration=s/u.fragments.length,u.endSN=a-1,u.startCC=u.fragments[0]?u.fragments[0].cc:0,u.endCC=c,!u.initSegment&&u.fragments.length&&u.fragments.every(function(e){return L.test(e.relurl)})&&(l.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(h=new v).relurl=u.fragments[0].relurl,h.baseurl=t,h.level=r,h.type=i,h.sn="initSegment",u.initSegment=h,u.needSidxRanges=!0),T&&function(e,t){for(var r=e[t],i=t-1;i>=0;i--){var n=e[i];n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(u.fragments,T),u},e}();function O(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(o.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var I=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:null;if(r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);this.resetInternalLoader(r.type);var n=e.data;t.tload=C.now(),0===n.indexOf("#EXTM3U")?n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},t.prototype.loaderror=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!1,e)},t.prototype.loadtimeout=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!0,null)},t.prototype._handleMasterPlaylist=function(e,r,i,n){var a=this.hls,o=e.data,u=t.getResponseUrl(e,i),d=D.parseMasterPlaylist(o,u);if(d.length){var c=d.map(function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}}),f=D.parseMasterPlaylistMedia(o,u,"AUDIO",c),h=D.parseMasterPlaylistMedia(o,u,"SUBTITLES"),p=D.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");if(f.length){var g=!1;f.forEach(function(e){e.url||(g=!0)}),!1===g&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(l.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main"}))}a.trigger(s.default.MANIFEST_LOADED,{levels:d,audioTracks:f,subtitles:h,captions:p,url:u,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,i,"no level found in manifest",n)},t.prototype._handleTrackOrLevelPlaylist=function(e,r,i,n){var l=this.hls,u=i.id,d=i.level,c=i.type,f=t.getResponseUrl(e,i),h=Object(o.isFiniteNumber)(u)?u:0,p=Object(o.isFiniteNumber)(d)?d:h,g=t.mapContextToLevelType(i),v=D.parseLevelPlaylist(e.data,f,p,g,h);if(v.tload=r.tload,v.fragments.length){if(c===x.MANIFEST){var y={url:f,details:v};l.trigger(s.default.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:f,stats:r,networkDetails:n})}if(r.tparsed=C.now(),v.needSidxRanges){var m=v.initSegment.url;this.load(m,{isSidxRequest:!0,type:c,level:d,levelDetails:v,id:u,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else i.levelDetails=v,this._handlePlaylistLoaded(e,r,i,n)}else l.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,reason:"no fragments found in level",level:i.level})},t.prototype._handleSidxRequest=function(e,t){var r=f.default.parseSegmentIndex(new Uint8Array(e.data));if(r){var i=r.references,n=t.levelDetails;i.forEach(function(e,t){var r=e.info,i=n.fragments[t];0===i.byteRange.length&&(i.rawByteRange=String(1+r.end-r.start)+"@"+String(r.start))}),n.initSegment.rawByteRange=String(r.moovEndOffset)+"@0"}},t.prototype._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===x.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:i})},t.prototype._handleNetworkError=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;l.logger.info("A network error occured while loading a "+e.type+"-type playlist");var n=void 0,o=void 0,u=this.getInternalLoader(e);switch(e.type){case x.MANIFEST:n=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case x.LEVEL:n=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case x.AUDIO_TRACK:n=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;default:o=!1}u&&(u.abort(),this.resetInternalLoader(e.type));var d={type:a.ErrorTypes.NETWORK_ERROR,details:n,fatal:o,url:e.url,loader:u,response:i,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(s.default.ERROR,d)},t.prototype._handlePlaylistLoaded=function(e,r,i,n){var a=i.type,o=i.level,l=i.id,u=i.levelDetails;if(u.targetduration)if(t.canHaveQualityLevels(i.type))this.hls.trigger(s.default.LEVEL_LOADED,{details:u,level:o||0,id:l||0,stats:r,networkDetails:n});else switch(a){case x.AUDIO_TRACK:this.hls.trigger(s.default.AUDIO_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n});break;case x.SUBTITLE_TRACK:this.hls.trigger(s.default.SUBTITLE_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,i,"invalid target duration",n)},I(t,null,[{key:"ContextType",get:function(){return x}},{key:"LevelType",get:function(){return P}}]),t}(c);var N=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this,r,s.default.FRAG_LOADING));return i.loaders={},i}return function(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)}(t,e),t.prototype.destroy=function(){var t=this.loaders;for(var r in t){var i=t[r];i&&i.destroy()}this.loaders={},e.prototype.destroy.call(this)},t.prototype.onFragLoading=function(e){var t=e.frag,r=t.type,i=this.loaders,n=this.hls.config,a=n.fLoader,s=n.loader;t.loaded=0;var u=i[r];u&&(l.logger.warn("abort previous fragment loader for type: "+r),u.abort()),u=i[r]=t.loader=n.fLoader?new a(n):new s(n);var d,c,f=void 0;f={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var h=t.byteRangeStartOffset,p=t.byteRangeEndOffset;Object(o.isFiniteNumber)(h)&&Object(o.isFiniteNumber)(p)&&(f.rangeStart=h,f.rangeEnd=p),d={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:n.fragLoadingMaxRetryTimeout},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},u.load(f,d,c)},t.prototype.loadsuccess=function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=e.data,a=r.frag;a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(s.default.FRAG_LOADED,{payload:n,frag:a,stats:t,networkDetails:i})},t.prototype.loaderror=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},t.prototype.loadtimeout=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},t.prototype.loadprogress=function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=t.frag;n.loaded=e.loaded,this.hls.trigger(s.default.FRAG_LOAD_PROGRESS,{frag:n,stats:e,networkDetails:i})},t}(c);var M=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this,r,s.default.KEY_LOADING));return i.loaders={},i.decryptkey=null,i.decrypturl=null,i}return function(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)}(t,e),t.prototype.destroy=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},c.prototype.destroy.call(this)},t.prototype.onKeyLoading=function(e){var t=e.frag,r=t.type,i=this.loaders[r],n=t.decryptdata,a=n.uri;if(a!==this.decrypturl||null===this.decryptkey){var o=this.hls.config;i&&(l.logger.warn("abort previous key loader for type:"+r),i.abort()),t.loader=this.loaders[r]=new o.loader(o),this.decrypturl=a,this.decryptkey=null;var u,d,c;u={url:a,frag:t,responseType:"arraybuffer"},d={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},t.loader.load(u,d,c)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(s.default.KEY_LOADED,{frag:t}))},t.prototype.loadsuccess=function(e,t,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(s.default.KEY_LOADED,{frag:i})},t.prototype.loaderror=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),this.loaders[t.type]=void 0,this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},t.prototype.loadtimeout=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),this.loaders[t.type]=void 0,this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},t}(c);var U="NOT_LOADED",B="APPENDING",j="PARTIAL",G="OK",K=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this,r,s.default.BUFFER_APPENDED,s.default.FRAG_BUFFERED,s.default.FRAG_LOADED));return i.bufferPadding=.2,i.fragments=Object.create(null),i.timeRanges=Object.create(null),i.config=r.config,i}return function(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)}(t,e),t.prototype.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,c.prototype.destroy.call(this),e.prototype.destroy.call(this)},t.prototype.getBufferedFrag=function(e,t){var r=this.fragments,i=Object.keys(r).filter(function(i){var n=r[i];if(n.body.type!==t)return!1;if(!n.buffered)return!1;var a=n.body;return a.startPTS<=e&&e<=a.endPTS});if(0===i.length)return null;var n=i.pop();return r[n].body},t.prototype.detectEvictedFragments=function(e,t){var r=this,i=void 0,n=void 0;Object.keys(this.fragments).forEach(function(a){var o=r.fragments[a];if(!0===o.buffered){var s=o.range[e];if(s){i=s.time;for(var l=0;l=n&&t<=a){i.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))});break}if(en)i.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))}),o=!0;else if(t<=n)break}return{time:i,partial:o}},t.prototype.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},t.prototype.getPartialFragment=function(e){var t=this,r=void 0,i=void 0,n=void 0,a=null,o=0;return Object.keys(this.fragments).forEach(function(s){var l=t.fragments[s];t.isPartial(l)&&(i=l.body.startPTS-t.bufferPadding,n=l.body.endPTS+t.bufferPadding,e>=i&&e<=n&&(r=Math.min(e-i,n-e),o<=r&&(a=l.body,o=r)))}),a},t.prototype.getState=function(e){var t=this.getFragmentKey(e),r=this.fragments[t],i=U;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?j:G:B),i},t.prototype.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},t.prototype.isTimeBuffered=function(e,t,r){for(var i=void 0,n=void 0,a=0;a=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.prototype.onFragLoaded=function(e){var t=e.frag;Object(o.isFiniteNumber)(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},t.prototype.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach(function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)})},t.prototype.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},t.prototype.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},t.prototype.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},t.prototype.removeAllFragments=function(){this.fragments=Object.create(null)},t}(c),H={search:function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var o=t(a=e[n=(r+i)/2|0]);if(o>0)r=n+1;else{if(!(o<0))return a;i=n-1}}return null}};var V=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,i=0;i=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){var i=e.buffered,n=[],a=void 0;for(a=0;ad&&(i[u-1].end=e[l].end):i.push(e[l])}else i.push(e[l])}for(l=0,n=0,a=o=t;l=c&&t1?t-1:0),i=1;it?(i.duration=a-i.start,i.duration<0&&l.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-a,n.duration<0&&l.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!")):n.start=r>t?i.start+i.duration:Math.max(i.start-n.duration,0)}function te(e,t,r,i,n,a){var s=r;if(Object(o.isFiniteNumber)(t.startPTS)){var l=Math.abs(t.startPTS-r);Object(o.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),i=Math.max(i,t.endPTS),n=Math.min(n,t.startDTS),a=Math.max(a,t.endDTS)}var u=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=i,t.startDTS=n,t.endDTS=a,t.duration=i-r;var d=t.sn;if(!e||de.endSN)return 0;var c,f=void 0,h=void 0;for(c=d-e.startSN,(f=e.fragments)[c]=t,h=c;h>0;h--)ee(f,h,h-1);for(h=c;hi.length)return;for(var a=0;ar.startCC||e&&e.cc=e[e.length-1].endProgramDateTime)return null;r=r||0;for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=e?t[e.sn-t[0].sn+1]:null;return n&&!de(r,i,n)?n:H.search(t,de.bind(null,r,i))}function de(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function ce(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.endProgramDateTime-i>e}var fe=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.media=r,this.fragmentTracker=i,this.hls=n,this.stallReported=!1}return e.prototype.poll=function(e,t){var r=this.config,i=this.media,n=i.currentTime,a=window.performance.now();if(n!==e)return this.stallReported&&(l.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(a-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,void(this.nudgeRetry=0);if(!(i.ended||!i.buffered.length||i.readyState>2||i.seeking&&V.isBuffered(i,n))){var o=a-this.stalled,s=V.bufferInfo(i,n,r.maxBufferHole);this.stalled?(o>=1e3&&this._reportStall(s.len),this._tryFixBufferStall(s,o)):this.stalled=a}},e.prototype._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media.currentTime,a=i.getPartialFragment(n);a&&this._trySkipBufferHole(a),e.len>.5&&t>1e3*r.highBufferWatchdogPeriod&&(this.stalled=null,this._tryNudgeBuffer())},e.prototype._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,l.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},e.prototype._trySkipBufferHole=function(e){for(var t=this.hls,r=this.media,i=r.currentTime,n=0,o=0;o=n&&i1?i-1:0),a=1;a1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)},t.prototype.doTick=function(){},t}(c);var pe={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ge=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,e.apply(this,arguments))}return function(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)}(t,e),t.prototype.doTick=function(){},t.prototype.startLoad=function(){},t.prototype.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=pe.STOPPED},t.prototype._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var n=i.getState(r);return n===j||n===G}return!1},t.prototype.onMediaSeeking=function(){var e=this.config,t=this.media,r=this.mediaBuffer,i=this.state,n=t?t.currentTime:null,a=V.bufferInfo(r||t,n,this.config.maxBufferHole);if(Object(o.isFiniteNumber)(n)&&l.logger.log("media seeking to "+n.toFixed(3)),i===pe.FRAG_LOADING){var s=this.fragCurrent;if(0===a.len&&s){var u=e.maxFragLookUpTolerance,d=s.start-u,c=s.start+s.duration+u;nc?(s.loader&&(l.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=pe.IDLE):l.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else i===pe.ENDED&&(0===a.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=pe.IDLE);t&&(this.lastCurrentTime=n),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=n),this.tick()},t.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.prototype.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},t.prototype.onHandlerDestroyed=function(){this.state=pe.STOPPED,this.fragmentTracker=null},t}(he),ve=function(){function e(e,t){for(var r=0;r0&&-1===e&&(l.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=pe.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=pe.STOPPED},t.prototype.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},t.prototype.doTick=function(){switch(this.state){case pe.BUFFER_FLUSHING:this.fragLoadError=0;break;case pe.IDLE:this._doTickIdle();break;case pe.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=pe.IDLE);break;case pe.FRAG_LOADING_WAITING_RETRY:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(l.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=pe.IDLE);break;case pe.ERROR:case pe.STOPPED:case pe.FRAG_LOADING:case pe.PARSING:case pe.PARSED:case pe.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},t.prototype._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch)){var i=0;this.loadedmetadata?i=r.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition);var n=e.nextLoadLevel,a=this.levels[n];if(a){var o=a.bitrate,u=void 0;u=o?Math.max(8*t.maxBufferSize/o,t.maxBufferLength):t.maxBufferLength,u=Math.min(u,t.maxMaxBufferLength);var d=V.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,t.maxBufferHole),c=d.len;if(!(c>=u)){l.logger.trace("buffer length of "+c.toFixed(3)+" is below max of "+u.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=n;var f=a.details;if(!f||f.live&&this.levelLastLoaded!==n)this.state=pe.WAITING_LEVEL;else{if(this._streamEnded(d,f)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(s.default.BUFFER_EOS,h),void(this.state=pe.ENDED)}this._fetchPayloadOrEos(i,d,f)}}}}},t.prototype._fetchPayloadOrEos=function(e,t,r){var i=this.fragPrevious,n=this.level,a=r.fragments,o=a.length;if(0!==o){var s=a[0].start,u=a[o-1].start+a[o-1].duration,d=t.end,c=void 0;if(r.initSegment&&!r.initSegment.data)c=r.initSegment;else if(r.live){var f=this.config.initialLiveManifestSize;if(of&&(u.currentTime=f),this.nextLoadPosition=f}if(e.PTSKnown&&t>i&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(n)if(e.hasProgramDateTime)l.logger.log("live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),d=le(a,n.endProgramDateTime,s.maxFragLookUpTolerance);else{var h=n.sn+1;if(h>=e.startSN&&h<=e.endSN){var p=a[h-e.startSN];n.cc===p.cc&&(d=p,l.logger.log("live playlist, switching playlist, load frag with next SN: "+d.sn))}d||(d=H.search(a,function(e){return n.cc-e.cc}))&&l.logger.log("live playlist, switching playlist, load frag with same CC: "+d.sn)}d||(d=a[Math.min(o-1,Math.round(o/2))],l.logger.log("live playlist, switching playlist, unknown, load middle frag : "+d.sn))}return d},t.prototype._findFragment=function(e,t,r,i,n,a,o){var s=this.hls.config,u=void 0;na-s.maxFragLookUpTolerance?0:s.maxFragLookUpTolerance):u=i[r-1];if(u){var d=u.sn-o.startSN,c=t&&u.level===t.level,f=i[d-1],h=i[d+1];if(t&&u.sn===t.sn)if(c&&!u.backtracked)if(u.sns.maxBufferHole&&t.dropped&&d&&!u.backtracked?(u=f,l.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")):(u=h,l.logger.log("SN just loaded, load next one: "+u.sn,u))}else u=null;else u.backtracked&&(h&&h.backtracked?(l.logger.warn("Already backtracked from fragment "+h.sn+", will not backtrack to fragment "+u.sn+". Loading fragment "+h.sn),u=h):(l.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),u.dropped=0,f?(u=f).backtracked=!0:d&&(u=null)))}return u},t.prototype._loadKey=function(e){this.state=pe.KEY_LOADING,this.hls.trigger(s.default.KEY_LOADING,{frag:e})},t.prototype._loadFragment=function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,this.startFragRequested=!0,Object(o.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===U||t===j?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(s.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new $(this.hls,"main")),this.state=pe.FRAG_LOADING):t===B&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},t.prototype.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,F.LevelType.MAIN)},t.prototype.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},t.prototype._checkFragmentChanged=function(){var e=void 0,t=void 0,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),V.isBuffered(r,t)?e=this.getBufferedFrag(t):V.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(s.default.FRAG_CHANGED,{frag:i});var n=i.level;this.fragPlaying&&this.fragPlaying.level===n||this.hls.trigger(s.default.LEVEL_SWITCHED,{level:n}),this.fragPlaying=i}}},t.prototype.immediateLevelSwitch=function(){if(l.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.flushMainBuffer(0,Number.POSITIVE_INFINITY)},t.prototype.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,V.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},t.prototype.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,r=void 0,i=void 0;if((t=this.getBufferedFrag(e.currentTime))&&t.startPTS>1&&this.flushMainBuffer(0,t.startPTS-1),e.paused)r=0;else{var n=this.hls.nextLoadLevel,a=this.levels[n],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*a.bitrate/(1e3*o)+1:0}if((i=this.getBufferedFrag(e.currentTime+r))&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},t.prototype.flushMainBuffer=function(e,t){this.state=pe.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(s.default.BUFFER_FLUSHING,r)},t.prototype.onMediaAttached=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),this.gapController=new fe(r,t,this.fragmentTracker,this.hls)},t.prototype.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(l.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.backtracked=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=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},t.prototype.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(o.isFiniteNumber)(t)&&l.logger.log("media seeked to "+t.toFixed(3)),this.tick()},t.prototype.onManifestLoading=function(){l.logger.log("trigger BUFFER_RESET"),this.hls.trigger(s.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},t.prototype.onManifestParsed=function(e){var t=!1,r=!1,i=void 0;e.levels.forEach(function(e){(i=e.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(t=!0),-1!==i.indexOf("mp4a.40.5")&&(r=!0))}),this.audioCodecSwitch=t&&r,this.audioCodecSwitch&&l.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1;var n=this.config;(n.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(n.startPosition)},t.prototype.onLevelLoaded=function(e){var t=e.details,r=e.level,i=this.levels[this.levelLastLoaded],n=this.levels[r],a=t.totalduration,u=0;if(l.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"], cc ["+t.startCC+", "+t.endCC+"] duration:"+a),t.live){var d=n.details;d&&t.fragments.length>0?(re(d,t),u=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(u,d),t.PTSKnown&&Object(o.isFiniteNumber)(u)?l.logger.log("live playlist sliding:"+u.toFixed(3)):(l.logger.log("live playlist - outdated PTS, unknown sliding"),se(this.fragPrevious,i,t))):(l.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,se(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(n.details=t,this.levelLastLoaded=r,this.hls.trigger(s.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var c=t.startTimeOffset;Object(o.isFiniteNumber)(c)?(c<0&&(l.logger.log("negative start time offset "+c+", count from end of last fragment"),c=u+a+c),l.logger.log("start time offset found in playlist, adjust startPosition to "+c),this.startPosition=c):t.live?(this.startPosition=this.computeLivePosition(u,t),l.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===pe.WAITING_LEVEL&&(this.state=pe.IDLE),this.tick()},t.prototype.onKeyLoaded=function(){this.state===pe.KEY_LOADING&&(this.state=pe.IDLE,this.tick())},t.prototype.onFragLoaded=function(e){var t=this.fragCurrent,r=this.hls,i=this.levels,n=this.media,a=e.frag;if(this.state===pe.FRAG_LOADING&&t&&"main"===a.type&&a.level===t.level&&a.sn===t.sn){var o=e.stats,u=i[t.level],d=u.details;if(this.bitrateTest=!1,this.stats=o,l.logger.log("Loaded "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level),a.bitrateTest&&r.nextLoadLevel)this.state=pe.IDLE,this.startFragRequested=!1,o.tparsed=o.tbuffered=window.performance.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else if("initSegment"===a.sn)this.state=pe.IDLE,o.tparsed=o.tbuffered=window.performance.now(),d.initSegment.data=e.payload,r.trigger(s.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else{l.logger.log("Parsing "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level+", cc "+t.cc),this.state=pe.PARSING,this.pendingBuffering=!0,this.appended=!1,a.bitrateTest&&(a.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:a}));var c=!(n&&n.seeking)&&(d.PTSKnown||!d.live),f=d.initSegment?d.initSegment.data:[],h=this._getAudioCodec(u);(this.demuxer=this.demuxer||new $(this.hls,"main")).push(e.payload,f,h,u.videoCodec,t,d.totalduration,c)}}this.fragLoadError=0},t.prototype.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===pe.PARSING){var i=e.tracks,n=void 0,a=void 0;if(i.audio&&this.altAudio&&delete i.audio,a=i.audio){var o=this.levels[this.level].audioCodec,u=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(l.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===u.indexOf("firefox")&&(o="mp4a.40.5"),-1!==u.indexOf("android")&&"audio/mpeg"!==a.container&&(o="mp4a.40.2",l.logger.log("Android: force audio codec to "+o)),a.levelCodec=o,a.id=e.id}for(n in(a=i.video)&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=e.id),this.hls.trigger(s.default.BUFFER_CODECS,i),i){a=i[n],l.logger.log("main track:"+n+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var d=a.initSegment;d&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,{type:n,data:d,parent:"main",content:"initSegment"}))}this.tick()}},t.prototype.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"main"===e.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===pe.PARSING){var n=this.levels[this.level],a=r;if(Object(o.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&a.addElementaryStream(v.ElementaryStreamTypes.AUDIO),!0===e.hasVideo&&a.addElementaryStream(v.ElementaryStreamTypes.VIDEO),l.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)),"video"===e.type)if(a.dropped=e.dropped,a.dropped)if(a.backtracked)l.logger.warn("Already backtracked on this fragment, appending with the gap",a.sn);else{var u=n.details;if(!u||a.sn!==u.startSN)return l.logger.warn("missing video frame(s), backtracking fragment",a.sn),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=pe.IDLE,this.fragPrevious=a,void this.tick();l.logger.warn("missing video frame(s) on first frag, appending with gap",a.sn)}else a.backtracked=!1;var d=te(n.details,a,e.startPTS,e.endPTS,e.startDTS,e.endDTS),c=this.hls;c.trigger(s.default.LEVEL_PTS_UPDATED,{details:n.details,level:this.level,drift:d,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach(function(r){r&&r.length&&t.state===pe.PARSING&&(t.appended=!0,t.pendingBuffering=!0,c.trigger(s.default.BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))}),this.tick()}},t.prototype.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===pe.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=pe.PARSED,this._checkAppendedParsed())},t.prototype.onAudioTrackSwitching=function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){l.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(l.logger.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=pe.IDLE}var n=this.hls;n.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),n.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},t.prototype.onAudioTrackSwitched=function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(l.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},t.prototype.onBufferCreated=function(e){var t=e.tracks,r=void 0,i=void 0,n=!1;for(var a in t){var o=t[a];"main"===o.id?(i=a,r=o,"video"===a&&(this.videoBuffer=t[a].buffer)):n=!0}n&&r?(l.logger.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},t.prototype.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==pe.PARSING&&t!==pe.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},t.prototype._checkAppendedParsed=function(){if(!(this.state!==pe.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;l.logger.log("main buffered : "+ae.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(s.default.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=pe.IDLE}this.tick()}},t.prototype.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&V.isBuffered(this.media,this.media.currentTime)&&V.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);l.logger.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=pe.FRAG_LOADING_WAITING_RETRY}else l.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=pe.ERROR;break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==pe.ERROR&&(e.fatal?(this.state=pe.ERROR,l.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==pe.WAITING_LEVEL||(this.state=pe.IDLE));break;case a.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==pe.PARSING&&this.state!==pe.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=pe.IDLE):(l.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},t.prototype._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,l.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},t.prototype._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}},t.prototype.onFragLoadEmergencyAborted=function(){this.state=pe.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},t.prototype.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(v.ElementaryStreamTypes.VIDEO,e.buffered),this.state=pe.IDLE,this.fragPrevious=null},t.prototype.onLevelsUpdated=function(e){this.levels=e.levels},t.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},t.prototype.computeLivePosition=function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)},t.prototype._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&(l.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},t.prototype._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(l.logger.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},ve(t,[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,l.logger.log("main stream:"+t+"->"+e),this.hls.trigger(s.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}]),t}(ge),me="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},Te=function(){function e(e,t){for(var r=0;r0){i=t[0].bitrate,t.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=t;for(var c=0;c=0&&e1&&s.loadError0){var t=this.currentLevelIndex,r=e.urlId,i=e.url[r];l.logger.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(s.default.LEVEL_LOADING,{url:i,level:t,id:r})}}},t.prototype.removeLevel=function(e,t){var r=this.levels.filter(function(r,i){return i!==e||r.url.length>1&&void 0!==t&&(r.url=r.url.filter(function(e,r){return r!==t}),r.urlId=0,!0)}).map(function(e,t){var r=e.details;return r&&r.fragments&&r.fragments.forEach(function(e){e.level=t}),e});this._levels=r,this.hls.trigger(s.default.LEVELS_UPDATED,{levels:r})},Te(t,[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){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-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(c);var Se=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=0,this.totalWeight_=0}return e.prototype.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},e.prototype.getTotalWeight=function(){return this.totalWeight_},e.prototype.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/e}return this.estimate_},e}();var _e=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Se(r),this.fast_=new Se(i)}return e.prototype.sample=function(e,t){var r=8e3*t/(e=Math.max(e,this.minDelayMs_)),i=e/1e3;this.fast_.sample(i,r),this.slow_.sample(i,r)},e.prototype.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},e.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.prototype.destroy=function(){},e}(),Re=function(){function e(e,t){for(var r=0;r500*r.duration/u){var d=e.levels,c=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/o),f=d[r.level],h=f.realBitrate?Math.max(f.realBitrate,f.bitrate):f.bitrate,p=a.total?a.total:Math.max(a.loaded,Math.round(r.duration*h/8)),g=t.currentTime,v=(p-a.loaded)/c,y=(V.bufferInfo(t,g,e.config.maxBufferHole).end-g)/u;if(y<2*r.duration/u&&v>y){var m=void 0,T=void 0;for(T=r.level-1;T>n;T--){var b=d[T].realBitrate?Math.max(d[T].realBitrate,d[T].bitrate):d[T].bitrate;if((m=r.duration*b/(6.4*c))=i;d--){var c=u[d];if(c){var f=c.details,h=f?f.totalduration/f.fragments.length:t,p=!!f&&f.live,g=void 0;g=d<=e?o*r:s*r;var v=u[d].realBitrate?Math.max(u[d].realBitrate,u[d].bitrate):u[d].bitrate,y=v*h/g;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+d+"/"+Math.round(g)+"/"+v+"/"+h+"/"+a+"/"+y),g>v&&(!y||p&&!this.bitrateTestDelay||y=0)return y;l.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var m=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay;if(0===v){var T=this.bitrateTestDelay;if(T)m=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-T,l.logger.trace("bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),d=c=1}return y=this._findBestLevel(r,f,g,s,n,v+m,d,c,a),Math.max(y,0)}}]),t}(c);var Ae=q(),Le=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this,r,s.default.MEDIA_ATTACHING,s.default.MEDIA_DETACHING,s.default.MANIFEST_PARSED,s.default.BUFFER_RESET,s.default.BUFFER_APPENDING,s.default.BUFFER_CODECS,s.default.BUFFER_EOS,s.default.BUFFER_FLUSHING,s.default.LEVEL_PTS_UPDATED,s.default.LEVEL_UPDATED));return i._msDuration=null,i._levelDuration=null,i._levelTargetDuration=10,i._live=null,i._objectUrl=null,i.bufferCodecEventsExpected=0,i.onsbue=i.onSBUpdateEnd.bind(i),i.onsbe=i.onSBUpdateError.bind(i),i.pendingTracks={},i.tracks={},i}return function(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)}(t,e),t.prototype.destroy=function(){c.prototype.destroy.call(this)},t.prototype.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(Math.abs(i.timestampOffset-e.start)>.1){var n=i.updating;try{i.abort()}catch(e){l.logger.warn("can not abort audio buffer: "+e)}n?this.audioTimestampOffset=e.start:(l.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}},t.prototype.onManifestParsed=function(e){this.bufferCodecEventsExpected=e.altAudio?2:1,l.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.prototype.onMediaAttaching=function(e){var t=this.media=e.media;if(t){var r=this.mediaSource=new Ae;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}},t.prototype.onMediaDetaching=function(){l.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){l.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this.onmso),e.removeEventListener("sourceended",this.onmse),e.removeEventListener("sourceclose",this.onmsc),this.media&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):l.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(s.default.MEDIA_DETACHED)},t.prototype.onMediaSourceOpen=function(){l.logger.log("media source opened"),this.hls.trigger(s.default.MEDIA_ATTACHED,{media:this.media});var e=this.mediaSource;e&&e.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},t.prototype.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},t.prototype.onMediaSourceClose=function(){l.logger.log("media source closed")},t.prototype.onMediaSourceEnded=function(){l.logger.log("media source ended")},t.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var e=this.sourceBuffer.audio;l.logger.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+this.audioTimestampOffset),e.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var t=this.parent,r=this.segments.reduce(function(e,r){return r.parent===t?e+1:e},0),i={},n=this.sourceBuffer;for(var a in n)i[a]=n[a].buffered;this.hls.trigger(s.default.BUFFER_APPENDED,{parent:t,pending:r,timeRanges:i}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),0===r&&this.flushLiveBackBuffer()},t.prototype.onSBUpdateError=function(e){l.logger.error("sourceBuffer error:",e),this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},t.prototype.onBufferReset=function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},t.prototype.onBufferCodecs=function(e){var t=this;if(!Object.keys(this.sourceBuffer).length){Object.keys(e).forEach(function(r){t.pendingTracks[r]=e[r]});var r=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),r&&"open"===r.readyState&&this.checkPendingTracks()}},t.prototype.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;for(var i in e)if(!t[i]){var n=e[i],o=n.levelCodec||n.codec,u=n.container+";codecs="+o;l.logger.log("creating sourceBuffer("+u+")");try{var d=t[i]=r.addSourceBuffer(u);d.addEventListener("updateend",this.onsbue),d.addEventListener("error",this.onsbe),this.tracks[i]={codec:o,container:n.container},n.buffer=d}catch(e){l.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:u})}}this.hls.trigger(s.default.BUFFER_CREATED,{tracks:e})},t.prototype.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},t.prototype.onBufferAppendFail=function(e){l.logger.error("sourceBuffer error:",e.event),this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},t.prototype.onBufferEos=function(e){var t=this.sourceBuffer,r=e.type;for(var i in t)r&&i!==r||t[i].ended||(t[i].ended=!0,l.logger.log(i+" sourceBuffer now EOS"));this.checkEos()},t.prototype.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var i=e[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}l.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){l.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},t.prototype.onBufferFlushing=function(e){this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}),this.flushBufferCounter=0,this.doFlush()},t.prototype.flushLiveBackBuffer=function(){if(this._live){var e=this.hls.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),n=t-Math.max(e,this._levelTargetDuration),a=i.length-1;a>=0;a--){var o=i[a],s=r[o].buffered;s.length>0&&n>s.start(0)&&this.removeBufferRange(o,r[o],0,n)}}},t.prototype.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},t.prototype.updateMediaElementDuration=function(){var e,t=this.hls.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer)if(!0===this.sourceBuffer[r].updating)return;e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(l.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(o.isFiniteNumber)(e))&&(l.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},t.prototype.doFlush=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;try{for(var i in r)t+=r[i].buffered.length}catch(e){l.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(s.default.BUFFER_FLUSHED)}},t.prototype.doAppending=function(){var e=this.hls,t=this.segments,r=this.sourceBuffer;if(Object.keys(r).length){if(this.media.error)return this.segments=[],void l.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(t&&t.length){var i=t.shift();try{var n=r[i.type];n?n.updating?t.unshift(i):(n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(r){l.logger.error("error while trying to append buffer:"+r.message),t.unshift(i);var o={type:a.ErrorTypes.MEDIA_ERROR,parent:i.parent};22!==r.code?(this.appendError?this.appendError++:this.appendError=1,o.details=a.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.config.appendErrorMaxRetry?(l.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],o.fatal=!0,e.trigger(s.default.ERROR,o)):(o.fatal=!1,e.trigger(s.default.ERROR,o))):(this.segments=[],o.details=a.ErrorDetails.BUFFER_FULL_ERROR,o.fatal=!1,e.trigger(s.default.ERROR,o))}}}},t.prototype.flushBuffer=function(e,t,r){var i=void 0,n=this.sourceBuffer;if(Object.keys(n).length){if(l.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+e+"/"+t),this.flushBufferCounter.5)return l.logger.log("sb remove "+e+" ["+s+","+u+"], of ["+a+","+o+"], pos:"+this.media.currentTime),t.remove(s,u),!0}}catch(e){l.logger.warn("removeBufferRange failed",e)}return!1},t}(c),De=function(){function e(e,t){for(var r=0;r0&&this.mediaWidth>0){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.prototype.getMaxLevel=function(e){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,n){return t.isLevelAllowed(n,r.restrictedLevels)&&n<=e});return t.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},t.prototype._startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.prototype._stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},t.isLevelAllowed=function(e){return-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(e)},t.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var i,n,a=e.length-1,o=0;o=t||s.height>=r)&&(i=s,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a},De(t,[{key:"mediaWidth",get:function(){var e=void 0,r=this.media;return r&&(e=r.width||r.clientWidth||r.offsetWidth,e*=t.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e=void 0,r=this.media;return r&&(e=r.height||r.clientHeight||r.offsetHeight,e*=t.contentScaleFactor),e}}],[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}]),t}(c);var Ie=window.performance,Ce=function(e){function t(r){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,e.call(this,r,s.default.MEDIA_ATTACHING))}return function(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)}(t,e),t.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},t.prototype.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},t.prototype.checkFPS=function(e,t,r){var i=Ie.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,u=1e3*a/n,d=this.hls;if(d.trigger(s.default.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),u>0&&a>d.config.fpsDroppedMonitoringThreshold*o){var c=d.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===d.autoLevelCapping||d.autoLevelCapping>=c)&&(c-=1,d.trigger(s.default.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,d.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.prototype.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},t}(c);var xe=window,Pe=xe.performance,Fe=xe.XMLHttpRequest,Ne=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t&&t.xhrSetup&&(this.xhrSetup=t.xhrSetup)}return e.prototype.destroy=function(){this.abort(),this.loader=null},e.prototype.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},e.prototype.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Pe.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},e.prototype.loadInternal=function(){var e=void 0,t=this.context;e=this.loader=new Fe;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(r){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},e.prototype.readystatechange=function(e){var t=e.currentTarget,r=t.readyState,i=this.stats,n=this.context,a=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(Pe.now(),i.trequest)),4===r){var o=t.status;if(o>=200&&o<300){i.tload=Math.max(i.tfirst,Pe.now());var s=void 0,u=void 0;u="arraybuffer"===n.responseType?(s=t.response).byteLength:(s=t.responseText).length,i.loaded=i.total=u;var d={url:t.responseURL,data:s};this.callbacks.onSuccess(d,i,n,t)}else i.retry>=a.maxRetry||o>=400&&o<499?(l.logger.error(o+" while loading "+n.url),this.callbacks.onError({code:o,text:t.statusText},n,t)):(l.logger.warn(o+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),a.timeout)},e.prototype.loadtimeout=function(){l.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},e.prototype.loadprogress=function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)},e}(),Me=function(){function e(e,t){for(var r=0;r=this.tracks.length)l.logger.warn("Invalid audio track id:",e.id);else{if(l.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}},t.prototype.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},t.prototype.onLevelLoaded=function(e){var t=this.hls.levels[e.level];if(t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}},t.prototype.onError=function(e){e.type===a.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(l.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},t.prototype._setAudioTrack=function(e){if(this._trackId===e&&this.tracks[this._trackId].details)l.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)l.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];l.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,i=t.type,n=t.id;this.hls.trigger(s.default.AUDIO_TRACK_SWITCHING,{id:n,type:i,url:r}),this._loadTrackDetailsIfNeeded(t)}},t.prototype.doTick=function(){this._updateTrack(this._trackId)},t.prototype._selectInitialAudioTrack=function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var n=t.filter(function(e){return e.default});n.length?t=n:l.logger.warn("No default audio tracks defined")}var o=!1,u=function(){t.forEach(function(t){o||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),o=!0)})};u(),o||(i=null,u()),o||(l.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},t.prototype._needsTrackLoading=function(e){var t=e.details;return!(!e.url||t&&!0!==t.live)},t.prototype._loadTrackDetailsIfNeeded=function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;l.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(s.default.AUDIO_TRACK_LOADING,{url:t,id:r})}},t.prototype._updateTrack=function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,l.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}},t.prototype._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,n=t.groupId;l.logger.warn("Loading failed on audio track id: "+e+", group-id: "+n+', name/language: "'+r+'" / "'+i+'"');for(var a=e,o=0;o0&&-1===e?(l.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=pe.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=pe.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=pe.STOPPED},t.prototype.doTick=function(){var e=void 0,t=void 0,r=void 0,i=this.hls,n=i.config;switch(this.state){case pe.ERROR:case pe.PAUSED:case pe.BUFFER_FLUSHING:break;case pe.STARTING:this.state=pe.WAITING_TRACK,this.loadedmetadata=!1;break;case pe.IDLE:var a=this.tracks;if(!a)break;if(!this.media&&(this.startFragRequested||!n.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var u=this.mediaBuffer?this.mediaBuffer:this.media,d=this.videoBuffer?this.videoBuffer:this.media,c=V.bufferInfo(u,e,n.maxBufferHole),f=V.bufferInfo(d,e,n.maxBufferHole),h=c.len,p=c.end,g=this.fragPrevious,v=Math.min(n.maxBufferLength,n.maxMaxBufferLength),y=Math.max(v,f.len),m=this.audioSwitch,T=this.trackId;if((hS||c.nextStart))return;l.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=S+.05}if(r.initSegment&&!r.initSegment.data)R=r.initSegment;else if(p<=S){if(R=b[0],null!==this.videoTrackCC&&R.cc!==this.videoTrackCC&&(R=function(e,t){return H.search(e,function(e){return e.cct?-1:0})}(b,this.videoTrackCC)),r.live&&R.loadIdx&&R.loadIdx===this.fragLoadIdx){var w=c.nextStart?c.nextStart:S;return l.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(w+.05)),void(this.media.currentTime=w+.05)}}else{var k=void 0,A=n.maxFragLookUpTolerance;p<_?(p>_-A&&(A=0),k=ue(g,b,p,A)):k=b[E-1],k&&(R=k,S=k.start,g&&R.level===g.level&&R.sn===g.sn&&(R.sn=D||O)&&(l.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=pe.IDLE);break;case pe.WAITING_INIT_PTS:var I=this.videoTrackCC;if(void 0===this.initPTS[I])break;var C=this.waitingFragment;if(C){var x=C.frag.cc;I!==x?(t=this.tracks[this.trackId]).details&&t.details.live&&(l.logger.warn("Waiting fragment CC ("+x+") does not match video track CC ("+I+")"),this.waitingFragment=null,this.state=pe.IDLE):(this.state=pe.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=pe.IDLE;break;case pe.STOPPED:case pe.FRAG_LOADING:case pe.PARSING:case pe.PARSED:case pe.ENDED:}},t.prototype.onMediaAttached=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)},t.prototype.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(l.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},t.prototype.onAudioTracksUpdated=function(e){l.logger.log("audio tracks updated"),this.tracks=e.audioTracks},t.prototype.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=pe.PAUSED,this.waitingFragment=null,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=pe.IDLE),this.tick()},t.prototype.onAudioTrackLoaded=function(e){var t=e.details,r=e.id,i=this.tracks[r],n=t.totalduration,a=0;if(l.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+n),t.live){var s=i.details;s&&t.fragments.length>0?(re(s,t),a=t.fragments[0].start,t.PTSKnown?l.logger.log("live audio playlist sliding:"+a.toFixed(3)):l.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,l.logger.log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(i.details=t,!this.startFragRequested){if(-1===this.startPosition){var u=t.startTimeOffset;Object(o.isFiniteNumber)(u)?(l.logger.log("start time offset found in playlist, adjust startPosition to "+u),this.startPosition=u):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===pe.WAITING_TRACK&&(this.state=pe.IDLE),this.tick()},t.prototype.onKeyLoaded=function(){this.state===pe.KEY_LOADING&&(this.state=pe.IDLE,this.tick())},t.prototype.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag;if(this.state===pe.FRAG_LOADING&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var i=this.tracks[this.trackId],n=i.details,a=n.totalduration,o=t.level,u=t.sn,d=t.cc,c=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",f=this.stats=e.stats;if("initSegment"===u)this.state=pe.IDLE,f.tparsed=f.tbuffered=je.now(),n.initSegment.data=e.payload,this.hls.trigger(s.default.FRAG_BUFFERED,{stats:f,frag:t,id:"audio"}),this.tick();else{this.state=pe.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new $(this.hls,"audio"));var h=this.initPTS[d],p=n.initSegment?n.initSegment.data:[];if(n.initSegment||void 0!==h){this.pendingBuffering=!0,l.logger.log("Demuxing "+u+" of ["+n.startSN+" ,"+n.endSN+"],track "+o);this.demuxer.push(e.payload,p,c,null,t,a,!1,h)}else l.logger.log("unknown video PTS for continuity counter "+d+", waiting for video PTS before demuxing audio frag "+u+" of ["+n.startSN+" ,"+n.endSN+"],track "+o),this.waitingFragment=e,this.state=pe.WAITING_INIT_PTS}}this.fragLoadError=0},t.prototype.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===pe.PARSING){var i=e.tracks,n=void 0;if(i.video&&delete i.video,n=i.audio){n.levelCodec=n.codec,n.id=e.id,this.hls.trigger(s.default.BUFFER_CODECS,i),l.logger.log("audio track:audio,container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var a=n.initSegment;if(a){var o={type:"audio",data:a,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,o))}this.tick()}}},t.prototype.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&i.sn===r.sn&&i.level===r.level&&this.state===pe.PARSING){var n=this.audioSwitch,u=this.hls,d=this.media,c=this.pendingData,f=this.trackId;r.addElementaryStream(v.ElementaryStreamTypes.AUDIO),Object(o.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),l.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),te(this.tracks[f].details,r,e.startPTS,e.endPTS);var h=!1;if(n){if(d&&d.readyState)d.currentTime>=e.startPTS&&(l.logger.log("switching audio track : flushing all audio"),this.state=pe.BUFFER_FLUSHING,u.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),h=!0);this.audioSwitch=!1,u.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:f})}if(!this.pendingData)return void u.trigger(s.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach(function(t){t&&t.length&&c.push({type:e.type,data:t,parent:"audio",content:"data"})}),!h&&c.length&&(c.forEach(function(e){t.state===pe.PARSING&&(t.pendingBuffering=!0,u.trigger(s.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}},t.prototype.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===pe.PARSING&&(this.stats.tparsed=je.now(),this.state=pe.PARSED,this._checkAppendedParsed())},t.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},t.prototype.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},t.prototype.onBufferAppended=function(e){if("audio"===e.parent){var t=this.state;t!==pe.PARSING&&t!==pe.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},t.prototype._checkAppendedParsed=function(){if(!(this.state!==pe.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=je.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;l.logger.log("audio buffered : "+ae.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=pe.IDLE}this.tick()}},t.prototype.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var n=this.config;if(i<=n.fragLoadingMaxRetry){this.fragLoadError=i;var o=Math.min(Math.pow(2,i-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);l.logger.warn("AudioStreamController: frag loading failed, retry in "+o+" ms"),this.retryDate=je.now()+o,this.state=pe.FRAG_LOADING_WAITING_RETRY}else l.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=pe.ERROR}break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==pe.ERROR&&(this.state=e.fatal?pe.ERROR:pe.IDLE,l.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===pe.PARSING||this.state===pe.PARSED)){var u=this.mediaBuffer,d=this.media.currentTime;if(u&&V.isBuffered(u,d)&&V.isBuffered(u,d+.5)){var c=this.config;c.maxMaxBufferLength>=c.maxBufferLength&&(c.maxMaxBufferLength/=2,l.logger.warn("AudioStreamController: reduce max buffer length to "+c.maxMaxBufferLength+"s")),this.state=pe.IDLE}else l.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=pe.BUFFER_FLUSHING,this.hls.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},t.prototype.onBufferFlushed=function(){var e=this,t=this.pendingData;t&&t.length?(l.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach(function(t){e.hls.trigger(s.default.BUFFER_APPENDING,t)}),this.appended=!0,this.pendingData=[],this.state=pe.PARSED):(this.state=pe.IDLE,this.fragPrevious=null,this.tick())},Be(t,[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,l.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}]),t}(ge),Ke=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e="auto",t={"":!0,lr:!0,rl:!0},r={start:!0,middle:!0,end:!0,left:!0,right:!0};function i(e){return"string"==typeof e&&(!!r[e.toLowerCase()]&&e.toLowerCase())}function n(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",n({},u,{get:function(){return E},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",n({},u,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",n({},u,{get:function(){return _},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),s.displayState=void 0,l)return s}return a.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},a}(),He=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function Ve(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new He,this.regionList=[]}function We(){this.values=Object.create(null)}function Ye(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var o=n[a].split(r);if(2===o.length)t(o[0],o[1])}}We.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 qe=new Ke(0,0,0),Xe="middle"===qe.align?"middle":"center";function ze(e,t,r){var i=e;function n(){var t=function(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}(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),a(),t.endTime=n(),a(),function(e,t){var i=new We;Ye(e,function(e,t){switch(e){case"region":for(var n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var a=t.split(","),o=a[0];i.integer(e,o),i.percent(e,o)&&i.set("snapToLines",!1),i.alt(e,o,["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",Xe,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",Xe,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Xe,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===qe.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Xe);var a=i.get("position","auto");"auto"===a&&50===qe.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function Je(e){return e.replace(//gi,"\n")}Ve.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=Je(e);r=16?o--:o++,navigator.userAgent.match(/Firefox\//)?n.line=u+1:n.line=u>7?u-2:u+1,Math.abs(32-(n.text.length+2*o))>2&&(n.align="left",n.position=Math.max(10,Math.min(90,10+2.5*o))),l.push(n)}return l}function Ze(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var et={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},tt=function(e){var t=e;return et.hasOwnProperty(e)&&(t=et[e]),String.fromCharCode(t)},rt=15,it=100,nt={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},at={17:2,18:4,21:6,22:8,23:10,19:13,20:15},ot={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},st={25:2,26:4,29:6,30:8,31:10,27:13,28:15},lt=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],ut={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){var r=this.verboseFilter[e];this.verboseLevel>=r&&console.log(this.time+" ["+e+"] "+t)}},dt=function(e){for(var t=[],r=0;rit&&(ut.log("DEBUG","Too large cursor position "+this.pos),this.pos=it)},e.prototype.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r=144&&this.backSpace();var t=tt(e);this.pos>=it?ut.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},e.prototype.clearFromPos=function(e){var t=void 0;for(t=e;t0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},e.prototype.getTextAndFormat=function(){return this.rows},e}(),gt=function(){function e(t,r){Ze(this,e),this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new pt,this.nonDisplayedMemory=new pt,this.lastOutputScreen=new pt,this.currRollUpRow=this.displayedMemory.rows[rt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return e.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[rt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.prototype.getHandler=function(){return this.outputFilter},e.prototype.setHandler=function(e){this.outputFilter=e},e.prototype.setPAC=function(e){this.writeScreen.setPAC(e)},e.prototype.setBkgData=function(e){this.writeScreen.setBkgData(e)},e.prototype.setMode=function(e){e!==this.mode&&(this.mode=e,ut.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},e.prototype.insertChars=function(e){for(var t=0;t=46,t.italics)t.foreground="white";else{t.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16]}ut.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},e.prototype.outputDataUpdate=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=ut.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),!0===e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},e.prototype.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}();function vt(e,t,r){r&&(r.a=e,r.b=t)}function yt(e,t,r){if(r)return r.a===e&&r.b===t}var mt=function(){function e(t,r,i,n){Ze(this,e),this.channels={1:new gt(1,t),2:new gt(2,r),3:new gt(3,i),4:new gt(4,n)},this.currChNr=-1,this.cmdHistory={1:{a:null,b:null},3:{a:null,b:null}}}return e.prototype.getHandler=function(e){return this.channels[e].getHandler()},e.prototype.setHandler=function(e,t){this.channels[e].setHandler(t)},e.prototype.addData=function(e,t,r){var i=void 0,n=void 0,a=void 0,o=!1;ut.setTime(e);for(var s=0;s ("+dt([n,a])+")"),(i=this.parseCmd(n,a,r))||(i=this.parseMidrow(n,a,r)),i||(i=this.parsePAC(n,a,r)),i||(i=this.parseBackgroundAttributes(n,a,r)),!i)if(o=this.parseChars(n,a))if(this.currChNr&&this.currChNr>=0)if(3===r&&this.currChNr>2||1===r&&this.currChNr<3)this.channels[this.currChNr].insertChars(o);else ut.log("WARNING","The last seen channel number does not fall within the current field. Deferring character insertion until the field and channel match.");else ut.log("WARNING","No channel found yet. TEXT-MODE?");i||o||ut.log("WARNING","Couldn't parse cleaned data "+dt([n,a])+" orig: "+dt([t[s],t[s+1]]))}},e.prototype.parseCmd=function(e,t,r){var i=this.cmdHistory,n=function(e){var t=void 0;20===e?t=1:28===e?t=2:21===e?t=3:29===e&&(t=4);return t}(e),a=function(e,t){var r=null;23===e?r=t:31===e&&(r=t+1);return r}(t,r);if(!(n&&t>=32&&t<=47)&&!(a&&t>=33&&t<=35))return!1;if(yt(e,t,i[r]))return vt(null,null,i[r]),ut.log("DEBUG","Repeated command ("+dt([e,t])+") is dropped"),!0;var o=void 0;return n?(o=this.channels[n],32===t?o.ccRCL():33===t?o.ccBS():34===t?o.ccAOF():35===t?o.ccAON():36===t?o.ccDER():37===t?o.ccRU(2):38===t?o.ccRU(3):39===t?o.ccRU(4):40===t?o.ccFON():41===t?o.ccRDC():42===t?o.ccTR():43===t?o.ccRTD():44===t?o.ccEDM():45===t?o.ccCR():46===t?o.ccENM():47===t&&o.ccEOC()):(o=this.channels[a]).ccTO(t-32),vt(e,t,i[r]),this.currChNr=n,!0},e.prototype.parseMidrow=function(e,t,r){var i=null;return(17===e||25===e)&&t>=32&&t<=47&&((i=17===e?r:r+1)!==this.currChNr?(ut.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[i].ccMIDROW(t),ut.log("DEBUG","MIDROW ("+dt([e,t])+")"),!0))},e.prototype.parsePAC=function(e,t,r){var i=this.cmdHistory,n=null,a=null;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;if(yt(e,t,i[r]))return vt(null,null,i[r]),!0;var o=void 0;return e<=23?(o=1,n=r):(o=2,n=r+1),a=t>=64&&t<=95?1===o?nt[e]:ot[e]:1===o?at[e]:st[e],this.channels[n].setPAC(this.interpretPAC(a,t)),vt(e,t,i[r]),this.currChNr=n,!0},e.prototype.interpretPAC=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},e.prototype.parseChars=function(e,t,r){var i=null,n=null,a=null;if(e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19){var o=t;o=17===a?t+80:18===a?t+112:t+144,ut.log("INFO","Special char '"+tt(o)+"' in channel "+i),n=[o]}else e>=32&&e<=127&&(n=0===t?[e]:[e,t]);if(n){var s=dt(n);ut.log("DEBUG","Char codes = "+s.join(",")),vt(e,t,this.cmdHistory[r])}return n},e.prototype.parseBackgroundAttributes=function(e,t,r){var i,n=void 0,a=void 0;return((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47)&&(n={},16===e||24===e?(a=Math.floor((t-32)/2),n.background=lt[a],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0)),i=e<24?r:r+1,this.channels[i].setBkgData(n),vt(e,t,this.cmdHistory[r]),!0)},e.prototype.reset=function(){for(var e=0;ee)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),bt=r("./src/demux/id3.js"),Et=function(e,t,r){return e.substr(r||0,t.length)===t},St=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},_t={parse:function(e,t,r,i,n,a){var s=Object(bt.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),l="00:00.000",u=0,d=0,c=0,f=[],h=void 0,p=!0,g=new Qe;g.oncue=function(e){var t=r[i],n=r.ccOffset;t&&t.new&&(void 0!==d?n=r.ccOffset=t.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;n&&n.new;)e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC];e.presentationOffset=r}(r,i,c)),c&&(n=c-r.presentationOffset),e.startTime+=n-d,e.endTime+=n-d,e.id=St(e.startTime.toString())+St(e.endTime.toString())+St(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&f.push(e)},g.onparsingerror=function(e){h=e},g.onflush=function(){h&&a?a(h):n(f)},s.forEach(function(e){if(p){if(Et(e,"X-TIMESTAMP-MAP=")){p=!1,e.substr(16).split(",").forEach(function(e){Et(e,"LOCAL:")?l=e.substr(6):Et(e,"MPEGTS:")&&(u=parseInt(e.substr(7)))});try{t+(9e4*r[i].start||0)<0&&(t+=8589934592),u-=t,n=l,a=parseInt(n.substr(-3)),s=parseInt(n.substr(-6,2)),f=parseInt(n.substr(-9,2)),v=n.length>9?parseInt(n.substr(0,n.indexOf(":"))):0,d=(Object(o.isFiniteNumber)(a)&&Object(o.isFiniteNumber)(s)&&Object(o.isFiniteNumber)(f)&&Object(o.isFiniteNumber)(v)?(a+=1e3*s,a+=6e4*f,a+=36e5*v):-1)/1e3,c=u/9e4,-1===d&&(h=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(t){h=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(p=!1)}var n,a,s,f,v;g.parse(e+"\n")}),g.flush()}};function Rt(e){if(e)for("disabled"===e.mode&&(e.mode="hidden");e.cues&&e.cues.length>0;)e.removeCue(e.cues[0])}var wt=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this,r,s.default.MEDIA_ATTACHING,s.default.MEDIA_DETACHING,s.default.FRAG_PARSING_USERDATA,s.default.FRAG_DECRYPTED,s.default.MANIFEST_LOADING,s.default.MANIFEST_LOADED,s.default.FRAG_LOADED,s.default.LEVEL_SWITCHING,s.default.INIT_PTS_FOUND,s.default.FRAG_PARSING_INIT_SEGMENT,s.default.SUBTITLE_TRACKS_CLEARED));if(i.hls=r,i.config=r.config,i.enabled=!0,i.Cues=r.config.cueHandler,i.textTracks=[],i.tracks=[],i.unparsedVttFrags=[],i.initPTS=[],i.cueRanges={},i.captionsTracks={},i.captionsProperties={textTrack1:{label:i.config.captionsTextTrack1Label,languageCode:i.config.captionsTextTrack1LanguageCode},textTrack2:{label:i.config.captionsTextTrack2Label,languageCode:i.config.captionsTextTrack2LanguageCode},textTrack3:{label:i.config.captionsTextTrack1Label,languageCode:i.config.captionsTextTrack1LanguageCode},textTrack4:{label:i.config.captionsTextTrack2Label,languageCode:i.config.captionsTextTrack2LanguageCode}},i.config.enableCEA708Captions){var n=new Tt(i,"textTrack1"),a=new Tt(i,"textTrack2"),o=new Tt(i,"textTrack3"),l=new Tt(i,"textTrack4");i.cea608Parser=new mt(n,a,o,l)}return i}return function(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)}(t,e),t.prototype.addCues=function(e,t,r,i){var n=this,a=this.cueRanges[e];a||(a=this.cueRanges[e]=[]);for(var o,l,u,d,c=!1,f=a.length;f--;){var h=a[f],p=(o=h[0],l=h[1],u=t,d=r,Math.min(l,d)-Math.max(o,u));if(p>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),c=!0,p/(r-t)>.5))return}c||a.push([t,r]);var g=this.Cues.createCues(t,r,i);this.config.renderNatively?g.forEach(function(t){n.captionsTracks[e].addCue(t)}):this.hls.trigger(s.default.CUES_PARSED,{type:"captions",cues:g,track:e})},t.prototype.onInitPtsFound=function(e){var t=this;if("main"===e.id&&(this.initPTS[e.frag.cc]=e.initPTS),this.unparsedVttFrags.length){var r=this.unparsedVttFrags;this.unparsedVttFrags=[],r.forEach(function(e){t.onFragLoaded(e)})}},t.prototype.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r=a.length||r!==n||!o||this.stopped)this._clearReloadTimer();else if(l.logger.log("subtitle track "+r+" loaded"),i.live){var s=ne(o.details,i,e.stats.trequest);l.logger.log("Reloading live subtitle playlist in "+s+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},s)}else this._clearReloadTimer()},t.prototype.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},t.prototype.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},t.prototype._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},t.prototype._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(l.logger.log("Loading subtitle track "+e),r.trigger(s.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},t.prototype._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;if(t){var n=At(t.textTracks);if(-1===e)[].slice.call(n).forEach(function(e){e.mode="disabled"});else{var a=n[i];a&&(a.mode="disabled")}var o=n[e];o&&(o.mode=r?"showing":"hidden")}},t.prototype._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(o.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,l.logger.log("Switching to subtitle track "+e),t.trigger(s.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},t.prototype._onTextTracksChanged=function(){if(this.media&&this.hls.config.renderNatively){for(var e=-1,t=At(this.media.textTracks),r=0;r=i[o].start&&a<=i[o].end){n=i[o];break}var s=t.start+t.duration;n?n.end=s:(n={start:a,end:s},i.push(n))}}},t.prototype.onMediaAttached=function(e){this.media=e.media,this.state=pe.IDLE},t.prototype.onMediaDetaching=function(){this.media=null,this.state=pe.STOPPED},t.prototype.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=pe.IDLE)},t.prototype.onSubtitleTracksUpdated=function(e){var t=this;l.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})},t.prototype.onSubtitleTrackSwitch=function(e){if(this.currentTrackId=e.id,this.tracks&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()},t.prototype.onSubtitleTrackLoaded=function(e){var t=e.id,r=e.details,i=this.currentTrackId,n=this.tracks,a=n[i];t>=n.length||t!==i||!a||(r.live&&function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=-1;ie(e,t,function(e,t,r){t.start=e.start,i=r});var n=t.fragments;if(i<0)n.forEach(function(e){e.start+=r});else for(var a=i+1;a0&&r&&r.key&&"AES-128"===r.method){var a=Ot.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,function(e){var t=Ot.now();n.trigger(s.default.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:a,tdecrypt:t}})})}},t.prototype.onLevelUpdated=function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0},t.prototype.doTick=function(){if(this.media)switch(this.state){case pe.IDLE:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,n=this.tracks;if(!n||!n[t]||!n[t].details)break;var a=e.maxBufferHole,o=e.maxFragLookUpTolerance,u=Math.min(e.maxBufferLength,e.maxMaxBufferLength),d=V.bufferedInfo(this._getBuffered(),i.currentTime,a),c=d.end,f=d.len,h=n[t].details,p=h.fragments,g=p.length,v=p[g-1].start+p[g-1].duration;if(f>u)return;var y=void 0,m=this.fragPrevious;c0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(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}(this,e.call(this)),n=t.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var a in n)a in r||(r[a]=n[a]);if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(r.liveMaxLatencyDuration<=r.liveSyncDuration||void 0===r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(l.enableLogs)(r.debug),i.config=r,i._autoLevelCapping=-1;var o=i.abrController=new r.abrController(i),s=new r.bufferController(i),u=new r.capLevelController(i),d=new r.fpsController(i),c=new F(i),f=new N(i),h=new M(i),p=i.levelController=new Ee(i),g=new K(i),v=[p,i.streamController=new ye(i,g)],y=r.audioStreamController;y&&v.push(new y(i,g)),i.networkControllers=v;var m=[c,f,h,o,s,u,d,g];if(y=r.audioTrackController){var T=new y(i);i.audioTrackController=T,m.push(T)}if(y=r.subtitleTrackController){var b=new y(i);i.subtitleTrackController=b,v.push(b)}if(y=r.emeController){var E=new y(i);i.emeController=E,m.push(E)}return(y=r.subtitleStreamController)&&v.push(new y(i,g)),(y=r.timelineController)&&m.push(new y(i)),i.coreComponents=m,i}return function(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)}(t,e),t.isSupported=function(){return e=q(),t=window.SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove,!!r&&!!i;var e,t,r,i},Ut(t,null,[{key:"version",get:function(){return"0.11.0"}},{key:"Events",get:function(){return s.default}},{key:"ErrorTypes",get:function(){return a.ErrorTypes}},{key:"ErrorDetails",get:function(){return a.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:Mt},set:function(e){t.defaultConfig=e}}]),t.prototype.destroy=function(){l.logger.log("destroy"),this.trigger(s.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},t.prototype.attachMedia=function(e){l.logger.log("attachMedia"),this.media=e,this.trigger(s.default.MEDIA_ATTACHING,{media:e})},t.prototype.detachMedia=function(){l.logger.log("detachMedia"),this.trigger(s.default.MEDIA_DETACHING),this.media=null},t.prototype.loadSource=function(e){e=n.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),l.logger.log("loadSource:"+e),this.url=e,this.trigger(s.default.MANIFEST_LOADING,{url:e})},t.prototype.startLoad=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;l.logger.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},t.prototype.stopLoad=function(){l.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},t.prototype.swapAudioCodec=function(){l.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.prototype.recoverMediaError=function(){l.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),this.attachMedia(e)},t.prototype.removeLevel=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.levelController.removeLevel(e,t)},Ut(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){l.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){l.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){l.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 Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){l.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"bandwidthEstimate",get:function(){var e=this.abrController._bwEstimator;return e?e.getEstimate():NaN}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){l.logger.log("set startLevel:"+e);-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){l.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,r=e?e.length:0,i=0;it)return i}return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),t}(z);t.default=Bt},"./src/polyfills/number-isFinite.js": /*!******************************************!*\ !*** ./src/polyfills/number-isFinite.js ***! \******************************************/ /*! exports provided: isFiniteNumber */function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",function(){return i});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)}},"./src/utils/get-self-scope.js": /*!*************************************!*\ !*** ./src/utils/get-self-scope.js ***! \*************************************/ /*! exports provided: getSelfScope */function(e,t,r){"use strict";function i(){return"undefined"==typeof window?self:window}r.r(t),r.d(t,"getSelfScope",function(){return i})},"./src/utils/logger.js": /*!*****************************!*\ !*** ./src/utils/logger.js ***! \*****************************/ /*! exports provided: enableLogs, logger */function(e,t,r){"use strict";r.r(t),r.d(t,"enableLogs",function(){return d}),r.d(t,"logger",function(){return c});var i=r(/*! ./get-self-scope */"./src/utils/get-self-scope.js"),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};function a(){}var o={trace:a,debug:a,log:a,warn:a,info:a,error:a},s=o;var l=Object(i.getSelfScope)();function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i "+t}(e,i[0])),t.apply(l.console,i)}:a}(t)})}var d=function(e){if(!0===e||"object"===(void 0===e?"undefined":n(e))){u(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=o}}else s=o},c=s}}).default},"object"==typeof t&&"object"==typeof e?e.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof t?t.Hls=i():r.Hls=i()},148:function(e,t,r){"use strict";r.r(t),r.d(t,"default",function(){return f});var i=r(133),n=r(141),a=r.n(n);function o(e){return(o="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})(e)}function s(e,t){for(var r=0;r0&&(n=0),r.length>n+1&&r[n+1]){var a=r[n],o=a.indexOf(" --\x3e ");o>0&&(t.begin=Object(i.g)(a.substr(0,o)),t.end=Object(i.g)(a.substr(o+5)),t.text=r.slice(n+1).join("\r\n"))}return t}},71:function(e,t,r){"use strict";var i=window.VTTCue;function n(e){if("string"!=typeof e)return!1;return!!{start:!0,middle:!0,end:!0,left:!0,right:!0}[e.toLowerCase()]&&e.toLowerCase()}if(!i){(i=function(e,t,r){var i=this;i.hasBeenReset=!1;var a="",o=!1,s=e,l=t,u=r,d=null,c="",f=!0,h="auto",p="start",g="auto",v=100,y="middle";Object.defineProperty(i,"id",{enumerable:!0,get:function(){return a},set:function(e){a=""+e}}),Object.defineProperty(i,"pauseOnExit",{enumerable:!0,get:function(){return o},set:function(e){o=!!e}}),Object.defineProperty(i,"startTime",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");s=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"endTime",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");l=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"text",{enumerable:!0,get:function(){return u},set:function(e){u=""+e,this.hasBeenReset=!0}}),Object.defineProperty(i,"region",{enumerable:!0,get:function(){return d},set:function(e){d=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"vertical",{enumerable:!0,get:function(){return c},set:function(e){var t=function(e){return"string"==typeof e&&!!{"":!0,lr:!0,rl:!0}[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");c=t,this.hasBeenReset=!0}}),Object.defineProperty(i,"snapToLines",{enumerable:!0,get:function(){return f},set:function(e){f=!!e,this.hasBeenReset=!0}}),Object.defineProperty(i,"line",{enumerable:!0,get:function(){return h},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");h=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"lineAlign",{enumerable:!0,get:function(){return p},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");p=t,this.hasBeenReset=!0}}),Object.defineProperty(i,"position",{enumerable:!0,get:function(){return g},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");g=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"size",{enumerable:!0,get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");v=e,this.hasBeenReset=!0}}),Object.defineProperty(i,"align",{enumerable:!0,get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}}),i.displayState=void 0}).prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)}}t.a=i},72:function(e,t,r){"use strict";function i(e,t){var r=e.kind||"cc";return e.default||e.defaulttrack?"default":e._id||e.file||r+t}function n(e,t){var r=e.label||e.name||e.language;return r||(r="Unknown CC",(t+=1)>1&&(r+=" ["+t+"]")),{label:r,unknownCount:t}}r.d(t,"a",function(){return i}),r.d(t,"b",function(){return n})},73:function(e,t,r){"use strict";var i=r(71),n=r(10),a=r(28),o=r(4),s=r(68),l=r(2),u=r(1);function d(e){throw new u.s(null,e)}function c(e,t,i){e.xhr=Object(a.a)(e.file,function(a){!function(e,t,i,a){var c,f,p=e.responseXML?e.responseXML.firstChild:null;if(p)for("xml"===Object(o.b)(p)&&(p=p.nextSibling);p.nodeType===p.COMMENT_NODE;)p=p.nextSibling;try{if(p&&"tt"===Object(o.b)(p))c=function(e){e||d(306007);var t=[],r=e.getElementsByTagName("p"),i=30,n=e.getElementsByTagName("tt");if(n&&n[0]){var a=parseFloat(n[0].getAttribute("ttp:frameRate"));isNaN(a)||(i=a)}r||d(306005),r.length||(r=e.getElementsByTagName("tt:p")).length||(r=e.getElementsByTagName("tts:p"));for(var o=0;o\s+<").replace(/(<\/?)tts?:/g,"$1").replace(//g,"\r\n");if(p){var g=s.getAttribute("begin"),v=s.getAttribute("dur"),y=s.getAttribute("end"),m={begin:Object(l.g)(g,i),text:p};y?m.end=Object(l.g)(y,i):v&&(m.end=m.begin+Object(l.g)(v,i)),t.push(m)}}return t.length||d(306005),t}(e.responseXML),f=h(c),delete t.xhr,i(f);else{var g=e.responseText;g.indexOf("WEBVTT")>=0?r.e(18).then(function(e){return r(134).default}.bind(null,r)).catch(Object(n.c)(301131)).then(function(e){var r=new e(window);f=[],r.oncue=function(e){f.push(e)},r.onflush=function(){delete t.xhr,i(f)},r.parse(g)}).catch(function(e){delete t.xhr,a(Object(u.A)(null,u.b,e))}):(c=Object(s.a)(g),f=h(c),delete t.xhr,i(f))}}catch(e){delete t.xhr,a(Object(u.A)(null,u.b,e))}}(a,e,t,i)},function(e,t,r,n){i(Object(u.z)(n,u.b))})}function f(e){e&&e.forEach(function(e){var t=e.xhr;t&&(t.onload=null,t.onreadystatechange=null,t.onerror=null,"abort"in t&&t.abort()),delete e.xhr})}function h(e){return e.map(function(e){return new i.a(e.begin,e.end,e.text)})}r.d(t,"c",function(){return c}),r.d(t,"a",function(){return f}),r.d(t,"b",function(){return h})},74:function(e,t,r){"use strict";function i(e,t){return e!==1/0&&Math.abs(e)>=Math.max(a(t),0)}function n(e,t){var r="VOD";return e===1/0?r="LIVE":e<0&&(r=i(e,a(t))?"DVR":"LIVE"),r}function a(e){return void 0===e?120:Math.max(e,0)}r.d(t,"a",function(){return i}),r.d(t,"b",function(){return n})},75:function(e,t,r){"use strict";function i(e){return new Promise(function(t,r){if(e.paused)return r(n("NotAllowedError",0,"play() failed."));var i=function(){e.removeEventListener("play",a),e.removeEventListener("playing",o),e.removeEventListener("pause",o),e.removeEventListener("abort",o),e.removeEventListener("error",o)},a=function(){e.addEventListener("playing",o),e.addEventListener("abort",o),e.addEventListener("error",o),e.addEventListener("pause",o)},o=function(e){if(i(),"playing"===e.type)t();else{var a='The play() request was interrupted by a "'.concat(e.type,'" event.');"error"===e.type?r(n("NotSupportedError",9,a)):r(n("AbortError",20,a))}};e.addEventListener("play",a)})}function n(e,t,r){var i=new Error(r);return i.name=e,i.code=t,i}r.d(t,"a",function(){return i})},76:function(e,t,r){"use strict";r.d(t,"c",function(){return n}),r.d(t,"b",function(){return a}),r.d(t,"a",function(){return o});var i={TIT2:"title",TT2:"title",WXXX:"url",TPE1:"artist",TP1:"artist",TALB:"album",TAL:"album"};function n(e,t){for(var r,i,n,a=e.length,o="",s=t||0;s>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:i=e[s++],o+=String.fromCharCode((31&r)<<6|63&i);break;case 14:i=e[s++],n=e[s++],o+=String.fromCharCode((15&r)<<12|(63&i)<<6|(63&n)<<0)}return o}function a(e){var t=function(e){for(var t="0x",r=0;r>1|(8323072&t)>>2|(2130706432&t)>>3}function o(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce(function(e,t){if(!("value"in t)&&"data"in t&&t.data instanceof ArrayBuffer){var r=new Uint8Array(t.data),o=r.length;t={value:{key:"",data:""}};for(var s=10;s<14&&s0){var f=n(r.subarray(l,l+=d),0);if("PRIV"===t.value.key){if("com.apple.streaming.transportStreamTimestamp"===f){var h=1&a(r.subarray(l,l+=4)),p=a(r.subarray(l,l+=4))+(h?4294967296:0);t.value.data=p}else t.value.data=n(r,l+1);t.value.info=f}else t.value.info=f,t.value.data=n(r,l+1)}else{var g=r[l];t.value.data=1===g||2===g?function(e,t){for(var r=e.length-1,i="",n=t||0;nthis._textTracks.length)return!0;for(var t=0;t=0&&n[a].startTime>t.startTime;a--)r.unshift(n[a]),e.removeCue(n[a]);e.addCue(t),r.forEach(function(t){return e.addCue(t)}),e.mode=i}(t,i)}else t.addCue(r)}function h(e,t){t&&t.length&&Object(l.j)(t,function(t){if(!(o.Browser.ie&&e&&/^(native|subtitle|cc)/.test(t._id))){o.Browser.ie&&"disabled"===t.mode||(t.mode="disabled",t.mode="hidden");for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);t.embedded||(t.mode="disabled"),t.inuse=!1}})}function p(e){return"subtitles"===e||"captions"===e}function g(e){var t,r=Object(n.b)(e,this._unknownCount),i=r.label;if(this._unknownCount=r.unknownCount,this.renderNatively||"metadata"===e.kind){var a=this.video.textTracks;(t=Object(l.n)(a,{label:i}))||(t=this.video.addTextTrack(e.kind,i,e.language||"")),t.default=e.default,t.mode="disabled",t.inuse=!0}else(t=e).data=t.data||[];return t._id||(t._id=Object(n.a)(e,this._textTracks.length)),t}function v(e){this._textTracks.push(e),this._tracksById[e._id]=e}function y(e){this.triggerActiveCues(e.currentTarget.activeCues)}t.a=u},80:function(e,t,r){"use strict";function i(e){return e&&e.length?e.end(e.length-1):0}r.d(t,"a",function(){return i})},82:function(e,t,r){"use strict";function i(e){return{bitrate:e.bitrate,label:e.label,width:e.width,height:e.height}}r.d(t,"a",function(){return i})}}]);