diff --git a/vendor/playback/playback.js b/vendor/playback/playback.js index fecdfeb..e1cb8dc 100644 --- a/vendor/playback/playback.js +++ b/vendor/playback/playback.js @@ -1,15 +1,15 @@ -module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports={SCAudio:r(1),SCAudioPublicApiStreamURLRetriever:r(6),MaestroCore:r(2),MaestroLoaders:r(5),MaestroHTML5Player:r(4),MaestroHLSMSEPlayer:r(3)}},function(e,t,r){!function(t,n){e.exports=n(r(2),function(){try{return r(!function(){var e=new Error('Cannot find module "@sc/maestro-chromecast-player"');throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}(),function(){try{return r(!function(){var e=new Error('Cannot find module "@sc/maestro-flipper-player"');throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}(),function(){try{return r(3)}catch(e){}}(),function(){try{return r(4)}catch(e){}}(),r(5))}(this,function(e,t,r,n,o,i){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=36)}([function(t,r){t.exports=e},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t,r){void 0===r&&(r="API error.");var n=e.call(this,r)||this;return n.statusCode=t,n}return n(t,e),t.prototype.getCode=function(){return"SCAUDIO.API_ERROR."+(this.statusCode||"TIMEOUT")},t.prototype.getStatusCode=function(){return this.statusCode},t}(o.errors.PlayerFatalError);t.ApiError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){return e.call(this,t||"There was no format available that a player was able to play.")||this}return n(t,e),t.prototype.getCode=function(){return"SCAUDIO.NOT_SUPPORTED_ERROR"},t}(o.errors.PlayerFatalError);t.NotSupportedError=i},function(e,t,r){"use strict";function n(e){return new i({startPos:0,endPos:e,startLevel:0,endLevel:1,fromEnd:!1})}function o(e){return new i({startPos:e,endPos:0,startLevel:1,endLevel:0,fromEnd:!0})}Object.defineProperty(t,"__esModule",{value:!0}),t.buildFadeIn=n,t.buildFadeOut=o;var i=function(){function e(e){var t=e.startPos,r=e.endPos,n=e.startLevel,o=e.endLevel,i=e.fromEnd,a=void 0!==i&&i;if(t<0)throw new Error("startPos invalid.");if(r<0||!a&&r1)throw new Error("startLevel invalid.");if(o<0||o>1)throw new Error("endLevel invalid.");this._startPos=t,this._endPos=r,this._startLevel=n,this._endLevel=o,this._fromEnd=a}return e.prototype.calculate=function(e,t){var r=this._fromEnd?t-500-this._startPos:this._startPos,n=this._fromEnd?t-500-this._endPos:this._endPos;if(e=0&&(this._volumeAutomators.splice(t,1),this._updateVolume())},t.prototype._triggerError=function(t){e.prototype._triggerError.call(this,t)},t.prototype.providePlayer=function(t,r,n){void 0===n&&(n=!0),this._volumeAutomationSupported=n,e.prototype.providePlayer.call(this,t,r)},t.prototype._setVolume=function(e){this._userVolume=e,this._calculateAndSetVolume()},t.prototype._kill=function(){this._timer&&window.clearTimeout(this._timer),null!==this._connectionLossTimer&&window.clearTimeout(this._connectionLossTimer),this._abortPauseFade(),e.prototype._kill.call(this)},t.prototype._calculateIfConnectionRequired=function(){var e=this,t=this.isLoading()&&"navigator"in window&&!window.navigator.onLine;t?null===this._connectionLossTimer&&(this._connectionLossTimer=window.setTimeout(function(){e._connectionLossTimer=null,e._connectionRequired=!0,e._onConnectionRequired.dispatch(void 0)},p)):this._connectionRequired?(this._connectionRequired=!1,this._onConnectionRecovered.dispatch(void 0)):null!==this._connectionLossTimer&&(window.clearTimeout(this._connectionLossTimer),this._connectionLossTimer=null)},t.prototype._completePauseFade=function(){if(this._pauseFadeDeferred){this._pauseFadeTimer&&window.clearTimeout(this._pauseFadeTimer);var e=this._pauseFadeDeferred;this._pauseFadeDeferred=null,e.resolve(this.pause())}},t.prototype._abortPauseFade=function(){this._pauseFadeTimer&&(window.clearTimeout(this._pauseFadeTimer),this._pauseFadeTimer=null),this._pauseFadeDeferred&&(this._pauseFadeDeferred.reject(new Error("Player was killed.")),this._pauseFadeDeferred=null)},t.prototype._updateVolume=function(){var e=this;if(this._volumeAutomationSupported){this._ensureNotDead(),this._timer&&(window.clearTimeout(this._timer),this._timer=null);var t=this.getDuration();if(null!==t){var r=this._volumeAutomators,o=this.getPosition(),i=1/0,a=1;r.forEach(function(e){var r=e.calculate(o,t),s=r.nextCalculatePosition,u=r.level;a*=n(0,1,u),s1)throw new Error("Invalid volume level.");se=e,ae.forEach(function(t){return t.setVolume(e)})}function _(){return se}function g(e){if("boolean"!=typeof e)throw new Error("muteEnabled must be a boolean.");ue=e,ae.forEach(function(t){return t.setMuted(e)})}function y(){return ue}function v(){n()}function m(e){function t(){return Te&&Me?p(Te,Me):null}function r(){if(ke&&window.clearTimeout(ke),Se.debug("Performing retrieve."),De)throw new Error("Player job already running. Only one instance of the job is allowed at once.");if(Re.isDead())throw new Error("Proxy is dead.");var e=new q(function(){function e(){function t(e){if(e!==E.helpers.abortableJob.abortedError)if(e instanceof T.RequestError){var t=e.getStatusCode();switch(t){case 401:Re._triggerError(new M.GeoBlockedError(t,"Geoblocked (logged out)."));break;case 403:Re._triggerError(new M.GeoBlockedError(t,"Geoblocked (logged in)."));break;case 404:Re._triggerError(new x.UnavailableError(t,"Track unavailable."));break;case null:throw new Error("Status code should not be null.");default:Re._triggerError(new D.ApiError(t))}}else e===E.helpers.retry.noMoreAttemptsError?Re._triggerError(new O.TimedOutError):(Se.error("Unexpected error.",e),Re._triggerError(new E.errors.PlayerFatalError("An unexpected error occurred.",e)))}s=o(),s.onCompletion(function(r){if(r)try{Me=r;var o=r.url,i=r.rendition,s=new E.Descriptor(o,i.maestroProtocol,i.maestroFormat),u=a(Ae,s,r);u?n(u):(Se.debug("Excluding rendition.",r.rendition),d.excludeRendition(r.rendition),Ae=[],e())}catch(e){t(e)}else Me?(Se.error("There were no stream formats that were supported."),Re._triggerError(new k.NotSupportedError)):(Se.error("There were no streams available."),Re._triggerError(new K.NoStreamsError))}),s.onError(t)}function n(e){function n(e){if(!o&&!i&&(o=!0,Se.debug("Player releasing control.",e),t.abort(e),!Re.isDead()))if(e&&e.retryPlayer){var n=Oe.getDelay();n>0?(Se.debug("Waiting "+n+" ms."),ke=window.setTimeout(function(){return r()},n)):r()}else r()}var o=!1;Te=e(n),Te.isDead()?(Se.debug("Player died during construction."),n()):(le.addPlayer(Te),Te.onChange.subscribe(function(e){var t=e.dead;t&&(Se.debug("Player died."),n())}))}var i=!1,s=null;return e(),{result:E.helpers.deferred.buildDeferred().promise,abort:function(e){i=!0,Se.info("Player job aborted.",e),De=null,s&&s.abort(),Te&&(e&&e.retryPlayer?Se.debug("Player might be used again for current rendition."):(Se.debug("Player will not be used again for current rendition."),Ae.push(Te.constructor)),Re.getPlayer()&&Re.removePlayer(),Te.kill(),Te=null,Me=null)}}}),t=e.run();return De=t}function o(){return z(function(){return new q(function(){var e=d.getUrl();Se.debug("Retrieving a URL...");var t=e.whenComplete().then(function(e){return Se.debug("Retrieved URL.",e),e&&te.indexOf(e.rendition)<0?(Se.warn("Unknown rendition. Skipping...",e.rendition),{success:!1}):{result:e,success:!0}}).catch(function(e){if(e instanceof T.RequestError){var t=e.getStatusCode();if(null===t||0===t)return null===t?Se.warn("Timed out when retrieving URL. Will retry."):Se.warn("Network error when retrieving URL. Will retry."),{success:!1}}throw e!==E.helpers.abortableJob.abortedError&&Se.error("Error retrieving URL.",e),e});return{result:t,abort:function(){return e.abort()}}})},ge)}function a(e,t,r){var n=r.timeRetrieved;if($&&l.indexOf($)>=0&&e.indexOf($)<0){if(Se.debug("ChromecastPlayer found.",Y.version),me)return function(){var e=new $(t,{name:Ee,castContext:me,logger:re});return Re.providePlayer(e,{syncPosition:!1,syncVolume:!1},!1),e};Se.warn("Could not construct chromecast player because context not provided.")}return Z&&l.indexOf(Z)>=0&&e.indexOf(Z)<0?(Se.debug("FlipperPlayer found.",Q.version),function(){var e=new Z(t,{name:Ee,logger:re});return L.takeControlFlipperPlayer(Re,e,Se,xe||void 0),e}):X&&l.indexOf(X)>=0&&e.indexOf(X)<0?(Se.debug("HLSMSEPlayer found.",J.version),function(e){var n=new X(t,{name:Ee,playlistLoader:b.stringLoader,segmentLoader:b.arrayBufferLoader,keyLoader:b.arrayBufferLoader,expectedSegmentFormat:{mimeType:"audio/mpeg"},logger:re});return u(n,function(){return e()}),I.takeControlHLSMSEPlayer(J,Re,n,ve,e,r.rendition,d,r.url,Se),n}):W&&l.indexOf(W)>=0&&(!ve||"hls"!==t.getProtocol().name)&&(!ve||void 0!==n)&&e.indexOf(W)<0?(Se.debug("HTML5Player found.",V.version),function(e){var r=new W(t,{name:Ee,logger:re});u(r,function(){return e()});var o;if(ve){if(void 0===n)throw new Error("Expecting timeUrlRetrieved to be set.");o={urlExpires:!0,timeUrlRetrieved:n}}else o={urlExpires:!1};return C.takeControlHTML5Player(V,Re,r,o,e,Se),r}):null}function s(){De?(Se.debug("Reloading stream URLs..."),Se.debug("Aborting player job that is in progress."),De.abort(),Ae=[],r()):Se.debug("Reload requested, but not reloading as there is nothing to reload.")}function u(e,t){function r(){var t=e.getMediaElement();t&&t!==n()&&(Se.debug("Revoking audio element that was created internally because player is ready now."),e.revokeMediaElement())}function o(){var r=e.getMediaElement();if(r&&r!==n()&&(Se.debug("Revoking audio element that was created internally, even though player is not ready."),e.revokeMediaElement()),!e.getMediaElement()){ne&&!ne.isDead()&&(Se.info("Revoking audio element from a player."),ne.isPlaying()&&Se.warn("The audio element is being revoked from a player which is playing. Only one player should be playing at once."),ne.revokeMediaElement()),ne=e,Se.info("Providing audio element to a different player.");var o=oe={};e.provideMediaElement(n()).catch(function(r){e.isDead()||oe!==o||(Se.error("An unexpected error occurred when trying to provide the audio element to a player.",r),t())})}}e.isReady()?r():e.onReady.subscribe(r),Re.onPlayIntent.subscribe(function(){e.isDead()||o()}),Re.isPlaying()&&(e.isDead()||o()),ne||o()}var l=e.playerClasses,d=e.streamUrlRetriever,c=e.duration,f=void 0===c?null:c,_=e.preloadingEnabled,g=void 0!==_&&_,y=e.pausedMaxBufferLength,v=void 0===y?2e3:y,m=e.playingMaxBufferLength,N=void 0===m?9e4:m,B=e.fadeOutDuration,H=void 0===B?0:B,ee=e.logger,re=void 0===ee?E.logger.noOpLogger:ee,de=e.audioPerformanceReporter,ce=e.audioReporter,pe=e.audioCheckpointInterval,he=void 0===pe?3e4:pe,fe=e.errorReporter,_e=e.urlProviderRetryDelayCalculator,ge=void 0===_e?G():_e,ye=e.streamUrlsExpire,ve=void 0===ye||ye,me=e.chromecastContext;if(!(d instanceof P.BaseStreamUrlRetriever))throw new Error("StreamUrlRetriever invalid.");if(null!==f&&("number"!=typeof f||f<0))throw new Error("duration invalid.");if("boolean"!=typeof g)throw new Error("preloadingEnabled invalid.");if(null!==v&&("number"!=typeof v||v<0))throw new Error("pausedMaxBufferLength invalid.");if(null!==N&&("number"!=typeof N||N<0))throw new Error("playingMaxBufferLength invalid.");if(null!==H&&("number"!=typeof H||H<0))throw new Error("fadeOutDuration invalid.");if(null!==re&&"function"!=typeof re&&"object"!=typeof re)throw new Error("logger invalid.");if(void 0!==ce&&"function"!=typeof ce)throw new Error("audioReporter invalid.");if(null!==he&&("number"!=typeof he||he<0))throw new Error("audioCheckpointInterval invalid.");if(void 0!==de&&"function"!=typeof de)throw new Error("audioPerformanceReporter invalid.");if(void 0!==fe&&"function"!=typeof fe)throw new Error("errorReporter invalid.");if(void 0!==ge&&"function"!=typeof ge)throw new Error("retryDelayCalculator invalid.");var Ee="SCAudio-"+ ++ie,be=d.getTrackId();null!==be&&(Ee+="-"+be);var Pe=new U.LogCollector;re=E.logger.cloneLogger(Pe,re);var Se=E.logger.prefixLogger(re,Ee),we=h();Se.info("Building player...",{ua:navigator.userAgent,logId:we});var Re=new A.Player({name:Ee+"-Proxy",logger:re,mediaSessionEnabled:!0,pausedMaxBufferLength:v,playingMaxBufferLength:N,preloadingEnabled:g},s);ae.push(Re),Re.setVolume(se),Re.setMuted(ue),H>0&&Re.addVolumeAutomator(S.buildFadeOut(H));var Ae=[],Te=null,Me=null,De=null,xe=null,ke=null,Oe=new F.DecayingExponentialDelayCalculator;if(de&&(xe=new w.AudioPerformanceEventGenerator(Re,de,Se,t,X)),ce&&new j.AudioEventGenerator(Re,ce,he,Se),fe&&R.generateErrorEvents(Re,Pe,we,be,fe,Se,t,J||null,ve),Re.onChange.subscribe(function(e){var t=e.dead,r=e.playing;if(t)Se.info("Player killed."),ae.splice(ae.indexOf(Re),1),De&&De.abort(),ke&&window.clearTimeout(ke);else if(r===!0){var o=l.some(function(e){return i(e)});o&&n()}}),null!==f&&(Se.debug("Setting initial duration.",f),Re.setInitialDuration(f)),g)Se.debug("Preloading is enabled, so performing retrieve immediately."),r();else{Se.debug("Preloading is disabled, so deferring retrieve until either a play intent or preloading is enabled.");var Ce=function(){Ie.remove(),Le.remove(),Se.debug("Preloading now enabled or received a play request. Peforming retrieve."),r()},Ie=Re.onPreloadingEnabled.subscribe(Ce),Le=Re.onPlayIntent.subscribe(Ce)}return Re}Object.defineProperty(t,"__esModule",{value:!0});var E=r(0),b=r(35),P=r(4),S=r(3),w=r(17),R=r(22),A=r(5),T=r(7),M=r(9),D=r(1),x=r(12),k=r(2),O=r(11),C=r(20),I=r(8),L=r(19),N=r(6),F=r(21),U=r(23),j=r(16),B=r(18),q=E.helpers.abortableJob.AbortableJob,H=E.helpers.retry,z=H.retry,G=H.buildExponentialDelayCalculator,K=r(10),V=void 0;try{V=r(34)}catch(e){}var J=void 0;try{J=r(33)}catch(e){}var Q=void 0;try{Q=r(32)}catch(e){}var Y=void 0;try{Y=r(31)}catch(e){}var W=V?V.HTML5Player:null,X=J?J.HLSMSEPlayer:null,Z=Q?Q.FlipperPlayer:null,$=Y?Y.ChromecastPlayer:null,ee=/^[^?#]*/,te=Object.keys(N.renditions).map(function(e){return N.renditions[e]}),re=null,ne=null,oe={},ie=-1,ae=[],se=1,ue=!1,le=new B.CacheManager(5e8,E.logger.noOpLogger);t.setGlobalVolume=f,t.getGlobalVolume=_,t.setGlobalMuted=g,t.getGlobalMuted=y,t.activateAudioElement=v,t.buildPlayer=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(3);!function(e){e.Fade=o.Fade,e.buildFadeIn=o.buildFadeIn,e.buildFadeOut=o.buildFadeOut}(n=t.volumeAutomation||(t.volumeAutomation={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=1e3,i=function(){function e(e,t,r,i){this._checkpointTimer=null,this._logger=n.logger.prefixLogger(i,"AudioEventGenerator"),this._player=e,this._eventReporter=t,this._checkpointInterval=null!==r?Math.max(o,r):null,this._startReporting()}return e.prototype._startReporting=function(){var e=this,t=this._player;t.onChange.subscribe(function(r){var n=r.actuallyPlaying,o=r.ended;n===!0&&!t.isEnded()||o===!1&&t.isActuallyPlaying()?(null===e._checkpointInterval||e._checkpointTimer||(e._checkpointTimer=window.setInterval(function(){e._reportEvent("checkpoint")},e._checkpointInterval)),e._reportEvent("play")):(n===!1&&!t.isEnded()||o===!0&&t.isActuallyPlaying())&&(e._checkpointTimer&&(window.clearInterval(e._checkpointTimer),e._checkpointTimer=null),e._reportEvent("pause"))})},e.prototype._reportEvent=function(e){var t=this._player.getDuration();if(null===t)throw new Error("Duration should exist now.");var r={type:e,position:this._player.getPosition(),duration:t};this._logger.debug("Generated audio event.",r),this._eventReporter(r)},e}();t.AudioEventGenerator=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(30),i=function(){function e(e,t,r,o,i){this._logger=n.logger.prefixLogger(r,"AudioPerformanceEventGenerator"),this._player=e,this._eventReporter=t,this._getPlayerDetails=o,this._HLSMSEPlayer=i,this._measureGeneralEvents()}return e.prototype.reportManualEvent=function(e){this._logger.debug("Reporting manual audio performance event.",e),this._eventReporter(e)},e.prototype._measureGeneralEvents=function(){var e=this,t=this._player,r=new o.Timer,n=null,i=null;t.onChange.subscribe(function(a){var s=a.dead,u=a.playing,l=a.actuallyPlaying,d=a.seeking,c=a.loading;s||(u===!0&&(r.isComplete()||r.start()),l===!0&&(r.isComplete()||(r.stop(),e._reportEvent("play",r.getTime()))),d===!0&&t.isReady()&&(n=new o.Timer,n.start()),d===!1&&n&&(n.stop(),e._reportEvent("seek",n.getTime())),c===!0&&r.isComplete()&&(i=new o.Timer,i.start()),c===!1&&i&&(i.stop(),e._reportEvent("buffer",i.getTime())))})},e.prototype._reportEvent=function(e,t,r){var n=r||this._getPlayerDetails();if(!n)return void this._logger.warn("Cannot report event because there is no player.",e,t);var o={type:e,latency:t,protocol:n.protocol,playerType:n.name,host:n.host,bitrate:n.bitrate,format:n.format||void 0};this._logger.debug("Generated audio performance event.",o),this._eventReporter(o)},e}();t.AudioPerformanceEventGenerator=i},function(e,t,r){"use strict";function n(e,t){var r=e.getMemoryCacheController();r&&r.setMaxCacheSize(t)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=2e4,a=function(){function e(e,t){this._maxCacheSize=e,this._players=[],this._updateTimer=null,this._logger=o.logger.prefixLogger(t,"CacheManager"),this._logger.debug("Initialized with cache size "+e+" bytes.")}return e.prototype.addPlayer=function(e){var t=this;if(this._logger.debug("Adding player to cache manager."),e.isDead())return void this._logger.debug("Player was dead.");var r=this._players;e.onChange.subscribe(function(n){var o=n.playing,i=n.dead;i===!0?(t._logger.debug("Removing player that became dead."),r.splice(r.indexOf(e),1),t._update()):o===!0?(t._logger.debug("Updating because player started playing."),r.splice(r.indexOf(e),1),r.unshift(e),t._update()):o===!1&&(t._logger.debug("Updating because player became paused."),t._update())}),e.isPlaying()?r.unshift(e):r.push(e),this._update()},e.prototype._update=function(){var e=this;if(this._updateTimer&&(window.clearTimeout(this._updateTimer),this._updateTimer=null),0===this._players.length)return void this._logger.debug("There are no longer any players to manage.");var t=this._players.reduce(function(e,t){return t.isPlaying()?e.playingPlayers.push(t):e.pausedPlayers.push(t),e},{playingPlayers:[],pausedPlayers:[]}),r=t.playingPlayers,o=t.pausedPlayers,a=r.reduce(function(e,t){return e+(t.getMemoryCacheUsage()||0)},0),s=o.reduce(function(e,t){return e+(t.getMemoryCacheUsage()||0)},0);if(a>this._maxCacheSize){this._logger.debug("All playing players are using more than the max cache size. Cleaning...",a,this._maxCacheSize);var u=this._maxCacheSize/r.length;r.forEach(function(e){return n(e,u)}),o.forEach(function(e){return n(e,0)})}else this._logger.debug("Recalculating cache sizes...",a+s,this._maxCacheSize),r.concat(o).reduce(function(t,r){return n(r,Math.max(0,e._maxCacheSize-t)),t+(r.getMemoryCacheUsage()||0)},0);this._updateTimer=window.setTimeout(function(){return e._update()},i)},e}();t.CacheManager=a},function(e,t,r){"use strict";function n(e,t,r,n){r=o.logger.prefixLogger(r,"FlipperPlayer Controller"),n&&t.onAudioPerformanceEvent.subscribe(function(e){var t=e.protocol,o=e.type,i=e.latency,a=e.player_type,s=e.host,u=e.bitrate,l=e.format,d="Flipper";if(a!==d)return void r.warn("Ignoring audio performance event from flipper because the player_type was incorrect.",a);var c={protocol:t,type:o,latency:i,playerType:d,host:s,bitrate:u,format:l};n.reportManualEvent(c)}),e.providePlayer(t)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0);t.takeControlFlipperPlayer=n},function(e,t,r){"use strict";function n(e,t,r,n,a,s){function u(){var e=r.getDuration(),t=l();if(null!==e&&null!==t){var n=e-r.getPosition();i()+n>t&&(s.info("Releasing control because stream URL would expire before reaching end."),a({retryPlayer:!0}))}}function l(){if(!n.urlExpires)return null;var e=r.getDuration();return null===e?null:n.timeUrlRetrieved+e+105e3}function d(){var e=l();return null!==e&&e<=i()}s=o.logger.prefixLogger(s,"HTML5Player Controller"),r.onError.subscribe(function(t){t instanceof o.errors.NotSupportedError||(t instanceof e.errors.NetworkError&&d()?(s.info("Releasing control as a network error occurred, and the URL has expired."),a({retryPlayer:!0})):(s.error("Unexpected player error.",t),a({retryPlayer:!1})))}),n.urlExpires&&(r.onPlayIntent.subscribe(function(){return u()}),r.onSeekIntent.subscribe(function(){return u()})),t.providePlayer(r)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=o.helpers.time.now;t.takeControlHTML5Player=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{ -value:!0});var n=function(){function e(){this._delayFactor=0,this._lastRequestTime=0}return e.prototype.getDelay=function(){var e=Date.now()-this._lastRequestTime;return this._lastRequestTime=Date.now(),this._delayFactor=Math.max(0,this._delayFactor-e/15e3),this._delayFactor+=1,Math.pow(2,this._delayFactor)},e}();t.DecayingExponentialDelayCalculator=n},function(e,t,r){"use strict";function n(e,t,r,n,a,s,u,l,d){function c(e){var o=u()||void 0,i={errorCode:e,log:t.getLog(),logId:r,trackId:n,protocol:o&&o.protocol,playerType:o?o.name:"MaestroUnknown",host:o&&o.host,bitrate:o&&o.bitrate,format:o&&(o.format||void 0),url:o&&o.url};s.debug("Generated audio error event.",i),a(i)}s=o.logger.prefixLogger(s,"ErrorGenerator"),e.onError.subscribe(function(e){if(!(d&&l&&i.isErrorWhichShouldTriggerURLRefresh(l,e))){var t,r;r=e instanceof o.errors.ProxyProvidedPlayerFatalError?e.getProvidedPlayerFatalError():e,t=r.getCode(),r instanceof o.errors.NotSupportedError||c(t)}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=r(8);t.generateErrorEvents=n},function(e,t,r){"use strict";function n(e){return e.map(function(e){try{return JSON.stringify(e)}catch(e){return""}})}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){void 0===e&&(e=200),this._bufferSize=e,this._log=[]}return e.prototype.getLog=function(){return this._log},e.prototype.debug=function(e){for(var t=[],r=1;rthis._bufferSize&&this._log.shift()},e}();t.LogCollector=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.apiMobile={scProtocol:"sc.api-mobile",maestroProtocol:{name:"sc.api-mobile"},maestroFormat:{}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encryptedHlsMp3={scProtocol:"encrypted-hls",scFormat:"mp3",maestroProtocol:{name:"hls"},maestroFormat:{mimeType:"application/x-mpegURL"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hlsMp3={scProtocol:"hls",scFormat:"mp3",maestroProtocol:{name:"hls"},maestroFormat:{mimeType:"application/x-mpegURL"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpMp3={scProtocol:"http",scFormat:"mp3",maestroProtocol:{name:"http"},maestroFormat:{mimeType:"audio/mpeg"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maestroChromecast={scProtocol:"maestro.chromecast",maestroProtocol:{name:"maestro.chromecast"},maestroFormat:{}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(27),o=r(26),i=r(25),a=r(24),s=r(28);t.renditions={httpMp3:n.httpMp3,hlsMp3:o.hlsMp3,encryptedHlsMp3:i.encryptedHlsMp3,apiMobile:a.apiMobile,maestroChromecast:s.maestroChromecast}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=n.helpers.time.now,i=function(){function e(){this._start=null,this._end=null}return e.prototype.start=function(){if(this.isComplete())throw new Error("Timer completed.");this._start=o()},e.prototype.isComplete=function(){return null!==this._end},e.prototype.stop=function(){if(null===this._start)throw new Error("Not started.");this._end=o()},e.prototype.getTime=function(){if(null===this._end)throw new Error("Not completed.");return this._end-this._start},e}();t.Timer=i},function(e,r){if("undefined"==typeof t){var n=new Error('Cannot find module "@sc/maestro-chromecast-player"');throw n.code="MODULE_NOT_FOUND",n}e.exports=t},function(e,t){if("undefined"==typeof r){var n=new Error('Cannot find module "@sc/maestro-flipper-player"');throw n.code="MODULE_NOT_FOUND",n}e.exports=r},function(e,t){if("undefined"==typeof n){var r=new Error('Cannot find module "@sc/maestro-hls-mse-player"');throw r.code="MODULE_NOT_FOUND",r}e.exports=n},function(e,t){if("undefined"==typeof o){var r=new Error('Cannot find module "@sc/maestro-html5-player"');throw r.code="MODULE_NOT_FOUND",r}e.exports=o},function(e,t){e.exports=i},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),t.version="11.0.4",t.buildNumber=275;var o=r(15);t.volumeAutomation=o.volumeAutomation;var i=r(4);t.BaseStreamUrlRetriever=i.BaseStreamUrlRetriever;var a=r(7);t.RequestError=a.RequestError;var s=r(5);t.Player=s.Player;var u=r(6);t.renditions=u.renditions,n(r(13)),n(r(14))}])})},function(e,t,r){!function(t,r){e.exports=r()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=35)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"PLAYER_FATAL_ERROR"},t}(o.PlayerError);t.PlayerFatalError=i},function(e,t,r){"use strict";function n(){var e,t,r=!1,n=new o.Promise(function(r,n){e=r,t=n});return{promise:n,resolve:function(t){r||(r=!0,e(t))},reject:function(e){r||(r=!0,t(e))},isSettled:function(){return r}}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(10);t.buildDeferred=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=function(){function e(){this._listeners=[],this.dispatch=this.dispatch.bind(this)}return e.prototype.subscribe=function(e){var t=this,r={fn:e,payloads:[]};return this._listeners.push(r),{remove:function(){var e=t._listeners.indexOf(r);return e>=0&&(t._listeners.splice(e,1),!0)},retrieve:function(){return t._dispatchListenerPayloads(r)}}},e.prototype.dispatch=function(e,t){var r=this,o="number"==typeof t?{time:t}:t||{},i=void 0!==o.time?o.time:n.now(),a=this._listeners;a.forEach(function(t){return t.payloads.push({time:i,payload:e})});var s=!1;do s=!a.some(function(e){var t=e.fn,n=e.payloads,o=n.shift();return!!o&&(r._callHandler(t,o),!0)});while(!s)},e.prototype.getHandle=function(){return{subscribe:this.subscribe.bind(this)}},e.prototype._dispatchListenerPayloads=function(e){for(var t=e.fn,r=e.payloads;;){var n=r.shift();if(!n)break;this._callHandler(t,n)}},e.prototype._callHandler=function(e,t){try{e(t.payload,t.time)}catch(e){window.setTimeout(function(){throw e},0)}},e}();t.EventDispatcher=o},function(e,t,r){"use strict";function n(e,t){return{debug:function(r){for(var n=[],o=1;o1)throw new Error("Volume must be >= 0 and <= 1.");this._setVolume(e)},e.prototype.getCurrentBufferedTimeRange=function(){var e=this.getBufferedTimeRanges(),t=this.getPosition();return l.find(e,function(e){return e.containsTime(t)})||null},e.prototype.play=function(){var e=this;this._ensureNotDead(),this._logger.debug("play() called.");try{return this._stateManager.update(function(t){return t.playing?e._logger.debug("Intent is already to be playing."):(e._logger.debug("Requesting play."),t.playing=!0,e._lastPlayError=null),t.playDeferred||(t.playDeferred=u.buildDeferred()),t.playDeferred.promise})}catch(e){return this._triggerError(new i.PlayerFatalError("Unexpected error when attempting to play.",e)),o.Promise.reject(e)}},e.prototype.pause=function(){var e=this;this._ensureNotDead(),this._logger.debug("pause() called.");try{return this._stateManager.update(function(t){return t.playing?(e._logger.debug("Requesting pause."),t.playing=!1,e._lastPauseError=null):e._logger.debug("Intent is already to be paused."),t.pauseDeferred||(t.pauseDeferred=u.buildDeferred()),t.pauseDeferred.promise})}catch(e){return this._triggerError(new i.PlayerFatalError("Unexpected error when attempting to pause.",e)),o.Promise.reject(e)}},e.prototype.seek=function(e){var t=this;return this._ensureNotDead(),this._logger.debug("seek() called.",e),this._stateManager.update(function(r){if(e<0)return t._logger.warn("Rejecting seek immediately as the position was negative."),o.Promise.reject(new Error("You were attempting to seek to a negative time."));if(null!==r.duration&&e>r.duration)return t._logger.warn("Rejecting seek immediately as the duration is now known, and the requested positon was past it."),o.Promise.reject(new Error("You were attempting to seek past the end of the media."));try{var n=u.buildDeferred();return r.seek&&"IN_PROGRESS"===r.seek.state&&r.seek.position===e?t._logger.debug("Seek already requested to the same position.",e):(t._logger.debug("Requesting seek.",e),r.seeking=!0,r.seek={state:"IN_PROGRESS",position:e},r.positionJumped=Object.create(null),t._updateEnded(e)),t._queuedSeekDeferreds.push({position:e,deferred:n}),n.promise}catch(e){return t._triggerError(new i.PlayerFatalError("Unexpected error when attempting to seek.",e)),o.Promise.reject(e)}})},e.prototype.getSeekState=function(){return this._stateManager.getState().seek},e.prototype.kill=function(){var e=this;this._stateManager.update(function(t){t.dead||(e._logger.debug("kill() called."),t.dead=!0,e._positionWhenKilled=e._getPositionOrPositionSeekingTo(),e._updateEnded(e._positionWhenKilled))})},e.prototype._atomic=function(e){return this._stateManager.update(function(){return e()})},e.prototype._ensureNotDead=function(){if(this._stateManager.getState().dead)throw new Error("Player is dead.")},e.prototype._notifyStalled=function(e){this._stalled!==e&&(this._logger.debug("notifyStalled() called.",e),this._stalled=e,this._pendingPositionWhenStoppedPlaying=this.getPosition(),this._stateManager.update(function(){}))},e.prototype._getQueuedSeekPosition=function(){var e=this.getSeekState();return e&&"IN_PROGRESS"===e.state?e.position:null},e.prototype._provideDuration=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),r.duration!==e){var n=t._getPositionOrPositionSeekingTo();if(e<0||r.ready&&n>e)throw t._triggerError(new i.PlayerFatalError("Attempt to update duration to an invalid value.")),new Error("Duration cannot be less than the current position.");t._logger.debug("provideDuration() called.",e),r.ready?(r.duration=e,t._updateEnded(n)):t._queuedDuration=e}})},e.prototype._notifyPlaying=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to register playback as started before ready.")),new Error("Player must be ready first.");e!==r.actuallyPlaying&&(t._logger.debug("notifyPlaying() called.",e),e||(t._pendingPositionWhenStoppedPlaying=t.getPosition()),r.actuallyPlaying=r.playing=e,e?t._lastPlayError=null:t._lastPauseError=null)})},e.prototype._notifyPlayRejection=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to reject a play request before player ready.")),new Error("Player must be ready first.");if(r.actuallyPlaying||!r.playing)throw t._triggerError(new i.PlayerFatalError("Attempt to reject a play request when not valid.")),new Error("Playing state is incorrect.");t._logger.debug("notifyPlayRejection() called.",e),r.playing=!1,t._lastPlayError=e})},e.prototype._notifyPauseRejection=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){if(!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to reject pause request before player ready.")),new Error("Player must be ready first.");if(!r.actuallyPlaying||r.playing)throw t._triggerError(new i.PlayerFatalError("Attempt to reject pause request when not valid.")),new Error("Playing state is incorrect.");t._logger.debug("notifyPauseRejection() called.",e),r.playing=!0,t._lastPauseError=e})},e.prototype._notifySeekRejection=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){if(!r.ready)throw new Error("Player must be ready first.");if(!r.seek||"IN_PROGRESS"!==r.seek.state)throw new Error("A seek hasn't been requested.");t._logger.debug("notifySeekRejection() called.",e),r.seeking=!1,r.seek={state:"ERROR",error:e},r.positionJumped=Object.create(null),t._updateEnded(t._getPositionOrPositionSeekingTo())})},e.prototype._signalReady=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ready twice.")),new Error("Ready already signalled.");if(null===e._queuedDuration)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ready when duration unknown.")),new Error("Duration is still unknown.");e._logger.debug("signalReady() called."),t.ready=!0,t.duration=e._queuedDuration,t.seek&&"IN_PROGRESS"===t.seek.state&&t.seek.position>t.duration&&(t.seeking=!1,t.seek={state:"ERROR",error:new Error("You were attempting to seek past the end of the media.")}),e._updateEnded(e._getPositionOrPositionSeekingTo())})},e.prototype._signalSeekComplete=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw new Error("Player must be ready first.");if(!t.seek||"IN_PROGRESS"!==t.seek.state)throw new Error("There shouldn't be a seek in progress.");var r=t.duration;if(t.seek&&"IN_PROGRESS"===t.seek.state&&t.seek.position>r)throw new Error("Seek cannot have completed given it was to a time greater than the duration.");e._logger.debug("signalSeekComplete() called."),t.seek={state:"COMPLETED",position:t.seek.position},t.seeking=!1,e._updateEnded(e._getPositionOrPositionSeekingTo())})},e.prototype._signalPositionJump=function(){return this._stateManager.update(function(e){e.seek&&"IN_PROGRESS"===e.seek.state||(e.positionJumped=Object.create(null))})},e.prototype._signalEnded=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ended before player was ready.")),new Error("Player must be ready first.");if(!t.ended){if(t.seek&&"IN_PROGRESS"===t.seek.state)return void e._logger.debug("Ignoring signalEnded() call because a seek is in progress.");e._logger.debug("signalEnded() called."),t.ended=!0}})},e.prototype._signalNotEnded=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal not ended before player was ready.")),new Error("Player must be ready first.");if(t.ended){if(null!==t.seek&&"IN_PROGRESS"===t.seek.state)return void e._logger.debug("Ignoring signalNotEnded() call because a seek is in progress.");e._logger.debug("signalNotEnded() called."),t.ended=!1}})},e.prototype._triggerError=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){var n=!1;if(r.ready&&e instanceof a.NotSupportedError&&(e=new i.PlayerFatalError("Invalid NotSupportedError."),n=!0),e instanceof i.PlayerFatalError){e instanceof a.NotSupportedError?t._logger.info("NotSupportedError occurred.",e):t._logger.error("Fatal error occurred.",e),r.fatalError?t._logger.warn("A fatal error already occurred."):r.fatalError=e,t._errors.push(e),r.errorOccurred=Object.create(null);try{t._positionWhenKilled=t.getPosition()}catch(e){t._logger.error("Tried to get position before player was killed but got exception.",e)}r.dead=!0}else t._logger.warn("Non-fatal error occurred.",e),t._errors.push(e),r.errorOccurred=Object.create(null);if(n)throw new Error("Not supported errors are only valid before the player is ready.")})},e.prototype._buildEventHandle=function(e){var t=this;return{subscribe:function(r){var n=function(e){return r(e,d.now())};return t._stateManager.subscribe(function(t){e(n,t)})}}},e.prototype._finalizeState=function(e){e.dead?(this._lastPlayError=new Error("Player was killed."),e.loading=!1,e.stalled=!0,e.actuallyPlaying=!1,e.playing=!1,e.state=c.State.DEAD):(e.stalled=!e.ended&&(!e.ready||this._stalled||!(!e.seek||"IN_PROGRESS"!==e.seek.state)),e.loading=!e.ended&&(e.playing||e.actuallyPlaying)&&(e.stalled||e.playing!==e.actuallyPlaying),e.state=this._calculateState(e))},e.prototype._getPositionOrPositionSeekingTo=function(){var e=this;return this._stateManager.update(function(t){if(t.seek&&"IN_PROGRESS"===t.seek.state)return t.seek.position;if(!t.ready||null===t.duration)return 0;var r=e._getPosition();if(t.seek&&"IN_PROGRESS"===t.seek.state)return t.seek.position;var n=t.duration;if(r<0)throw e._logger.error("Player provided invalid position.",r,n),e._triggerError(new i.PlayerFatalError("Player provided a position that was invalid.")),new Error("Player provided invalid position.");if(null!==n&&r>n)throw e._logger.error("Player provided invalid position.",r,n),e._triggerError(new i.PlayerFatalError("Player provided a position that was invalid.")),new Error("Player provided invalid position.");return r})},e.prototype._updateEnded=function(e){return this._stateManager.update(function(t){var r=t.duration,n=e===r&&t.ready;t.ended=n})},e.prototype._calculateState=function(e){var t=e.dead,r=e.loading,n=e.playing,o=e.ended;return t?c.State.DEAD:r?c.State.LOADING:n&&!o?c.State.PLAYING:c.State.PAUSED},e.prototype._registerMediaSessionActionHandlers=function(){var e=this;this._mediaSessionEnabled&&g&&(g.setActionHandler("play",function(){e.isDead()||e.play()}),g.setActionHandler("pause",function(){e.isDead()||e.pause()}),g.setActionHandler("seekbackward",function(){e.isDead()||e.seek(Math.max(0,e.getPosition()-_))}),g.setActionHandler("seekforward",function(){e.isDead()||e.seek(Math.min(e.getDuration()||0,e.getPosition()+_))}))},e.prototype._notifyMediaSessionPlaying=function(){this._mediaSessionEnabled&&g&&(g.playbackState="playing")},e.prototype._notifyMediaSessionPaused=function(){this._mediaSessionEnabled&&g&&(g.playbackState="paused")},e.prototype._afterUpdate=function(e){this._finalizeState(e)},e.prototype._afterDispatches=function(){var e=this,t=this._errors;this._errors=[],t.forEach(function(t){return e._onError.dispatch(t)})},e.prototype._onChange=function(e,t){var r=this,n=e.ready,o=e.dead,i=e.fatalError,a=e.playing,s=e.actuallyPlaying,u=e.ended;if(s===!1&&(this._positionWhenStoppedPlaying=this._pendingPositionWhenStoppedPlaying),n===!0&&(this._logger.debug("Resolving ready deferred."),this._readyDeferred.resolve(void 0)),s===!0&&this._registerMediaSessionActionHandlers(),a===!0?this._notifyMediaSessionPlaying():a===!1&&this._notifyMediaSessionPaused(),t.pauseDeferred&&!t.pauseDeferred.isSettled()&&t.playing){var l=this._lastPauseError||new Error("Pause request aborted.");this._logger.debug("Rejecting pause deferred.",l),t.pauseDeferred.reject(l)}if(t.playDeferred&&!t.playDeferred.isSettled()&&!t.playing){var l=this._lastPlayError||new Error("Play request aborted.");this._logger.debug("Rejecting play deferred.",l),t.playDeferred.reject(l)}if(t.playDeferred&&!t.playDeferred.isSettled()&&t.actuallyPlaying&&(this._logger.debug("Resolving play deferred."),t.playDeferred.resolve(void 0)),!t.pauseDeferred||t.pauseDeferred.isSettled()||t.actuallyPlaying||(this._logger.debug("Resolving pause deferred."),t.pauseDeferred.resolve(void 0)),s===!0&&!t.ended||u===!1&&t.actuallyPlaying?this._timePlaybackStarted=d.now():(s===!1&&!t.ended||u===!0&&t.actuallyPlaying)&&(this._listenTimeBase+=d.now()-this._timePlaybackStarted,this._timePlaybackStarted=null),this._queuedSeekDeferreds=this._queuedSeekDeferreds.filter(function(e){var n=e.position,o=e.deferred;if(t.seek)if("IN_PROGRESS"!==t.seek.state){if(!t.stalled||"ERROR"===t.seek.state)return"ERROR"!==t.seek.state?(r._logger.debug("Resolving seek()."),o.resolve(void 0)):(r._logger.debug("Rejecting seek().",t.seek.error),o.reject(t.seek.error)),!1}else if("IN_PROGRESS"!==t.seek.state||t.seek.position!==n)return r._logger.debug("Rejecting seek() because another seek was requested.",n),o.reject(new Error("Seek request aborted because another seek was requested to a different position.")),!1;return!0}),o===!0){if(this._logger.debug("Calling _kill() on player."),this._kill(),this._logger.info("Player killed."),!t.ready){var l=i||new Error("Player was killed.");this._logger.debug("Rejecting whenReady."),this._readyDeferred.reject(l)}this._queuedSeekDeferreds.forEach(function(e){var t=e.position,n=e.deferred,o=i||new Error("Seek aborted as player killed.");r._logger.debug("Rejecting seek().",t),n.reject(o)}),this._logger.debug("Player dead.")}},e}();t.BasePlayer=y},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(7),i=r(4),a=r(0),s=r(3),u=function(e){function t(t){var r=e.call(this,t)||this;return r._errorHandler=null,r._changeHandler=null,r._player=null,r._instanceLock=null,r._position=0,r._volume=1,r._muted=!1,r._unsynced=!1,r._logger=s.prefixLogger(r._logger,"ProxyPlayerBase"),r}return n(t,e),t.prototype.getVolume=function(){return this._player&&!this._unsynced?this._player.getVolume():this._volume},t.prototype.getMuted=function(){return this._player&&!this._unsynced?this._player.getMuted():this._muted},t.prototype.setMuted=function(e){return this._player&&!this._unsynced?this._player.setMuted(e):void(this._muted=e)},t.prototype.getBufferedTimeRanges=function(){return this._player&&!this._unsynced?this._player.getBufferedTimeRanges():[]},t.prototype.getCurrentBufferedTimeRange=function(){return this._player&&!this._unsynced?this._player.getCurrentBufferedTimeRange():null},t.prototype.getMaxBufferLength=function(){return this._player&&!this._unsynced?this._player.getMaxBufferLength():null},t.prototype._providePlayer=function(e,t){if(void 0===t&&(t={syncPosition:!0,syncVolume:!0}),this._ensureNotDead(),this._player)throw new Error("A player has already been provided."); -this._logger.debug("providePlayer() called."),this._instanceLock=Object.create(null),this._player=e,this._sync(t)},t.prototype._removePlayer=function(){if(this._ensureNotDead(),!this._player)throw new Error("There is no player to remove.");this._logger.debug("removePlayer() called."),this._unsync(),this._instanceLock=null,this._player=null},t.prototype._setInitialDuration=function(e){var t=this;if(this._ensureNotDead(),e<0)throw new Error("Cannot set duration to a value < 0.");null===this.getDuration()&&this._atomic(function(){t._fixPosition(e),t._provideDuration(e),t.isReady()||(t._signalReady(),t._player&&t._completeLocalSeekIfPlayerNotSeeking(t._player))})},t.prototype._triggerError=function(t){e.prototype._triggerError.call(this,t)},t.prototype._getPlayer=function(){return this.isDead()?null:this._player},t.prototype._setVolume=function(e){return this._player&&!this._unsynced?this._player.setVolume(e):void(this._volume=e)},t.prototype._handlePlayPauseChange=function(e){var t=this._player;t&&(e?this._playAndHandleAbort(t):this._pauseAndHandleAbort(t))},t.prototype._handleSeekChange=function(e){var t=this._player;t?t.seek(e):this._position=e},t.prototype._getPosition=function(){if(this._player&&!this._unsynced){if(!this._changeHandler)throw new Error("Handler should exist.");if(this._changeHandler.retrieve(),this._player)return this._player.getPosition()}return this._position},t.prototype._kill=function(){if(this._player&&!this._player.isDead()){if(!this._changeHandler)throw new Error("Handler should exist.");if(this._changeHandler.retrieve(),this._player){if(this._player.kill(),!this._unsynced)throw new Error("Unsync should have happened.");this._player=null}}},t.prototype._fixPosition=function(e){this._position>e&&(this._logger.debug("A duration was provided that was less than the current position. Changing position to the duration.",e),this._position=e,this._signalPositionJump())},t.prototype._sync=function(e){var t=this,r=this._player;if(!r)throw new Error("Player should have become available by now.");return this._unsynced=!1,this._logger.debug("Syncing..."),r.isDead()?void this._logger.debug("Provided player is dead."):(this._errorHandler=r.onError.subscribe(function(e){e instanceof a.PlayerFatalError||t._triggerError(e)}),this._changeHandler=r.onChange.subscribe(function(e){t._atomic(function(){if(e.dead)return t._logger.debug("Player has gone to DEAD state."),t._unsync(),void(t.isDead()||e.fatalError&&t._handleFatalError(e.fatalError));if(void 0!==e.duration&&(t._fixPosition(e.duration),t._provideDuration(e.duration),t.isReady()?t._notifyStalled(!1):(t._signalReady(),t._completeLocalSeekIfPlayerNotSeeking(r),t.isPlaying()&&!t.isActuallyPlaying()&&r.isActuallyPlaying()?(t._logger.debug("Provided player already playing."),t._notifyPlaying(!0)):t.isPlaying()||!t.isActuallyPlaying()||r.isActuallyPlaying()||(t._logger.debug("Provided player already paused."),t._notifyPlaying(!1)))),e.seek){var n=t.getSeekState();n&&"IN_PROGRESS"===n.state?"COMPLETED"===e.seek.state&&n.position===e.seek.position?t._signalSeekComplete():"COMPLETED"===e.seek.state&&n.position!==e.seek.position?t._notifySeekRejection(new Error("Another seek occurred to a different position.")):"IN_PROGRESS"===e.seek.state&&n.position!==e.seek.position?(t._notifySeekRejection(new Error("Another seek occurred to a different position.")),t.seek(e.seek.position)):"ERROR"===e.seek.state&&t._notifySeekRejection(e.seek.error):"COMPLETED"===e.seek.state&&t._signalPositionJump()}e.ended===!0&&t._signalEnded(),e.ended===!1&&t._signalNotEnded(),void 0!==e.stalled&&t._notifyStalled(e.stalled),e.playing===!1&&e.playRejection&&(t.isActuallyPlaying()?(t._triggerError(new i.PlayerError("Paused because a player was provided that refused to play.")),t._notifyStalled(!1),t._notifyPlaying(!1)):t._notifyPlayRejection(e.playRejection)),e.playing===!0&&e.pauseRejection&&(t.isActuallyPlaying()?t._notifyPauseRejection(e.pauseRejection):(t._triggerError(new i.PlayerError("Playing because a player was provided that refused to pause.")),t._notifyPlaying(!0))),e.playing===!0&&t.play(),e.playing===!1&&t.pause(),void 0!==e.actuallyPlaying&&(e.actuallyPlaying&&t._notifyStalled(!1),t._notifyPlaying(e.actuallyPlaying))})}),void this._atomic(function(){try{if(!t.isReady()&&r.isReady()){t._logger.debug("Provided player is already ready. Making proxy player ready.");var n=r.getDuration();t._fixPosition(n),t._provideDuration(n),t._signalReady()}if(e.syncVolume&&(r.setVolume(t._volume),r.setMuted(t._muted)),e.syncPosition)r.getPosition()!==t._position&&(t._logger.debug("Seeking to match position."),r.seek(t._position));else{var o=t.getSeekState();if(r.getPosition()!==t._position&&o&&"IN_PROGRESS"===o.state)t._logger.debug("Seeking to match position because a seek has been queued."),r.seek(t._position);else{var i=r.getSeekState();i&&"IN_PROGRESS"===i.state&&(t._logger.debug("Seeking on proxy to match seek that is in progress on provided player."),t.seek(i.position))}}r.isActuallyPlaying()?(t._logger.debug("Provided player is already playing."),t._notifyPlaying(!0)):r.isPlaying()?(t._logger.debug("Provided player is preparing to play."),t.play()):t.isPlaying()&&(t._logger.debug("Calling play() on provided player to match proxy."),t._playAndHandleAbort(r)),t._completeLocalSeekIfPlayerNotSeeking(r)}catch(e){t._triggerError(new a.PlayerFatalError("Unexpected error occurred whilst syncing.",e))}}))},t.prototype._completeLocalSeekIfPlayerNotSeeking=function(e){var t=e.getSeekState(),r=this.getSeekState();!r||"IN_PROGRESS"!==r.state||t&&"IN_PROGRESS"===t.state||this._signalSeekComplete()},t.prototype._playAndHandleAbort=function(e){var t=this._instanceLock;this._logger.debug("Calling play() on provided player."),e.play(),this._instanceLock===t&&!e.isPlaying()&&this.isPlaying()&&(this._logger.debug("Provided player was not playing after play() call completed."),this.pause())},t.prototype._pauseAndHandleAbort=function(e){var t=this._instanceLock;this._logger.debug("Calling pause() on provided player."),e.pause(),this._instanceLock===t&&e.isPlaying()&&!this.isPlaying()&&(this._logger.debug("Provided player was not paused after pause() call completed."),this.play())},t.prototype._unsync=function(){if(!this._unsynced){this._unsynced=!0,this._logger.debug("Unsyncing...");var e=this._player;if(e)try{this._volume=e.getVolume(),this._muted=e.getMuted(),this._position=e.getPosition()}catch(e){this._logger.error("Error whilst unsyncing.",e)}this._changeHandler&&(this._changeHandler.remove(),this._changeHandler=null),this._errorHandler&&(this._errorHandler.remove(),this._errorHandler=null),this._logger.debug("Unsynced."),this.isReady()&&!this.isDead()&&this._notifyStalled(!0)}},t}(o.BasePlayer);t.ProxyPlayerBase=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n;!function(e){e[e.LOADING=0]="LOADING",e[e.PLAYING=1]="PLAYING",e[e.PAUSED=2]="PAUSED",e[e.DEAD=3]="DEAD"}(n=t.State||(t.State={}))},function(e,t,r){(function(t,n){/*! +module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports={SCAudio:r(1),SCAudioPublicApiStreamURLRetriever:r(6),MaestroCore:r(2),MaestroLoaders:r(5),MaestroHTML5Player:r(4),MaestroHLSMSEPlayer:r(3)}},function(e,t,r){!function(t,n){e.exports=n(r(2),function(){try{return r(!function(){var e=new Error('Cannot find module "@sc/maestro-chromecast-player"');throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}(),function(){try{return r(!function(){var e=new Error('Cannot find module "@sc/maestro-flipper-player"');throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}(),function(){try{return r(3)}catch(e){}}(),function(){try{return r(4)}catch(e){}}(),r(5))}(this,function(e,t,r,n,o,i){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=36)}([function(t,r){t.exports=e},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t,r){void 0===r&&(r="API error.");var n=e.call(this,r)||this;return n.statusCode=t,n}return n(t,e),t.prototype.getCode=function(){return"SCAUDIO.API_ERROR."+(this.statusCode||"TIMEOUT")},t.prototype.getStatusCode=function(){return this.statusCode},t}(o.errors.PlayerFatalError);t.ApiError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){return e.call(this,t||"There was no format available that a player was able to play.")||this}return n(t,e),t.prototype.getCode=function(){return"SCAUDIO.NOT_SUPPORTED_ERROR"},t}(o.errors.PlayerFatalError);t.NotSupportedError=i},function(e,t,r){"use strict";function n(e){return new i({startPos:0,endPos:e,startLevel:0,endLevel:1,fromEnd:!1})}function o(e){return new i({startPos:e,endPos:0,startLevel:1,endLevel:0,fromEnd:!0})}Object.defineProperty(t,"__esModule",{value:!0}),t.buildFadeIn=n,t.buildFadeOut=o;var i=function(){function e(e){var t=e.startPos,r=e.endPos,n=e.startLevel,o=e.endLevel,i=e.fromEnd,a=void 0!==i&&i;if(t<0)throw new Error("startPos invalid.");if(r<0||!a&&r1)throw new Error("startLevel invalid.");if(o<0||o>1)throw new Error("endLevel invalid.");this._startPos=t,this._endPos=r,this._startLevel=n,this._endLevel=o,this._fromEnd=a}return e.prototype.calculate=function(e,t){var r=this._fromEnd?t-500-this._startPos:this._startPos,n=this._fromEnd?t-500-this._endPos:this._endPos;if(e=0&&(this._volumeAutomators.splice(t,1),this._updateVolume())},t.prototype._triggerError=function(t){e.prototype._triggerError.call(this,t)},t.prototype.providePlayer=function(t,r,n){void 0===n&&(n=!0),this._volumeAutomationSupported=n,e.prototype.providePlayer.call(this,t,r)},t.prototype._setVolume=function(e){this._userVolume=e,this._calculateAndSetVolume()},t.prototype._kill=function(){this._timer&&window.clearTimeout(this._timer),null!==this._connectionLossTimer&&window.clearTimeout(this._connectionLossTimer),this._abortPauseFade(),e.prototype._kill.call(this)},t.prototype._calculateIfConnectionRequired=function(){var e=this,t=this.isLoading()&&"navigator"in window&&!window.navigator.onLine;t?null===this._connectionLossTimer&&(this._connectionLossTimer=window.setTimeout(function(){e._connectionLossTimer=null,e._connectionRequired=!0,e._onConnectionRequired.dispatch(void 0)},h)):this._connectionRequired?(this._connectionRequired=!1,this._onConnectionRecovered.dispatch(void 0)):null!==this._connectionLossTimer&&(window.clearTimeout(this._connectionLossTimer),this._connectionLossTimer=null)},t.prototype._completePauseFade=function(){if(this._pauseFadeDeferred){this._pauseFadeTimer&&window.clearTimeout(this._pauseFadeTimer);var e=this._pauseFadeDeferred;this._pauseFadeDeferred=null,e.resolve(this.pause())}},t.prototype._abortPauseFade=function(){this._pauseFadeTimer&&(window.clearTimeout(this._pauseFadeTimer),this._pauseFadeTimer=null),this._pauseFadeDeferred&&(this._pauseFadeDeferred.reject(new Error("Player was killed.")),this._pauseFadeDeferred=null)},t.prototype._updateVolume=function(){var e=this;if(this._volumeAutomationSupported){this._ensureNotDead(),this._timer&&(window.clearTimeout(this._timer),this._timer=null);var t=this.getDuration();if(null!==t){var r=this._volumeAutomators,o=this.getPosition(),i=1/0,a=1;r.forEach(function(e){var r=e.calculate(o,t),s=r.nextCalculatePosition,u=r.level;a*=n(0,1,u),s1)throw new Error("Invalid volume level.");se=e,ae.forEach(function(t){return t.setVolume(e)})}function _(){return se}function g(e){if("boolean"!=typeof e)throw new Error("muteEnabled must be a boolean.");ue=e,ae.forEach(function(t){return t.setMuted(e)})}function y(){return ue}function v(){n()}function m(e){function t(){return Ae&&Me?h(Ae,Me):null}function r(){if(ke&&window.clearTimeout(ke),Pe.debug("Performing retrieve."),De)throw new Error("Player job already running. Only one instance of the job is allowed at once.");if(Re.isDead())throw new Error("Proxy is dead.");var e=new q(function(){function e(){function t(e){if(e!==E.helpers.abortableJob.abortedError)if(e instanceof A.RequestError){var t=e.getStatusCode();switch(t){case 401:Re._triggerError(new M.GeoBlockedError(t,"Geoblocked (logged out)."));break;case 403:Re._triggerError(new M.GeoBlockedError(t,"Geoblocked (logged in)."));break;case 404:Re._triggerError(new x.UnavailableError(t,"Track unavailable."));break;case null:throw new Error("Status code should not be null.");default:Re._triggerError(new D.ApiError(t))}}else e===E.helpers.retry.noMoreAttemptsError?Re._triggerError(new O.TimedOutError):(Pe.error("Unexpected error.",e),Re._triggerError(new E.errors.PlayerFatalError("An unexpected error occurred.",e)))}s=o(),s.onCompletion(function(r){if(r)try{Me=r,Te||(Te=a());var o=Te[0];o?n():(Pe.debug("Excluding rendition.",r.rendition),d.excludeRendition(r.rendition),Te=null,e())}catch(e){t(e)}else Me?(Pe.error("There were no stream formats that were supported."),Re._triggerError(new k.NotSupportedError)):(Pe.error("There were no streams available."),Re._triggerError(new K.NoStreamsError))}),s.onError(t)}function n(){function e(e){if(!u&&!i&&(u=!0,Pe.debug("Player releasing control.",e),t.abort(e),!Re.isDead()))if(e&&e.retryPlayer){var n=Oe.getDelay();n>0?(Pe.debug("Waiting "+n+" ms."),ke=window.setTimeout(function(){return r()},n)):r()}else r()}var n=Te&&Te[0];if(!n)throw new Error("No player to build.");if(!Me)throw new Error("No rendition.");var o=Me.url,a=Me.rendition,s=new E.Descriptor(o,a.maestroProtocol,a.maestroFormat),u=!1;Pe.debug("Building player...");var l=void 0,d=void 0;try{d=n(s,Me,e)}catch(e){l=e}void 0===d?(Pe.error("Exception occurred whilst building player.",l),e()):null===d?(Pe.debug("Player not supported for current descriptor."),e()):(Ae=d,Pe.debug("Built player."),Ae.isDead()?(Pe.debug("Player died during construction."),e()):(le.addPlayer(Ae),Ae.onChange.subscribe(function(t){var r=t.dead;r&&(Pe.debug("Player died."),e())})))}var i=!1,s=null;return e(),{result:E.helpers.deferred.buildDeferred().promise,abort:function(e){i=!0,Pe.info("Player job aborted.",e),De=null,s&&s.abort(),Te&&(e&&e.retryPlayer?Pe.debug("Player might be used again for current rendition."):(Pe.debug("Player will not be used again for current rendition."),Te.shift()),Re.getPlayer()&&Re.removePlayer(),Ae&&(Ae.kill(),Ae=null),Me=null)}}}),t=e.run();return De=t}function o(){return z(function(){return new q(function(){var e=d.getUrl();Pe.debug("Retrieving a URL...");var t=e.whenComplete().then(function(e){return e?Pe.debug("Retrieved URL.",{rendition:e.rendition,bitrate:e.bitrate}):Pe.debug("No URL provided."),e&&te.indexOf(e.rendition)<0?(Pe.warn("Unknown rendition. Skipping...",e.rendition),{success:!1}):{result:e,success:!0}}).catch(function(e){if(e instanceof A.RequestError){var t=e.getStatusCode();if(null===t||0===t)return null===t?Pe.warn("Timed out when retrieving URL. Will retry."):Pe.warn("Network error when retrieving URL. Will retry."),{success:!1}}throw e!==E.helpers.abortableJob.abortedError&&Pe.error("Error retrieving URL.",e),e});return{result:t,abort:function(){return e.abort()}}})},ge)}function a(){var e=[];return $&&l.indexOf($)>=0&&(Pe.debug("ChromecastPlayer found.",Y.version),me?e.push(function(e){var t=new $(e,{name:Ee,castContext:me,logger:re});return Re.providePlayer(t,{syncPosition:!1,syncVolume:!1},!1),t}):Pe.warn("Could not construct chromecast player because context not provided.")),Z&&l.indexOf(Z)>=0&&(Pe.debug("FlipperPlayer found.",Q.version),e.push(function(e){var t=new Z(e,{name:Ee,logger:re});return I.takeControlFlipperPlayer(Re,t,Pe,xe||void 0),t})),X&&l.indexOf(X)>=0&&(Pe.debug("HLSMSEPlayer found.",J.version),e.push(function(e,t,r){var n=new X(e,{name:Ee,playlistLoader:b.stringLoader,segmentLoader:b.arrayBufferLoader,keyLoader:b.arrayBufferLoader,expectedSegmentFormat:{mimeType:"audio/mpeg"},logger:re});return u(n,function(){return r()}),L.takeControlHLSMSEPlayer(J,Re,n,ve,r,t.rendition,d,t.url,Pe),n})),W&&l.indexOf(W)>=0&&(Pe.debug("HTML5Player found.",V.version),e.push(function(e,t,r){var n=t.timeRetrieved;if(ve&&("hls"===e.getProtocol().name||void 0===n))return null;var o;if(ve){if(void 0===n)throw new Error("Expecting timeUrlRetrieved to be set.");o={urlExpires:!0,timeUrlRetrieved:n}}else o={urlExpires:!1};var i=new W(e,{name:Ee,logger:re});return u(i,function(){return r()}),C.takeControlHTML5Player(V,Re,i,o,r,Pe),i})),e}function s(){De?(Pe.debug("Reloading stream URLs..."),Pe.debug("Aborting player job that is in progress."),De.abort(),Te=null,r()):Pe.debug("Reload requested, but not reloading as there is nothing to reload.")}function u(e,t){function r(){var t=e.getMediaElement();t&&t!==n()&&(Pe.debug("Revoking audio element that was created internally because player is ready now."),e.revokeMediaElement())}function o(){var r=e.getMediaElement();if(r&&r!==n()&&(Pe.debug("Revoking audio element that was created internally, even though player is not ready."),e.revokeMediaElement()),!e.getMediaElement()){ne&&!ne.isDead()&&(Pe.info("Revoking audio element from a player."),ne.isPlaying()&&Pe.warn("The audio element is being revoked from a player which is playing. Only one player should be playing at once."),ne.revokeMediaElement()),ne=e,Pe.info("Providing audio element to a different player.");var o=oe={};e.provideMediaElement(n()).catch(function(r){e.isDead()||oe!==o||(Pe.error("An unexpected error occurred when trying to provide the audio element to a player.",r),t())})}}e.isReady()?r():e.onReady.subscribe(r),Re.onPlayIntent.subscribe(function(){e.isDead()||o()}),Re.isPlaying()&&(e.isDead()||o()),ne||o()}var l=e.playerClasses,d=e.streamUrlRetriever,c=e.duration,f=void 0===c?null:c,_=e.preloadingEnabled,g=void 0!==_&&_,y=e.pausedMaxBufferLength,v=void 0===y?2e3:y,m=e.playingMaxBufferLength,N=void 0===m?9e4:m,B=e.fadeOutDuration,H=void 0===B?0:B,ee=e.logger,re=void 0===ee?E.logger.noOpLogger:ee,de=e.audioPerformanceReporter,ce=e.audioReporter,he=e.audioCheckpointInterval,pe=void 0===he?3e4:he,fe=e.errorReporter,_e=e.urlProviderRetryDelayCalculator,ge=void 0===_e?G():_e,ye=e.streamUrlsExpire,ve=void 0===ye||ye,me=e.chromecastContext;if(!(d instanceof w.BaseStreamUrlRetriever))throw new Error("StreamUrlRetriever invalid.");if(null!==f&&("number"!=typeof f||f<0))throw new Error("duration invalid.");if("boolean"!=typeof g)throw new Error("preloadingEnabled invalid.");if(null!==v&&("number"!=typeof v||v<0))throw new Error("pausedMaxBufferLength invalid.");if(null!==N&&("number"!=typeof N||N<0))throw new Error("playingMaxBufferLength invalid.");if(null!==H&&("number"!=typeof H||H<0))throw new Error("fadeOutDuration invalid.");if(null!==re&&"function"!=typeof re&&"object"!=typeof re)throw new Error("logger invalid.");if(void 0!==ce&&"function"!=typeof ce)throw new Error("audioReporter invalid.");if(null!==pe&&("number"!=typeof pe||pe<0))throw new Error("audioCheckpointInterval invalid.");if(void 0!==de&&"function"!=typeof de)throw new Error("audioPerformanceReporter invalid.");if(void 0!==fe&&"function"!=typeof fe)throw new Error("errorReporter invalid.");if(void 0!==ge&&"function"!=typeof ge)throw new Error("retryDelayCalculator invalid.");var Ee="SCAudio-"+ ++ie,be=d.getTrackId();null!==be&&(Ee+="-"+be);var we=new U.LogCollector;re=E.logger.cloneLogger(we,re);var Pe=E.logger.prefixLogger(re,Ee),Se=p();Pe.info("Building player...",{ua:navigator.userAgent,logId:Se});var Re=new T.Player({name:Ee+"-Proxy",logger:re,mediaSessionEnabled:!0,pausedMaxBufferLength:v,playingMaxBufferLength:N,preloadingEnabled:g},s);ae.push(Re),Re.setVolume(se),Re.setMuted(ue),H>0&&Re.addVolumeAutomator(P.buildFadeOut(H));var Te=null,Ae=null,Me=null,De=null,xe=null,ke=null,Oe=new F.DecayingExponentialDelayCalculator;if(de&&(xe=new S.AudioPerformanceEventGenerator(Re,de,Pe,t,X)),ce&&new j.AudioEventGenerator(Re,ce,pe,Pe),fe&&R.generateErrorEvents(Re,we,Se,be,fe,Pe,t,J||null,ve),Re.onChange.subscribe(function(e){var t=e.dead,r=e.playing;if(t)Pe.info("Player killed."),ae.splice(ae.indexOf(Re),1),De&&De.abort(),ke&&window.clearTimeout(ke);else if(r===!0){var o=l.some(function(e){return i(e)});o&&n()}}),null!==f&&(Pe.debug("Setting initial duration.",f),Re.setInitialDuration(f)),g)Pe.debug("Preloading is enabled, so performing retrieve immediately."),r();else{Pe.debug("Preloading is disabled, so deferring retrieve until either a play intent or preloading is enabled.");var Ce=function(){Le.remove(),Ie.remove(),Pe.debug("Preloading now enabled or received a play request. Peforming retrieve."),r()},Le=Re.onPreloadingEnabled.subscribe(Ce),Ie=Re.onPlayIntent.subscribe(Ce)}return Re}Object.defineProperty(t,"__esModule",{value:!0});var E=r(0),b=r(35),w=r(4),P=r(3),S=r(17),R=r(22),T=r(5),A=r(7),M=r(9),D=r(1),x=r(12),k=r(2),O=r(11),C=r(20),L=r(8),I=r(19),N=r(6),F=r(21),U=r(23),j=r(16),B=r(18),q=E.helpers.abortableJob.AbortableJob,H=E.helpers.retry,z=H.retry,G=H.buildExponentialDelayCalculator,K=r(10),V=void 0;try{V=r(34)}catch(e){}var J=void 0;try{J=r(33)}catch(e){}var Q=void 0;try{Q=r(32)}catch(e){}var Y=void 0;try{Y=r(31)}catch(e){}var W=V?V.HTML5Player:null,X=J?J.HLSMSEPlayer:null,Z=Q?Q.FlipperPlayer:null,$=Y?Y.ChromecastPlayer:null,ee=/^[^?#]*/,te=Object.keys(N.renditions).map(function(e){return N.renditions[e]}),re=null,ne=null,oe={},ie=-1,ae=[],se=1,ue=!1,le=new B.CacheManager(15e7,E.logger.noOpLogger);t.setGlobalVolume=f,t.getGlobalVolume=_,t.setGlobalMuted=g,t.getGlobalMuted=y,t.activateAudioElement=v,t.buildPlayer=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(3);!function(e){e.Fade=o.Fade,e.buildFadeIn=o.buildFadeIn,e.buildFadeOut=o.buildFadeOut}(n=t.volumeAutomation||(t.volumeAutomation={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=1e3,i=function(){function e(e,t,r,i){this._checkpointTimer=null,this._logger=n.logger.prefixLogger(i,"AudioEventGenerator"),this._player=e,this._eventReporter=t,this._checkpointInterval=null!==r?Math.max(o,r):null,this._startReporting()}return e.prototype._startReporting=function(){var e=this,t=this._player;t.onChange.subscribe(function(r){var n=r.actuallyPlaying,o=r.ended;n===!0&&!t.isEnded()||o===!1&&t.isActuallyPlaying()?(null===e._checkpointInterval||e._checkpointTimer||(e._checkpointTimer=window.setInterval(function(){e._reportEvent("checkpoint")},e._checkpointInterval)),e._reportEvent("play")):(n===!1&&!t.isEnded()||o===!0&&t.isActuallyPlaying())&&(e._checkpointTimer&&(window.clearInterval(e._checkpointTimer),e._checkpointTimer=null),e._reportEvent("pause"))})},e.prototype._reportEvent=function(e){var t=this._player.getDuration();if(null===t)throw new Error("Duration should exist now.");var r={type:e,position:this._player.getPosition(),duration:t};this._logger.debug("Generated audio event.",r),this._eventReporter(r)},e}();t.AudioEventGenerator=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(30),i=function(){function e(e,t,r,o,i){this._logger=n.logger.prefixLogger(r,"AudioPerformanceEventGenerator"),this._player=e,this._eventReporter=t,this._getPlayerDetails=o,this._HLSMSEPlayer=i,this._measureGeneralEvents()}return e.prototype.reportManualEvent=function(e){this._logger.debug("Reporting manual audio performance event.",e),this._eventReporter(e)},e.prototype._measureGeneralEvents=function(){var e=this,t=this._player,r=new o.Timer,n=null,i=null;t.onChange.subscribe(function(a){var s=a.dead,u=a.playing,l=a.actuallyPlaying,d=a.seeking,c=a.loading;s||(u===!0&&(r.isComplete()||r.start()),l===!0&&(r.isComplete()||(r.stop(),e._reportEvent("play",r.getTime()))),d===!0&&t.isReady()&&(n=new o.Timer,n.start()),d===!1&&n&&(n.stop(),e._reportEvent("seek",n.getTime())),c===!0&&r.isComplete()&&(i=new o.Timer,i.start()),c===!1&&i&&(i.stop(),e._reportEvent("buffer",i.getTime())))})},e.prototype._reportEvent=function(e,t,r){var n=r||this._getPlayerDetails();if(!n)return void this._logger.warn("Cannot report event because there is no player.",e,t);var o={type:e,latency:t,protocol:n.protocol,playerType:n.name,host:n.host,bitrate:n.bitrate,format:n.format||void 0};this._logger.debug("Generated audio performance event.",o),this._eventReporter(o)},e}();t.AudioPerformanceEventGenerator=i},function(e,t,r){"use strict";function n(e,t){var r=e.getMemoryCacheController();r&&r.setMaxCacheSize(t)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=2e4,a=function(){function e(e,t){this._maxCacheSize=e,this._players=[],this._updateTimer=null,this._logger=o.logger.prefixLogger(t,"CacheManager"),this._logger.debug("Initialized with cache size "+e+" bytes.")}return e.prototype.addPlayer=function(e){var t=this;if(this._logger.debug("Adding player to cache manager."),e.isDead())return void this._logger.debug("Player was dead.");var r=this._players;e.onChange.subscribe(function(n){var o=n.playing,i=n.dead;i===!0?(t._logger.debug("Removing player that became dead."),r.splice(r.indexOf(e),1),t._update()):o===!0?(t._logger.debug("Updating because player started playing."),r.splice(r.indexOf(e),1),r.unshift(e),t._update()):o===!1&&(t._logger.debug("Updating because player became paused."),t._update())}),e.isPlaying()?r.unshift(e):r.push(e),this._update()},e.prototype._update=function(){var e=this;if(this._updateTimer&&(window.clearTimeout(this._updateTimer),this._updateTimer=null),0===this._players.length)return void this._logger.debug("There are no longer any players to manage.");var t=this._players.reduce(function(e,t){return t.isPlaying()?e.playingPlayers.push(t):e.pausedPlayers.push(t),e},{playingPlayers:[],pausedPlayers:[]}),r=t.playingPlayers,o=t.pausedPlayers,a=r.reduce(function(e,t){return e+(t.getMemoryCacheUsage()||0)},0),s=o.reduce(function(e,t){return e+(t.getMemoryCacheUsage()||0)},0);if(a>this._maxCacheSize){this._logger.debug("All playing players are using more than the max cache size. Cleaning...",a,this._maxCacheSize);var u=this._maxCacheSize/r.length;r.forEach(function(e){return n(e,u)}),o.forEach(function(e){return n(e,0)})}else this._logger.debug("Recalculating cache sizes...",a+s,this._maxCacheSize),r.concat(o).reduce(function(t,r){return n(r,Math.max(0,e._maxCacheSize-t)),t+(r.getMemoryCacheUsage()||0)},0);this._updateTimer=window.setTimeout(function(){return e._update()},i)},e}();t.CacheManager=a},function(e,t,r){"use strict";function n(e,t,r,n){r=o.logger.prefixLogger(r,"FlipperPlayer Controller"),n&&t.onAudioPerformanceEvent.subscribe(function(e){var t=e.protocol,o=e.type,i=e.latency,a=e.player_type,s=e.host,u=e.bitrate,l=e.format,d="Flipper";if(a!==d)return void r.warn("Ignoring audio performance event from flipper because the player_type was incorrect.",a);var c={protocol:t,type:o,latency:i,playerType:d,host:s,bitrate:u,format:l};n.reportManualEvent(c)}),e.providePlayer(t)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0);t.takeControlFlipperPlayer=n},function(e,t,r){"use strict";function n(e,t,r,n,a,s){function u(){var e=r.getDuration(),t=l();if(null!==e&&null!==t){var n=e-r.getPosition();i()+n>t&&(s.info("Releasing control because stream URL would expire before reaching end."),a({retryPlayer:!0}))}}function l(){if(!n.urlExpires)return null;var e=r.getDuration();return null===e?null:n.timeUrlRetrieved+e+105e3}function d(){var e=l();return null!==e&&e<=i()}s=o.logger.prefixLogger(s,"HTML5Player Controller"),r.onError.subscribe(function(t){t instanceof o.errors.NotSupportedError||(t instanceof e.errors.NetworkError&&d()?(s.info("Releasing control as a network error occurred, and the URL has expired."), +a({retryPlayer:!0})):(s.error("Unexpected player error.",t),a({retryPlayer:!1})))}),n.urlExpires&&(r.onPlayIntent.subscribe(function(){return u()}),r.onSeekIntent.subscribe(function(){return u()})),t.providePlayer(r)}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=o.helpers.time.now;t.takeControlHTML5Player=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._delayFactor=0,this._lastRequestTime=0}return e.prototype.getDelay=function(){var e=Date.now()-this._lastRequestTime;return this._lastRequestTime=Date.now(),this._delayFactor=Math.max(0,this._delayFactor-e/15e3),this._delayFactor+=1,Math.pow(2,this._delayFactor)},e}();t.DecayingExponentialDelayCalculator=n},function(e,t,r){"use strict";function n(e,t,r,n,a,s,u,l,d){function c(e){var o=u()||void 0,i={errorCode:e,log:t.getLog(),logId:r,trackId:n,protocol:o&&o.protocol,playerType:o?o.name:"MaestroUnknown",host:o&&o.host,bitrate:o&&o.bitrate,format:o&&(o.format||void 0),url:o&&o.url};s.debug("Generated audio error event.",i),a(i)}s=o.logger.prefixLogger(s,"ErrorGenerator"),e.onError.subscribe(function(e){if(!(d&&l&&i.isErrorWhichShouldTriggerURLRefresh(l,e))){var t,r;r=e instanceof o.errors.ProxyProvidedPlayerFatalError?e.getProvidedPlayerFatalError():e,t=r.getCode(),r instanceof o.errors.NotSupportedError||c(t)}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=r(8);t.generateErrorEvents=n},function(e,t,r){"use strict";function n(e){return e.map(function(e){try{return JSON.stringify(e)}catch(e){return""}})}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){void 0===e&&(e=200),this._bufferSize=e,this._log=[]}return e.prototype.getLog=function(){return this._log},e.prototype.debug=function(e){for(var t=[],r=1;rthis._bufferSize&&this._log.shift()},e}();t.LogCollector=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.apiMobile={scProtocol:"sc.api-mobile",maestroProtocol:{name:"sc.api-mobile"},maestroFormat:{}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encryptedHlsMp3={scProtocol:"encrypted-hls",scFormat:"mp3",maestroProtocol:{name:"hls"},maestroFormat:{mimeType:"application/x-mpegURL"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hlsMp3={scProtocol:"hls",scFormat:"mp3",maestroProtocol:{name:"hls"},maestroFormat:{mimeType:"application/x-mpegURL"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpMp3={scProtocol:"http",scFormat:"mp3",maestroProtocol:{name:"http"},maestroFormat:{mimeType:"audio/mpeg"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maestroChromecast={scProtocol:"maestro.chromecast",maestroProtocol:{name:"maestro.chromecast"},maestroFormat:{}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(27),o=r(26),i=r(25),a=r(24),s=r(28);t.renditions={httpMp3:n.httpMp3,hlsMp3:o.hlsMp3,encryptedHlsMp3:i.encryptedHlsMp3,apiMobile:a.apiMobile,maestroChromecast:s.maestroChromecast}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=n.helpers.time.now,i=function(){function e(){this._start=null,this._end=null}return e.prototype.start=function(){if(this.isComplete())throw new Error("Timer completed.");this._start=o()},e.prototype.isComplete=function(){return null!==this._end},e.prototype.stop=function(){if(null===this._start)throw new Error("Not started.");this._end=o()},e.prototype.getTime=function(){if(null===this._end)throw new Error("Not completed.");return this._end-this._start},e}();t.Timer=i},function(e,r){if("undefined"==typeof t){var n=new Error('Cannot find module "@sc/maestro-chromecast-player"');throw n.code="MODULE_NOT_FOUND",n}e.exports=t},function(e,t){if("undefined"==typeof r){var n=new Error('Cannot find module "@sc/maestro-flipper-player"');throw n.code="MODULE_NOT_FOUND",n}e.exports=r},function(e,t){if("undefined"==typeof n){var r=new Error('Cannot find module "@sc/maestro-hls-mse-player"');throw r.code="MODULE_NOT_FOUND",r}e.exports=n},function(e,t){if("undefined"==typeof o){var r=new Error('Cannot find module "@sc/maestro-html5-player"');throw r.code="MODULE_NOT_FOUND",r}e.exports=o},function(e,t){e.exports=i},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),t.version="11.3.1",t.buildNumber=315;var o=r(15);t.volumeAutomation=o.volumeAutomation;var i=r(4);t.BaseStreamUrlRetriever=i.BaseStreamUrlRetriever;var a=r(7);t.RequestError=a.RequestError;var s=r(5);t.Player=s.Player;var u=r(6);t.renditions=u.renditions,n(r(13)),n(r(14))}])})},function(e,t,r){!function(t,r){e.exports=r()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=35)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"PLAYER_FATAL_ERROR"},t}(o.PlayerError);t.PlayerFatalError=i},function(e,t,r){"use strict";function n(){var e,t,r=!1,n=new o.Promise(function(r,n){e=r,t=n});return{promise:n,resolve:function(t){r||(r=!0,e(t))},reject:function(e){r||(r=!0,t(e))},isSettled:function(){return r}}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(10);t.buildDeferred=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=function(){function e(){this._listeners=[],this.dispatch=this.dispatch.bind(this)}return e.prototype.subscribe=function(e){var t=this,r={fn:e,payloads:[]};return this._listeners.push(r),{remove:function(){var e=t._listeners.indexOf(r);return e>=0&&(t._listeners.splice(e,1),!0)},retrieve:function(){return t._dispatchListenerPayloads(r)}}},e.prototype.dispatch=function(e,t){var r=this,o="number"==typeof t?{time:t}:t||{},i=void 0!==o.time?o.time:n.now(),a=this._listeners;a.forEach(function(t){return t.payloads.push({time:i,payload:e})});var s=!1;do s=!a.some(function(e){var t=e.fn,n=e.payloads,o=n.shift();return!!o&&(r._callHandler(t,o),!0)});while(!s)},e.prototype.getHandle=function(){return{subscribe:this.subscribe.bind(this)}},e.prototype._dispatchListenerPayloads=function(e){for(var t=e.fn,r=e.payloads;;){var n=r.shift();if(!n)break;this._callHandler(t,n)}},e.prototype._callHandler=function(e,t){try{e(t.payload,t.time)}catch(e){window.setTimeout(function(){throw e},0)}},e}();t.EventDispatcher=o},function(e,t,r){"use strict";function n(e,t){return{debug:function(r){for(var n=[],o=1;o= 0.")):(this._loadingDelay=void 0!==e.loadingDelay?e.loadingDelay:400,this.onError=this._onError.getHandle(),this.whenReady=this._readyDeferred.promise,this._stateManager.subscribe(function(e,r){return t._onChange(e,r)}),this._stateManager.subscribe(function(e,r){var n=e.playing,o=e.actuallyPlaying,i=r.dead;i||void 0===n||o===n||t._handlePlayPauseChange(n)}),this._stateManager.subscribe(function(e,r){var n=e.seek,o=r.dead;!o&&n&&"IN_PROGRESS"===n.state&&t._handleSeekChange(n.position)}),this._registerMediaSessionActionHandlers(),this._notifyMediaSessionPaused(),this.onChange=this._buildEventHandle(function(e,r){var n=r.ready;if(void 0!==n&&n!==!0)throw new Error("Ready state is invalid.");var o=r.duration;if(void 0!==o&&null===o)throw new Error("Duration state is invalid.");var i=r.dead;if(void 0!==i&&i!==!0)throw new Error("Dead state is invalid.");var a={ready:n,ended:r.ended,duration:o,playing:r.playing,actuallyPlaying:r.actuallyPlaying,stalled:r.stalled,loading:r.loading,playRejection:r.playing===!1?t._lastPlayError||void 0:void 0,pauseRejection:r.playing===!0?t._lastPauseError||void 0:void 0,seeking:r.seeking,seek:r.seek||void 0,positionJumped:void 0!==r.positionJumped||void 0,state:r.state,fatalError:r.fatalError||void 0,dead:i};Object.keys(a).some(function(e){return void 0!==a[e]})&&e(a)}),this.onDurationChange=this._buildEventHandle(function(e,t){var r=t.duration;void 0!==r&&null!==r&&e(r)}),this.onReady=this._buildEventHandle(function(e,t){var r=t.ready;r===!0&&e(void 0)}),this.onStateChange=this._buildEventHandle(function(e,t){var r=t.state;void 0!==r&&e(r)}),this.onPlay=this._buildEventHandle(function(e,t){var r=t.actuallyPlaying;r===!0&&e(void 0)}),this.onPlayIntent=this._buildEventHandle(function(e,t){var r=t.playing;r===!0&&e(void 0)}),this.onPlayRejection=this._buildEventHandle(function(e,r){var n=r.playing;n===!1&&t._lastPlayError&&e(t._lastPlayError)}),this.onPause=this._buildEventHandle(function(e,t){var r=t.actuallyPlaying;r===!1&&e(void 0)}),this.onPauseIntent=this._buildEventHandle(function(e,t){var r=t.playing;r===!1&&e(void 0)}),this.onPauseRejection=this._buildEventHandle(function(e,r){var n=r.playing;n===!0&&t._lastPauseError&&e(t._lastPauseError)}),this.onSeek=this._buildEventHandle(function(e,t){var r=t.seek;r&&"COMPLETED"===r.state&&e(void 0)}),this.onSeekIntent=this._buildEventHandle(function(e,t){var r=t.seeking;r===!0&&e(void 0)}),this.onSeekRejection=this._buildEventHandle(function(e,t){var r=t.seek;r&&"ERROR"===r.state&&e(r.error)}),this.onPositionJumped=this._buildEventHandle(function(e,t){var r=t.positionJumped;void 0!==r&&e(void 0)}),this.onEnded=this._buildEventHandle(function(e,t){var r=t.ended;r===!0&&e(void 0)}),this.onLeftEnded=this._buildEventHandle(function(e,t){var r=t.ended;r===!1&&e(void 0)}),this.onStallStart=this._buildEventHandle(function(e,t){var r=t.stalled;r===!0&&e(void 0)}),this.onStallEnd=this._buildEventHandle(function(e,t){var r=t.stalled;r===!1&&e(void 0)}),this.onLoadStart=this._buildEventHandle(function(e,t){var r=t.loading;r===!0&&e(void 0)}),void(this.onLoadEnd=this._buildEventHandle(function(e,t){var r=t.loading;r===!1&&e(void 0)})))}return e.prototype.isReady=function(){return this._stateManager.getState().ready},e.prototype.getPosition=function(){var e=this;return this._stateManager.update(function(t){var r=t.dead;if(r)return e._positionWhenKilled;var n=e._getPositionOrPositionSeekingTo();return e._updateEnded(n),n})},e.prototype.getLastPlayedPosition=function(){var e=this._stateManager.getState(),t=e.actuallyPlaying,r=e.stalled;return t&&!r?this.getPosition():this._positionWhenStoppedPlaying},e.prototype.getListenTime=function(){var e=this._stateManager.getState(),t=e.actuallyPlaying,r=e.ended,n=this._listenTimeBase;return t&&!r&&(n+=d.now()-this._timePlaybackStarted),n},e.prototype.isStalled=function(){return this._stateManager.getState().stalled},e.prototype.isLoading=function(){return this._stateManager.getState().loading},e.prototype.isPlaying=function(){return this._stateManager.getState().playing},e.prototype.isActuallyPlaying=function(){return this._stateManager.getState().actuallyPlaying},e.prototype.isEnded=function(){return this._stateManager.getState().ended},e.prototype.getState=function(){return this._stateManager.getState().state},e.prototype.getUrlController=function(){return null},e.prototype.getBufferController=function(){return null},e.prototype.getMemoryCacheMaxSize=function(){return null},e.prototype.getMemoryCacheUsage=function(){return null},e.prototype.getMemoryCacheController=function(){return null},e.prototype.getFatalError=function(){return this._stateManager.update(function(e){var t=e.fatalError;return t})},e.prototype.isDead=function(){return this._stateManager.getState().dead},e.prototype.getDuration=function(){var e=this._stateManager.getState(),t=e.ready,r=e.duration;return t?r:null},e.prototype.setVolume=function(e){if(e<0||e>1)throw new Error("Volume must be >= 0 and <= 1.");this._setVolume(e)},e.prototype.getCurrentBufferedTimeRange=function(){var e=this.getBufferedTimeRanges(),t=this.getPosition();return l.find(e,function(e){return e.containsTime(t)})||null},e.prototype.play=function(){var e=this;this._ensureNotDead(),this._logger.debug("play() called.");try{return this._stateManager.update(function(t){return t.playing?e._logger.debug("Intent is already to be playing."):(e._logger.debug("Requesting play."),t.playing=!0,e._lastPlayError=null),t.playDeferred&&!t.playDeferred.isSettled()||(t.playDeferred=u.buildDeferred()),t.playDeferred.promise})}catch(e){return this._triggerError(new i.PlayerFatalError("Unexpected error when attempting to play.",e)),o.Promise.reject(e)}},e.prototype.pause=function(){var e=this;this._ensureNotDead(),this._logger.debug("pause() called.");try{return this._stateManager.update(function(t){return t.playing?(e._logger.debug("Requesting pause."),t.playing=!1,e._lastPauseError=null):e._logger.debug("Intent is already to be paused."),t.pauseDeferred&&!t.pauseDeferred.isSettled()||(t.pauseDeferred=u.buildDeferred()),t.pauseDeferred.promise})}catch(e){return this._triggerError(new i.PlayerFatalError("Unexpected error when attempting to pause.",e)),o.Promise.reject(e)}},e.prototype.seek=function(e){var t=this;return this._ensureNotDead(),this._logger.debug("seek() called.",e),this._stateManager.update(function(r){if(e<0)return t._logger.warn("Rejecting seek immediately as the position was negative."),o.Promise.reject(new Error("You were attempting to seek to a negative time."));if(null!==r.duration&&e>r.duration)return t._logger.warn("Rejecting seek immediately as the duration is now known, and the requested positon was past it."),o.Promise.reject(new Error("You were attempting to seek past the end of the media."));try{var n=u.buildDeferred();return r.seek&&"IN_PROGRESS"===r.seek.state&&r.seek.position===e?t._logger.debug("Seek already requested to the same position.",e):(t._logger.debug("Requesting seek.",e),r.seeking=!0,r.seek={state:"IN_PROGRESS",position:e},r.positionJumped=Object.create(null),t._updateEnded(e)),t._queuedSeekDeferreds.push({position:e,deferred:n}),n.promise}catch(e){return t._triggerError(new i.PlayerFatalError("Unexpected error when attempting to seek.",e)),o.Promise.reject(e)}})},e.prototype.getSeekState=function(){return this._stateManager.getState().seek},e.prototype.kill=function(){var e=this;this._stateManager.update(function(t){t.dead||(e._logger.debug("kill() called."),t.dead=!0,e._positionWhenKilled=e._getPositionOrPositionSeekingTo(),e._updateEnded(e._positionWhenKilled))})},e.prototype._atomic=function(e){return this._stateManager.update(function(){return e()})},e.prototype._ensureNotDead=function(){if(this._stateManager.getState().dead)throw new Error("Player is dead.")},e.prototype._notifyStalled=function(e){this._stalled!==e&&(this._logger.debug("notifyStalled() called.",e),this._stalled=e,this._pendingPositionWhenStoppedPlaying=this.getPosition(),this._stateManager.update(function(){}))},e.prototype._getQueuedSeekPosition=function(){var e=this.getSeekState();return e&&"IN_PROGRESS"===e.state?e.position:null},e.prototype._provideDuration=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),r.duration!==e){var n=t._getPositionOrPositionSeekingTo();if(e<0||r.ready&&n>e)throw t._triggerError(new i.PlayerFatalError("Attempt to update duration to an invalid value.")),new Error("Duration cannot be less than the current position.");t._logger.debug("provideDuration() called.",e),r.ready?(r.duration=e,t._updateEnded(n)):t._queuedDuration=e}})},e.prototype._notifyPlaying=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to register playback as started before ready.")),new Error("Player must be ready first.");e!==r.actuallyPlaying&&(t._logger.debug("notifyPlaying() called.",e),e||(t._pendingPositionWhenStoppedPlaying=t.getPosition()),r.actuallyPlaying=r.playing=e,e?t._lastPlayError=null:t._lastPauseError=null)})},e.prototype._notifyPlayRejection=function(e){var t=this;return this._stateManager.update(function(r){if(t._ensureNotDead(),!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to reject a play request before player ready.")),new Error("Player must be ready first.");if(r.actuallyPlaying||!r.playing)throw t._triggerError(new i.PlayerFatalError("Attempt to reject a play request when not valid.")),new Error("Playing state is incorrect.");t._logger.debug("notifyPlayRejection() called.",e),r.playing=!1,t._lastPlayError=e})},e.prototype._notifyPauseRejection=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){if(!r.ready)throw t._triggerError(new i.PlayerFatalError("Attempt to reject pause request before player ready.")),new Error("Player must be ready first.");if(!r.actuallyPlaying||r.playing)throw t._triggerError(new i.PlayerFatalError("Attempt to reject pause request when not valid.")),new Error("Playing state is incorrect.");t._logger.debug("notifyPauseRejection() called.",e),r.playing=!0,t._lastPauseError=e})},e.prototype._notifySeekRejection=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){if(!r.ready)throw new Error("Player must be ready first.");if(!r.seek||"IN_PROGRESS"!==r.seek.state)throw new Error("A seek hasn't been requested.");t._logger.debug("notifySeekRejection() called.",e),r.seeking=!1,r.seek={state:"ERROR",error:e},r.positionJumped=Object.create(null),t._updateEnded(t._getPositionOrPositionSeekingTo())})},e.prototype._signalReady=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ready twice.")),new Error("Ready already signalled.");if(null===e._queuedDuration)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ready when duration unknown.")),new Error("Duration is still unknown.");e._logger.debug("signalReady() called."),t.ready=!0,t.duration=e._queuedDuration,t.seek&&"IN_PROGRESS"===t.seek.state&&t.seek.position>t.duration&&(t.seeking=!1,t.seek={state:"ERROR",error:new Error("You were attempting to seek past the end of the media.")});var r=e._getPositionOrPositionSeekingTo();r>0&&e._signalPositionJump(),e._updateEnded(r)})},e.prototype._signalSeekComplete=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw new Error("Player must be ready first.");if(!t.seek||"IN_PROGRESS"!==t.seek.state)throw new Error("There shouldn't be a seek in progress.");var r=t.duration;if(t.seek&&"IN_PROGRESS"===t.seek.state&&t.seek.position>r)throw new Error("Seek cannot have completed given it was to a time greater than the duration.");e._logger.debug("signalSeekComplete() called."),t.seek={state:"COMPLETED",position:t.seek.position},t.seeking=!1,e._updateEnded(e._getPositionOrPositionSeekingTo())})},e.prototype._signalPositionJump=function(){return this._stateManager.update(function(e){e.seek&&"IN_PROGRESS"===e.seek.state||(e.positionJumped=Object.create(null))})},e.prototype._signalEnded=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal ended before player was ready.")),new Error("Player must be ready first.");if(!t.ended){if(t.seek&&"IN_PROGRESS"===t.seek.state)return void e._logger.debug("Ignoring signalEnded() call because a seek is in progress.");e._logger.debug("signalEnded() called."),t.ended=!0}})},e.prototype._signalNotEnded=function(){var e=this;return this._ensureNotDead(),this._stateManager.update(function(t){if(!t.ready)throw e._triggerError(new i.PlayerFatalError("Attempt to signal not ended before player was ready.")),new Error("Player must be ready first.");if(t.ended){if(null!==t.seek&&"IN_PROGRESS"===t.seek.state)return void e._logger.debug("Ignoring signalNotEnded() call because a seek is in progress.");e._logger.debug("signalNotEnded() called."),t.ended=!1}})},e.prototype._triggerError=function(e){var t=this;return this._ensureNotDead(),this._stateManager.update(function(r){var n=!1;if(r.ready&&e instanceof a.NotSupportedError&&(e=new i.PlayerFatalError("Invalid NotSupportedError."),n=!0),e instanceof i.PlayerFatalError){e instanceof a.NotSupportedError?t._logger.info("NotSupportedError occurred.",e):t._logger.error("Fatal error occurred.",e),r.fatalError?t._logger.warn("A fatal error already occurred."):r.fatalError=e,t._errors.push(e),r.errorOccurred=Object.create(null);try{t._positionWhenKilled=t.getPosition()}catch(e){t._logger.error("Tried to get position before player was killed but got exception.",e)}r.dead=!0}else t._logger.warn("Non-fatal error occurred.",e),t._errors.push(e),r.errorOccurred=Object.create(null);if(n)throw new Error("Not supported errors are only valid before the player is ready.")})},e.prototype._buildEventHandle=function(e){var t=this;return{subscribe:function(r){var n=function(e){return r(e,d.now())};return t._stateManager.subscribe(function(t){e(n,t)})}}},e.prototype._finalizeState=function(e){if(e.dead)this._lastPlayError=new Error("Player was killed."),e.loading=!1,this._clearLoadingDelay(),e.stalled=!0,e.actuallyPlaying=!1,e.playing=!1,e.state=c.State.DEAD;else{e.stalled=!e.ended&&(!e.ready||this._stalled||!(!e.seek||"IN_PROGRESS"!==e.seek.state));var t=!e.ended&&(e.playing||e.actuallyPlaying)&&(e.stalled||e.playing!==e.actuallyPlaying);t?this._loadingDelay?this._scheduleLoadingDelay():e.loading=!0:(e.loading=!1,this._clearLoadingDelay()),e.state=this._calculateState(e)}},e.prototype._scheduleLoadingDelay=function(){var e=this;this._loadingDelayTimer||(this._loadingDelayTimer=window.setTimeout(function(){e._stateManager.update(function(e){return e.loading=!0})},this._loadingDelay))},e.prototype._clearLoadingDelay=function(){this._loadingDelayTimer&&(window.clearTimeout(this._loadingDelayTimer),this._loadingDelayTimer=null)},e.prototype._getPositionOrPositionSeekingTo=function(){var e=this;return this._stateManager.update(function(t){if(t.seek&&"IN_PROGRESS"===t.seek.state)return t.seek.position;if(!t.ready||null===t.duration)return 0;var r=e._getPosition();if(t.seek&&"IN_PROGRESS"===t.seek.state)return t.seek.position;var n=t.duration;if(r<0)throw e._logger.error("Player provided invalid position.",r,n),e._triggerError(new i.PlayerFatalError("Player provided a position that was invalid.")),new Error("Player provided invalid position.");if(null!==n&&r>n)throw e._logger.error("Player provided invalid position.",r,n),e._triggerError(new i.PlayerFatalError("Player provided a position that was invalid.")),new Error("Player provided invalid position.");return r})},e.prototype._updateEnded=function(e){return this._stateManager.update(function(t){var r=t.duration,n=e===r&&t.ready;t.ended=n})},e.prototype._calculateState=function(e){var t=e.dead,r=e.loading,n=e.playing,o=e.ended;return t?c.State.DEAD:r?c.State.LOADING:n&&!o?c.State.PLAYING:c.State.PAUSED},e.prototype._registerMediaSessionActionHandlers=function(){var e=this;this._mediaSessionEnabled&&y&&(y.setActionHandler("play",function(){e.isDead()||e.play()}),y.setActionHandler("pause",function(){e.isDead()||e.pause()}),y.setActionHandler("seekbackward",function(){e.isDead()||e.seek(Math.max(0,e.getPosition()-g))}),y.setActionHandler("seekforward",function(){e.isDead()||e.seek(Math.min(e.getDuration()||0,e.getPosition()+g))}))},e.prototype._notifyMediaSessionPlaying=function(){this._mediaSessionEnabled&&y&&(y.playbackState="playing")},e.prototype._notifyMediaSessionPaused=function(){this._mediaSessionEnabled&&y&&(y.playbackState="paused")},e.prototype._afterUpdate=function(e){this._finalizeState(e)},e.prototype._afterDispatches=function(){var e=this,t=this._errors;this._errors=[],t.forEach(function(t){return e._onError.dispatch(t)})},e.prototype._onChange=function(e,t){var r=this,n=e.ready,o=e.dead,i=e.fatalError,a=e.playing,s=e.actuallyPlaying,u=e.ended;if(s===!1&&(this._positionWhenStoppedPlaying=this._pendingPositionWhenStoppedPlaying),n===!0&&(this._logger.debug("Resolving ready deferred."),this._readyDeferred.resolve(void 0)),s===!0&&this._registerMediaSessionActionHandlers(),a===!0?this._notifyMediaSessionPlaying():a===!1&&this._notifyMediaSessionPaused(),t.pauseDeferred&&!t.pauseDeferred.isSettled()&&t.playing){var l=this._lastPauseError||new Error("Pause request aborted.");this._logger.debug("Rejecting pause deferred.",l),t.pauseDeferred.reject(l)}if(t.playDeferred&&!t.playDeferred.isSettled()&&!t.playing){var l=this._lastPlayError||new Error("Play request aborted.");this._logger.debug("Rejecting play deferred.",l),t.playDeferred.reject(l)}if(t.playDeferred&&!t.playDeferred.isSettled()&&t.actuallyPlaying&&(this._logger.debug("Resolving play deferred."),t.playDeferred.resolve(void 0)),!t.pauseDeferred||t.pauseDeferred.isSettled()||t.actuallyPlaying||(this._logger.debug("Resolving pause deferred."),t.pauseDeferred.resolve(void 0)),s===!0&&!t.ended||u===!1&&t.actuallyPlaying?this._timePlaybackStarted=d.now():(s===!1&&!t.ended||u===!0&&t.actuallyPlaying)&&(this._listenTimeBase+=d.now()-this._timePlaybackStarted,this._timePlaybackStarted=null),this._queuedSeekDeferreds=this._queuedSeekDeferreds.filter(function(e){var n=e.position,o=e.deferred;if(t.seek)if("IN_PROGRESS"!==t.seek.state){if(!t.stalled||"ERROR"===t.seek.state)return"ERROR"!==t.seek.state?(r._logger.debug("Resolving seek()."),o.resolve(void 0)):(r._logger.debug("Rejecting seek().",t.seek.error),o.reject(t.seek.error)),!1}else if("IN_PROGRESS"!==t.seek.state||t.seek.position!==n)return r._logger.debug("Rejecting seek() because another seek was requested.",n),o.reject(new Error("Seek request aborted because another seek was requested to a different position.")),!1;return!0}),o===!0){if(this._logger.debug("Calling _kill() on player."),this._kill(),this._logger.info("Player killed."),!t.ready){var l=i||new Error("Player was killed.");this._logger.debug("Rejecting whenReady."),this._readyDeferred.reject(l)}this._queuedSeekDeferreds.forEach(function(e){var t=e.position,n=e.deferred,o=i||new Error("Seek aborted as player killed.");r._logger.debug("Rejecting seek().",t),n.reject(o)}),this._stateManager.kill(),this._logger.debug("Player dead.")}},e}();t.BasePlayer=v},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype, +new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(7),i=r(4),a=r(0),s=r(3),u=function(e){function t(t){var r=e.call(this,t)||this;return r._errorHandler=null,r._changeHandler=null,r._player=null,r._instanceLock=null,r._position=0,r._volume=1,r._muted=!1,r._unsynced=!1,r._logger=s.prefixLogger(r._logger,"ProxyPlayerBase"),r}return n(t,e),t.prototype.getVolume=function(){return this._player&&!this._unsynced?this._player.getVolume():this._volume},t.prototype.getMuted=function(){return this._player&&!this._unsynced?this._player.getMuted():this._muted},t.prototype.setMuted=function(e){return this._player&&!this._unsynced?this._player.setMuted(e):void(this._muted=e)},t.prototype.getBufferedTimeRanges=function(){return this._player&&!this._unsynced?this._player.getBufferedTimeRanges():[]},t.prototype.getCurrentBufferedTimeRange=function(){return this._player&&!this._unsynced?this._player.getCurrentBufferedTimeRange():null},t.prototype.getMaxBufferLength=function(){return this._player&&!this._unsynced?this._player.getMaxBufferLength():null},t.prototype._providePlayer=function(e,t){if(void 0===t&&(t={syncPosition:!0,syncVolume:!0}),this._ensureNotDead(),this._player)throw new Error("A player has already been provided.");this._logger.debug("providePlayer() called."),this._instanceLock=Object.create(null),this._player=e,this._sync(t)},t.prototype._removePlayer=function(){if(this._ensureNotDead(),!this._player)throw new Error("There is no player to remove.");this._logger.debug("removePlayer() called."),this._unsync(),this._instanceLock=null,this._player=null},t.prototype._setInitialDuration=function(e){var t=this;if(this._ensureNotDead(),e<0)throw new Error("Cannot set duration to a value < 0.");null===this.getDuration()&&this._atomic(function(){t._fixPosition(e),t._provideDuration(e),t.isReady()||t._signalReady()})},t.prototype._triggerError=function(t){e.prototype._triggerError.call(this,t)},t.prototype._getPlayer=function(){return this.isDead()?null:this._player},t.prototype._setVolume=function(e){return this._player&&!this._unsynced?this._player.setVolume(e):void(this._volume=e)},t.prototype._handlePlayPauseChange=function(e){var t=this._player;t&&(e?this._playAndHandleAbort(t):this._pauseAndHandleAbort(t))},t.prototype._handleSeekChange=function(e){var t=this._player;t?t.seek(e):this._position=e},t.prototype._getPosition=function(){if(this._player&&!this._unsynced){if(!this._changeHandler)throw new Error("Handler should exist.");if(this._changeHandler.retrieve(),this._player)return this._player.getPosition()}return this._position},t.prototype._kill=function(){if(this._player&&!this._player.isDead()){if(!this._changeHandler)throw new Error("Handler should exist.");if(this._changeHandler.retrieve(),this._player&&(this._player.kill(),!this._unsynced))throw new Error("Unsync should have happened.")}this._player=null},t.prototype._fixPosition=function(e){this._position>e&&(this._logger.debug("A duration was provided that was less than the current position. Changing position to the duration.",e),this._position=e,this._signalPositionJump())},t.prototype._sync=function(e){var t=this,r=this._player;if(!r)throw new Error("Player should have become available by now.");return this._unsynced=!1,this._logger.debug("Syncing...",this.isPlaying(),this.isActuallyPlaying()),r.isDead()?void this._logger.debug("Provided player is dead."):(this._errorHandler=r.onError.subscribe(function(e){e instanceof a.PlayerFatalError||t._triggerError(e)}),this._changeHandler=r.onChange.subscribe(function(e){t._atomic(function(){if(e.dead)return t._logger.debug("Player has gone to DEAD state."),t._unsync(),void(t.isDead()||e.fatalError&&t._handleFatalError(e.fatalError));if(void 0!==e.duration&&(t._fixPosition(e.duration),t._provideDuration(e.duration),t.isReady()||(t._signalReady(),t._notifyStalled(r.isStalled()))),e.seek){var n=t.getSeekState();n&&"IN_PROGRESS"===n.state?"COMPLETED"===e.seek.state&&n.position===e.seek.position?t._signalSeekComplete():"COMPLETED"===e.seek.state&&n.position!==e.seek.position?t._notifySeekRejection(new Error("Another seek occurred to a different position.")):"IN_PROGRESS"===e.seek.state&&n.position!==e.seek.position?t.seek(e.seek.position):"ERROR"===e.seek.state&&t._notifySeekRejection(e.seek.error):"COMPLETED"===e.seek.state&&t._signalPositionJump()}e.ended===!0&&t._signalEnded(),e.ended===!1&&t._signalNotEnded(),void 0!==e.stalled&&t._notifyStalled(e.stalled),e.playing===!1&&e.playRejection?t.isActuallyPlaying()?(t._triggerError(new i.PlayerError("Paused because a player was provided that refused to play.")),t._notifyPlaying(!1)):t._notifyPlayRejection(e.playRejection):e.playing===!1&&(r.isActuallyPlaying()?t.pause():void 0===e.actuallyPlaying&&t.isReady()&&t._notifyPlaying(!1)),e.playing===!0&&e.pauseRejection?t._notifyPauseRejection(e.pauseRejection):e.playing===!0&&t.play(),void 0!==e.actuallyPlaying&&t._notifyPlaying(e.actuallyPlaying),e.positionJumped&&t._signalPositionJump()})}),void this._atomic(function(){try{if(!t.isReady()&&r.isReady()){t._logger.debug("Provided player is already ready. Making proxy player ready.");var n=r.getDuration();t._fixPosition(n),t._provideDuration(n),t._signalReady()}if(e.syncVolume&&(r.setVolume(t._volume),r.setMuted(t._muted)),e.syncPosition)t._logger.debug("Seeking to match position."),r.seek(t._position);else{var o=t.getSeekState();if(o&&"IN_PROGRESS"===o.state)t._logger.debug("Seeking to match position because a seek has been queued."),r.seek(t._position);else{var i=r.getSeekState();i&&"IN_PROGRESS"===i.state&&(t._logger.debug("Seeking on proxy to match seek that is in progress on provided player."),t.seek(i.position))}}t._position!==r.getPosition()&&t._signalPositionJump(),r.isActuallyPlaying()?(t._logger.debug("Provided player is already playing."),t._notifyPlaying(!0)):r.isPlaying()?(t._logger.debug("Provided player is preparing to play."),t.play()):t.isPlaying()?(t._logger.debug("Calling play() on provided player to match proxy."),t._playAndHandleAbort(r)):t.isReady()&&t.isActuallyPlaying()&&(t._logger.debug("Switching to paused state, as provided player and proxy intended state is paused."),t._notifyPlaying(!1))}catch(e){t._triggerError(new a.PlayerFatalError("Unexpected error occurred whilst syncing.",e))}}))},t.prototype._playAndHandleAbort=function(e){var t=this._instanceLock;this._logger.debug("Calling play() on provided player."),e.play(),this._instanceLock===t&&!e.isPlaying()&&this.isPlaying()&&(this._logger.debug("Provided player was not playing after play() call completed."),this.isActuallyPlaying()?(this._triggerError(new i.PlayerError("Paused because a player was provided that refused to play.")),this._notifyPlaying(!1)):this.pause())},t.prototype._pauseAndHandleAbort=function(e){var t=this._instanceLock;this._logger.debug("Calling pause() on provided player."),e.pause(),this._instanceLock===t&&e.isPlaying()&&!this.isPlaying()&&(this._logger.debug("Provided player was not paused after pause() call completed."),this.play())},t.prototype._unsync=function(){if(!this._unsynced){this._unsynced=!0,this._logger.debug("Unsyncing...");var e=this._player;if(e)try{this._volume=e.getVolume(),this._muted=e.getMuted(),this._position=e.getPosition()}catch(e){this._logger.error("Error whilst unsyncing.",e)}this._changeHandler&&(this._changeHandler.remove(),this._changeHandler=null),this._errorHandler&&(this._errorHandler.remove(),this._errorHandler=null),this._logger.debug("Unsynced.",this.isPlaying(),this.isActuallyPlaying()),this.isReady()&&!this.isDead()&&this._notifyStalled(!0)}},t}(o.BasePlayer);t.ProxyPlayerBase=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n;!function(e){e[e.LOADING=0]="LOADING",e[e.PLAYING=1]="PLAYING",e[e.PAUSED=2]="PAUSED",e[e.DEAD=3]="DEAD"}(n=t.State||(t.State={}))},function(e,t,r){(function(t,n){/*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version 4.0.5 */ -!function(t,r){e.exports=r()}(this,function(){"use strict";function e(e){return"function"==typeof e||"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}function i(e){Y=e}function a(e){W=e}function s(){return function(){return t.nextTick(p)}}function u(){return"undefined"!=typeof Q?function(){Q(p)}:c()}function l(){var e=0,t=new $(p),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function d(){var e=new MessageChannel;return e.port1.onmessage=p,function(){return e.port2.postMessage(0)}}function c(){var e=setTimeout;return function(){return e(p,1)}}function p(){for(var e=0;e=3){var t=parseInt(e[1],10),r=parseInt(e[2],10);if(!isNaN(t)&&!isNaN(r))return{major:t,minor:r}}return null}function i(){return u}Object.defineProperty(t,"__esModule",{value:!0});var a="undefined"!=typeof navigator?navigator.userAgent:"",s=!/chrome|opera/i.test(a)&&/safari/i.test(a),u=a.indexOf("MSIE ")>=0||a.indexOf("Trident/")>=0,l=/version\/(\d+)\.(\d+)/i;t.isSafari=n,t.getSafariVersion=o,t.isIE=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this._counter=0,this._onExit=e,this._onEnter=t||null}return e.prototype.enter=function(e){this._counter++,1===this._counter&&this._onEnter&&(this._enterReturnVal=this._onEnter());try{return e?e(this._enterReturnVal):void 0}finally{this._counter--,0===this._counter&&this._onExit(this._enterReturnVal)}},e}();t.OnExit=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10);t.Promise=n.Promise},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r){this.url=e,this.protocol=t,this.format=r}return e.prototype.getUrl=function(){return this.url},e.prototype.getProtocol=function(){return this.protocol},e.prototype.getFormat=function(){return this.format},e}();t.Descriptor=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(25),i=r(11),a=r(26),s=r(12),u=r(4),l=r(0);!function(e){e.PlayerError=u.PlayerError,e.PlayerFatalError=l.PlayerFatalError,e.DependencyError=o.DependencyError,e.NotSupportedError=i.NotSupportedError,e.URLUpdateError=a.URLUpdateError,e.ProxyProvidedPlayerFatalError=s.ProxyProvidedPlayerFatalError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(1),i=r(13),a=r(29),s=r(16),u=r(5),l=r(27),d=r(6),c=r(17),p=r(14),h=r(28),f=r(15),_=r(30);!function(e){e.OnExit=s.OnExit,e.find=u.find,e.Promise=c.Promise,e.always=p.always,e.compact=h.compact;var t;!function(e){e.buildCache=l.buildCache}(t=e.cache||(e.cache={}));var r;!function(e){e.buildDeferred=o.buildDeferred}(r=e.deferred||(e.deferred={}));var n;!function(e){e.getExtension=_.getExtension,e.buildAbsoluteUrl=_.buildAbsoluteUrl}(n=e.url||(e.url={}));var g;!function(e){e.AbortableJob=i.AbortableJob,e.abortedError=i.abortedError}(g=e.abortableJob||(e.abortableJob={}));var y;!function(e){e.noMoreAttemptsError=a.noMoreAttemptsError,e.retry=a.retry,e.buildExponentialDelayCalculator=a.buildExponentialDelayCalculator}(y=e.retry||(e.retry={}));var v;!function(e){e.isSafari=f.isSafari,e.getSafariVersion=f.getSafariVersion,e.isIE=f.isIE}(v=e.browser||(e.browser={}));var m;!function(e){e.now=d.now}(m=e.time||(e.time={}))}(n=t.helpers||(t.helpers={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(2),i=function(){function e(){this._aborted=!1,this._requestStarted=!1,this._response=null,this._responseDeferred=n.buildDeferred(),this._requestStartedDeferred=n.buildDeferred(),this._onRequestStart=new o.EventDispatcher,this.onRequestStart=this._onRequestStart.getHandle(),this.whenRequestStarted=this._requestStartedDeferred.promise}return e.prototype.getResponse=function(){return this._responseDeferred.promise},e.prototype.hasRequestStarted=function(){return this._requestStarted},e.prototype.abort=function(){if(!this._aborted){if(this._aborted=!0,this._response)throw new Error("Already have a response.");this._abort(),this._responseDeferred.reject(new Error("Aborted.")),this._requestStarted||this._requestStartedDeferred.reject(new Error("Aborted."))}},e.prototype._provideResponse=function(e){if(this._aborted)throw new Error("Response aborted.");if(this._response)throw new Error("Response already provided.");if(e instanceof Error)this._aborted=!0,this._responseDeferred.reject(e);else{if(!this._requestStarted)throw new Error("Request hasn't started yet.");this._response=e,this._responseDeferred.resolve(e)}},e.prototype._signalRequestStart=function(){if(this._aborted)throw new Error("Response aborted.");if(this._requestStarted)throw new Error("Request already started.");this._requestStarted=!0,this._requestStartedDeferred.resolve(void 0),this._onRequestStart.dispatch(void 0)},e}();t.LoaderRequest=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=r(3),a=r(8),s=r(12),u=function(e){function t(t){var r=e.call(this,t)||this;return r._onPlayerProvided=new o.EventDispatcher,r._onPlayerRemoved=new o.EventDispatcher,r._shouldPassThroughFatalErrors=!!t.shouldPassThroughFatalErrors,r.onPlayerProvided=r._onPlayerProvided.getHandle(),r.onPlayerRemoved=r._onPlayerRemoved.getHandle(),r._logger=i.prefixLogger(r._logger,"ProxyPlayer"),r}return n(t,e),t.prototype.providePlayer=function(e,t){void 0===t&&(t={syncPosition:!0,syncVolume:!0}),this._providePlayer(e,t),this._onPlayerProvided.dispatch(e)},t.prototype.removePlayer=function(){var e=this._getPlayer();if(!e)throw new Error("There is no player to remove.");this._removePlayer(),this._onPlayerRemoved.dispatch(e)},t.prototype.setInitialDuration=function(e){this._setInitialDuration(e)},t.prototype.getPlayer=function(){return this._getPlayer()},t.prototype._handleFatalError=function(e){this._shouldPassThroughFatalErrors?this._triggerError(e):this._triggerError(new s.ProxyProvidedPlayerFatalError(e))},t}(a.ProxyPlayerBase);t.ProxyPlayer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){if(this.start=e,this.duration=t,t<0)throw new RangeError("Duration must be >= 0.");this.end=e+t}return e.prototype.containsTime=function(e){return this.start<=e&&this.end>e},e}();t.TimeRange=n},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(e){if(d===setTimeout)return setTimeout(e,0);if((d===r||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function i(e){if(c===clearTimeout)return clearTimeout(e);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function a(){_&&h&&(_=!1,h.length?f=h.concat(f):g=-1,f.length&&s())}function s(){if(!_){var e=o(a);_=!0;for(var t=f.length;t;){for(h=f,f=[];++g1)for(var r=1;r= 0.")):null===o?i.reject(t.noMoreAttemptsError):l=n(function(){l=null,d()},o)}}),u.onError(function(e){u=null,i.reject(e)})};return d(),{result:i.promise,abort:function(){u&&u.abort(),l&&o(l)}}});return s.run()}function o(e){var t=void 0===e?{}:e,r=t.timeBase,n=void 0===r?500:r,o=t.threshold,i=void 0===o?3:o,a=t.delayCap,s=void 0===a?45e3:a,u=t.jitter,l=void 0===u?200:u,d=t.maxAttempts,c=void 0===d?null:d;if(n<=0)throw new Error("Time base must be > 0.");if(i<=0)throw new Error("Threshold must be > 0.");if(0===s)throw new Error("Delay cap must be null or > 0.");if(null!==c&&c<1)throw new Error("Max attempts must be >= 1.");return function(e){if(null!==c&&e>=c)return null;var t=e>0?Math.pow(2,e/i-1):0;return Math.min(t*n,s||1/0)+Math.round(Math.random()*l)}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(13),a=r(1);t.noMoreAttemptsError=new Error("No more attempts remaining."),t.retry=n,t.buildExponentialDelayCalculator=o},function(e,t,r){"use strict";function n(e){var t=a.exec(e);return t?t[1].toLowerCase():null}function o(e,t){return i.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}Object.defineProperty(t,"__esModule",{value:!0});var i=r(32),a=/^.*\.([^\.;\?#]*).*$/;t.getExtension=n,t.buildAbsoluteUrl=o},function(e,t,r){"use strict";function n(e){var t=Object.create(null);return Object.keys(e).forEach(function(r){t[r]=e[r]}),t}Object.defineProperty(t,"__esModule",{value:!0});var o=r(16),i=function(){},a=function(){function e(e,t){void 0===t&&(t={});var r=this;this._subscribers=[],this._onExit=new o.OnExit(function(){return r._after()}),this._state=n(e),this._initialState=n(e),this._afterUpdate=t.afterUpdate||i,this._afterDispatches=t.afterDispatches||i}return e.prototype.subscribe=function(e,t){var r=this;void 0===t&&(t=!0);var o=function(){var o={callback:e,localState:t?n(r._state):r._initialState};return r._subscribers.push(o),{remove:function(){var t=r._subscribers.map(function(e){return e.callback}).indexOf(e);return t>=0&&(r._subscribers.splice(t,1),!0)},retrieve:function(){r._updateSubscriber(o)}}};return t?o():this._onExit.enter(o)},e.prototype.subscribeIndividual=function(e,t,r){return this.subscribe(function(r){var n=r[e];void 0!==n&&t(n)},r)},e.prototype.getHandle=function(){return{subscribe:this.subscribe.bind(this)}},e.prototype.getIndividualHandle=function(e){var t=this;return{subscribe:function(r){return t.subscribeIndividual(e,r)}}},e.prototype.update=function(e){var t=this;return this._onExit.enter(function(){return e(t._state)})},e.prototype.getState=function(){return this._state},e.prototype._after=function(){var e=this;try{this._afterUpdate(this._state)}finally{this._subscribers.forEach(function(t){return e._updateSubscriber(t)}),this._afterDispatches(this._state)}},e.prototype._updateSubscriber=function(e){var t=this._calculateDiff(e.localState);if(Object.keys(t).length){e.localState=n(this._state);try{e.callback(t,e.localState)}catch(e){window.setTimeout(function(){throw e},0)}}},e.prototype._calculateDiff=function(e){var t=this,r=Object.create(null);return Object.keys(this._state).forEach(function(n){var o=t._state[n];o!==e[n]&&(r[n]=o)}),r},e}();t.StateManager=a},function(e,t,r){!function(t){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),t=t.trim(),!t){if(!r.alwaysNormalize)return e;var o=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return o.path=a.normalizePath(o.path),a.buildURLFromParts(o)}var i=this.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):t;var s=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var l={scheme:s.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(l.netLoc=s.netLoc,"/"!==i.path[0]))if(i.path){var d=s.path,c=d.substring(0,d.lastIndexOf("/")+1)+i.path;l.path=a.normalizePath(c)}else l.path=s.path,i.params||(l.params=s.params,i.query||(l.query=s.query));return null===l.path&&(l.path=r.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(l)},parseURL:function(e){var t=r.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(o,"");e.length!==(e=e.replace(i,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a}(this)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.0.5",t.buildNumber=790;var n=r(2),o=r(21),i=r(3),a=r(22);t.ProxyPlayer=a.ProxyPlayer;var s=r(8);t.ProxyPlayerBase=s.ProxyPlayerBase;var u=r(19);t.errors=u.errors;var l=r(20);t.helpers=l.helpers;var d=r(7);t.BasePlayer=d.BasePlayer;var c=r(18);t.Descriptor=c.Descriptor;var p=r(9);t.State=p.State;var h=r(23);t.TimeRange=h.TimeRange;var f;!function(e){e.EventDispatcher=n.EventDispatcher}(f=t.eventDispatcher||(t.eventDispatcher={}));var _;!function(e){e.LoaderRequest=o.LoaderRequest}(_=t.loader||(t.loader={}));var g;!function(e){e.noOpLogger=i.noOpLogger,e.consoleLogger=i.consoleLogger,e.prefixLogger=i.prefixLogger,e.cloneLogger=i.cloneLogger}(g=t.logger||(t.logger={}))}])})},function(e,t,r){!function(t,n){e.exports=n(r(2),r(4))}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=36)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.getCode=function(){return"GENERIC"},e}();t.RetrievalError=n},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.MSE_ERROR"},t}(o.errors.PlayerFatalError);t.MSEError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(t){var r=e.call(this)||this;return r._statusCode=t,r}return n(t,e),t.prototype.getStatusCode=function(){return this._statusCode},t.prototype.getCode=function(){return"UNACCEPTABLE_RESPONSE_STATUS_CODE"},t}(o.RetrievalError);t.UnacceptableResponseStatusCodeError=i},function(e,r){e.exports=t},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=function(e){function t(t){return e.call(this,"An error occurred trying to append to the buffer.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.APPEND_ERROR"},t}(o.MSEError);t.AppendError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=function(e){function t(t){return e.call(this,"An error occurred trying to initialize the buffer.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.INITIALIZE_ERROR"},t}(o.MSEError);t.InitializeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"A format could not be determined.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.NO_FORMAT_DETERMINED_ERROR"},t}(o.errors.NotSupportedError);t.NoFormatDeterminedError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"A transmuxer could not be found.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.NO_TRANSMUXER_ERROR"},t}(o.errors.NotSupportedError);t.NoTransmuxerError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){var r=e.call(this,"An error occurred when trying to retrieve a segment.",t)||this;return r._internalRetrievalError=t,r}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.RETRIEVAL_ERROR."+this._internalRetrievalError.getCode()},t}(o.errors.PlayerError);t.RetrievalError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"The playlist type is not supported.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.UNSUPPORTED_PLAYLIST_TYPE_ERROR"},t}(o.errors.PlayerFatalError);t.UnsupportedPlaylistTypeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"NO_DECRYPTOR"},t}(o.RetrievalError);t.NoDecryptorError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(t){var r=e.call(this)||this; -return r._details=t,r}return n(t,e),t.prototype.getDetails=function(){return this._details},t.prototype.getCode=function(){return"PLAYLIST_PARSE"},t}(o.RetrievalError);t.PlaylistParseError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"UNSUPPORTED_ENCRYPTION_ERROR"},t}(o.RetrievalError);t.UnsupportedEncryptionError=i},function(e,t,r){"use strict";function n(e){var t=e.reduce(function(e,t){return e+t.length},0),r=new Uint8Array(t),n=0;return e.forEach(function(e){r.set(e,n),n+=e.length}),r}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=r(19),a=r(20),s=o.helpers.Promise,u={rate:44100,id:3},l=16,d=2,c=u.rate,p=2,h=8;t.MP3ToMP4={getInputFormat:function(){return{mimeType:"audio/mpeg",audioCodec:{id:"mp3"}}},getOutputFormat:function(){return{mimeType:"audio/mp4",audioCodec:{id:"mp3"}}},transmux:function(e){return new s(function(t,r){function o(e){f||(f=!0,r(e))}function s(e){f||t(e)}var f=!1;try{var _=[],g=new i.MP3Parser,y=new a.MP4Mux({audioTrackId:0,videoTrackId:-1,tracks:[{codecId:p,channels:d,samplerate:u.rate,samplesize:l,timescale:c}]});if(y.ondata=function(e){return _.push(e)},g.onFrame=function(e){try{var t=new Uint8Array(e.length+1),r=p<<4;r|=u.id<<2,r|=(16===l?1:0)<<1,r|=2===d?1:0,t[0]=r,t.set(e,1);var n=0;y.pushPacket(h,t,n)}catch(e){o(e)}},g.push(e),g.close(),y.flush(),0===_.length)o(new Error("There was no output."));else{var v=_.shift();v?s({initData:v,data:n(_)}):o(new Error("No init data."))}}catch(e){o(e)}})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(5),i=r(6),a=r(2),s=r(7),u=r(8),l=r(9),d=r(10);!function(e){e.AppendError=o.AppendError,e.InitializeError=i.InitializeError,e.MSEError=a.MSEError,e.NoFormatDeterminedError=s.NoFormatDeterminedError,e.NoTransmuxerError=u.NoTransmuxerError,e.RetrievalError=l.RetrievalError,e.UnsupportedPlaylistTypeError=d.UnsupportedPlaylistTypeError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";function n(e){return void 0!==e.mimeType}function o(e,t){void 0===t&&(t={});var r=e.mimeType||t.mimeType,n=e.audioCodec||t.audioCodec,o=e.videoCodec||t.videoCodec,i=S([n,o]),a=i.length>0?'; codecs="'+i.map(function(e){return e.id}).join(",")+'"':"";return r+a}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=r(4),u=r(35),l=r(14),d=r(28),c=r(32),p=r(30),h=r(29),f=r(10),_=r(5),g=r(6),y=r(9),v=r(8),m=r(7),E=r(1),b=a.helpers.find,P=a.helpers.Promise,S=a.helpers.compact,w=a.helpers.time.now,R=a.helpers.deferred.buildDeferred,A=s.helpers.timeRanges.normalizeTimeRanges,T=a.errors.DependencyError,M=a.errors.PlayerFatalError,D=a.errors.URLUpdateError,x=a.eventDispatcher.EventDispatcher,k=a.logger.prefixLogger,O=a.helpers.abortableJob.abortedError,C=a.helpers.browser.getSafariVersion(),I=3e4,L=1e8,N=400,F=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n._onPlaylistRequestQueued=new x,n._onPlaylistRequestStart=new x,n._onPlaylistRetrieved=new x,n._onPlaylistRequestFailed=new x,n._onKeyRequestQueued=new x,n._onKeyRequestStart=new x,n._onKeyRetrieved=new x,n._onKeyRequestFailed=new x,n._onPlaylistParseStart=new x,n._onPlaylistParseEnd=new x,n._onSegmentRequestQueued=new x,n._onSegmentRequestStart=new x,n._onSegmentRetrieved=new x,n._onSegmentRequestFailed=new x,n._onSegmentTransmuxStart=new x,n._onSegmentTransmuxEnd=new x,n._onSegmentDecryptionStart=new x,n._onSegmentDecryptionEnd=new x,n._onSegmentReady=new x,n._onSegmentAppendQueued=new x,n._onSegmentAppendEnd=new x,n._playlist=null,n._playlistSegmentRetriever=null,n._initialPlaylistRetrieveCompleted=!1,n._mse=null,n._simpleMSE=null,n._retrieveDurationDeferred=R(),n._html5PlayerReady=!1,n._startPositionOffset=0,n._transmuxerAndMSEType=null,n._lastSegmentAppended=null,n._maxBufferLength=null,n._cacheSize=null,n._onFirstSegmentRetrieved=null,n._seekAttemptTimer=null,n._seekMetadataEventHandle=null,n._playlistDuration=null,n._logger=k(n._logger,"HLSMSEPlayer"),n.onPlaylistRequestQueued=n._onPlaylistRequestQueued.getHandle(),n.onPlaylistRequestStart=n._onPlaylistRequestStart.getHandle(),n.onPlaylistRetrieved=n._onPlaylistRetrieved.getHandle(),n.onPlaylistRequestFailed=n._onPlaylistRequestFailed.getHandle(),n.onKeyRequestQueued=n._onKeyRequestQueued.getHandle(),n.onKeyRequestStart=n._onKeyRequestStart.getHandle(),n.onKeyRetrieved=n._onKeyRetrieved.getHandle(),n.onKeyRequestFailed=n._onKeyRequestFailed.getHandle(),n.onPlaylistParseStart=n._onPlaylistParseStart.getHandle(),n.onPlaylistParseEnd=n._onPlaylistParseEnd.getHandle(),n.onSegmentRequestQueued=n._onSegmentRequestQueued.getHandle(),n.onSegmentRequestStart=n._onSegmentRequestStart.getHandle(),n.onSegmentRetrieved=n._onSegmentRetrieved.getHandle(),n.onSegmentRequestFailed=n._onSegmentRequestFailed.getHandle(),n.onSegmentTransmuxStart=n._onSegmentTransmuxStart.getHandle(),n.onSegmentTransmuxEnd=n._onSegmentTransmuxEnd.getHandle(),n.onSegmentDecryptionStart=n._onSegmentDecryptionStart.getHandle(),n.onSegmentDecryptionEnd=n._onSegmentDecryptionEnd.getHandle(),n.onSegmentReady=n._onSegmentReady.getHandle(),n.onSegmentAppendQueued=n._onSegmentAppendQueued.getHandle(),n.onSegmentAppendEnd=n._onSegmentAppendEnd.getHandle(),n.__descriptor=t,n.__playerDependencies=r,n._url=t.getUrl(),n}return i(t,e),t.prototype.getBufferedTimeRanges=function(){var e=this._playlistSegmentRetriever;return e?A(e.getSegmentsWithData().map(function(e){return e.segment.getTimeRange()})):[]},t.prototype.getMaxBufferLength=function(){return this._maxBufferLength},t.prototype.getBufferController=function(){var e=this;return{setMaxBufferLength:function(t){if(t<0)throw new Error("Max buffer length cannot be < 0.");e._logger.debug("Updating max buffer length.",t),e._maxBufferLength=t,e._playlistSegmentRetriever?e._playlistSegmentRetriever.updateMaxBufferLength(t):e._logger.debug("Cannot update right now. Playlist segment retriever doesn't exist.")}}},t.prototype.getUrlController=function(){var e=this;return{updateUrl:function(t){e._logger.debug("Updating URL.",t),e._url=t;var r=e._playlist;return r?(e._playlistRetrieveJob&&(e._playlistRetrieveJob.abort(),e._playlistRetrieveJob=null,e._logger.debug("Aborted playlist retrieve job.")),e._playlistSegmentRetriever&&(e._playlistSegmentRetriever.switchPlaylist(null),e._logger.debug("Removed current URL.")),e._playlist=null,void e._retrievePlaylist()):void e._logger.debug("Cannot update right now. Playlist doesn't exist yet.")}}},t.prototype.getMemoryCacheMaxSize=function(){return null!==this._cacheSize?this._cacheSize:L},t.prototype.getMemoryCacheUsage=function(){return this._playlistSegmentRetriever?this._playlistSegmentRetriever.getCacheUsage():0},t.prototype.getMemoryCacheController=function(){var e=this;return{setMaxCacheSize:function(t){if(t<0)throw new Error("Max size cannot be < 0.");e._logger.debug("Updating maximum cache size.",t),e._cacheSize=t,e._playlistSegmentRetriever&&e._playlistSegmentRetriever.updateCacheSize(t)}}},t.prototype._canPlay=function(){var t=this;return d.MSE.isSupported()?e.prototype._canPlay.call(this).then(function(e){if(e!==!0)return P.resolve(e);var r=t.__playerDependencies.expectedSegmentFormat;if(!r||!n(r))return t._logger.debug("Format could not be determined."),P.resolve(new m.NoFormatDeterminedError);var i=t._findTransmuxer(r);if(!i)return t._logger.debug("No transmuxer found."),P.resolve(new v.NoTransmuxerError);var a=i.getOutputFormat(),s=r;return t._transmuxerAndMSEType={transmuxer:i,mseType:o(a,s)},P.resolve(!0)}):(this._logger.debug("MSE not supported."),P.resolve(!1))},t.prototype._canPlayProtocol=function(e){return"hls"===e.name},t.prototype._canPlayType=function(e){return"application/x-mpegURL"===e},t.prototype._retrieveDuration=function(){return this._retrieveDurationDeferred.promise},t.prototype._signalReady=function(){this._html5PlayerReady=!0,this._initialPlaylistRetrieveCompleted&&e.prototype._signalReady.call(this)},t.prototype._initialize=function(){var t=this.__playerDependencies;if(null===this._maxBufferLength)if(void 0!==t.maxBufferLength){if(t.maxBufferLength<0)return void this._triggerError(new T("maxBufferLength cannot be < 0."));this._maxBufferLength=t.maxBufferLength}else this._maxBufferLength=I;if(this._logger.debug("Initialized max buffer length.",this._maxBufferLength),null===this._cacheSize)if(void 0!==t.memoryCacheSize){if(t.memoryCacheSize<0)return void this._triggerError(new T("memoryCacheSize cannot be < 0."));this._cacheSize=t.memoryCacheSize}else this._cacheSize=L;this._logger.debug("Initialized cache size.",this._cacheSize),e.prototype._initialize.call(this),this._retrievePlaylist()},t.prototype._initMediaElement=function(t,r){if(this._simpleMSE&&(this._simpleMSE.kill(),this._simpleMSE=null,this._logger.debug("Killed SimpleMSE.")),this._mse&&(this._mse.kill(),this._mse=null,this._logger.debug("Killed MSE.")),null!==this._seekAttemptTimer&&(window.clearTimeout(this._seekAttemptTimer),this._seekAttemptTimer=null,this._logger.debug("Cancelled seek attempt timer.")),null===r)e.prototype._initMediaElement.call(this,t,null);else{this._initMSE();var n=this._mse.getUrl();this._logger.debug("Setting MSE url.",n),e.prototype._initMediaElement.call(this,t,n)}},t.prototype._handleEndedEvent=function(){},t.prototype._shouldBeEnded=function(){if(e.prototype._shouldBeEnded.call(this))return!0;if(!this.getMediaElement())return!1;var t=this._duration;return this._stallDetected&&null!==t&&this._getTruePosition()>=t-N},t.prototype._getTruePosition=function(){var e=this.getMediaElement();if(!e)throw new Error("Media element should exist.");return this._startPositionOffset+this._getMediaElementPosition()},t.prototype._handleSeekChange=function(t){this._playlistSegmentRetriever&&(this._logger.debug("Explicitly updating playlist segment retriever, as seek requested."),this._playlistSegmentRetriever.update()),e.prototype._handleSeekChange.call(this,t)},t.prototype._performSeek=function(t,r){var n=this,o=this,i=o._simpleMSE,a=o._mse,s=this.getMediaElement();if(!i)throw new Error("SimpleMSE should exist.");if(!a)throw new Error("MSE should exist.");if(!s)throw new Error("Media element should exist.");null!==this._seekAttemptTimer&&(window.clearTimeout(this._seekAttemptTimer),this._seekAttemptTimer=null,this._logger.debug("Cancelled previous seek attempt timer.")),this._seekMetadataEventHandle&&(this._seekMetadataEventHandle.remove(),this._seekMetadataEventHandle=null,this._logger.debug("Removed previous loaded metadata event handler.")),i.kill(),a.kill(),this._logger.debug("SimpleMSE and MSE destroyed."),this._startPositionOffset=t;var u=null;this._onFirstSegmentRetrieved=function(e){return u=e},this._logger.debug("Initializing MSE and SimpleMSE for new position."),this._initMSE();var l=this._mse.getUrl();if(this._logger.debug("Updated media element MSE src.",l),e.prototype._initMediaElement.call(this,s,l),this.isPlaying()){this._logger.debug("Calling play() on media element as it was playing previously.");var d=s.play();d&&d.catch&&d.catch(function(e){"AbortError"!==e.name&&(n._logger.error("Unexpected play() error.",e),n._triggerError(new M("Exception from calling play() after seek.",e)))})}var c=function(e){var t=function(){n._startPositionOffset=Math.max(0,n._startPositionOffset-e),n._logger.debug("Updated start position offset.",n._startPositionOffset);var t=function(){n._seekAttemptTimer=null,n._logger.debug("Attempting to seek to the required offset.",e),s.currentTime=e/1e3;var o=1e3*s.currentTime;Math.abs(o-e)<=100?(n._logger.debug("Seeked to the required offset.",o),r()):(n._logger.warn("Seek attempt failed. Trying again shortly.",o),n._seekAttemptTimer=window.setTimeout(t,50))};t()};n._onFirstSegmentRetrieved=null,s.readyState===s.HAVE_METADATA?(n._logger.debug("Media element has metadata. Seeking to offset."),t()):(n._logger.debug("Media element has not loaded metadata. Waiting for metadata..."),n._seekMetadataEventHandle=n._listenToOnce("loadedmetadata",function(){n._seekMetadataEventHandle=null,n._logger.debug("Got metadata. Seeking to offset."),t()},{earlyAttach:!0}))};null!==u?(this._logger.debug("First segment already retrieved. Preparing to seek to initial offset."),c(u)):(this._logger.debug("Waiting for first segment to be retrieved."),this._onFirstSegmentRetrieved=function(e){n._logger.debug("First segment retrieved. Preparing to seek to initial offset."),c(e)})},t.prototype._kill=function(){this._simpleMSE&&(this._logger.debug("Killing SimpleMSE."),this._simpleMSE.kill()),this._mse&&(this._logger.debug("Killing MSE."),this._mse.kill()),this._playlistRetrieveJob&&(this._logger.debug("Aborting playlist retrieve job."),this._playlistRetrieveJob.abort()),this._playlistSegmentRetriever&&(this._logger.debug("Killing playlist segment retriever."),this._playlistSegmentRetriever.kill()),e.prototype._kill.call(this)},t.prototype._initMSE=function(){var e=this;if(!this._transmuxerAndMSEType)throw new Error("Transmuxer should have been configured.");this._lastSegmentAppended=null;var t=!1;C&&C.major<10&&this._transmuxerAndMSEType.transmuxer===l.MP3ToMP4&&(t=!0);var r=new d.MSE(this._transmuxerAndMSEType.mseType,this._logger,t),n=new c.SimpleMSE(r,function(){return e.getSegmentDataToAppendNext()},function(){return e._getMediaElementPosition()},function(t){e._triggerError(new _.AppendError(t))},this._logger);n.onAppendQueued.subscribe(this._onSegmentAppendQueued.dispatch),n.onAppendEnd.subscribe(this._onSegmentAppendEnd.dispatch),this._simpleMSE=n,n.start(),this._mse=r,r.whenInitialized().catch(function(t){t!==d.killedError&&(e._logger.error("Error during mse initialization.",t),e._triggerError(new g.InitializeError(t)))})},t.prototype._getMediaElementPosition=function(){var e=this.getMediaElement();if(!e)throw new Error("No media element.");return 1e3*e.currentTime},t.prototype._whenPlaylistRetrieved=function(){var t=this,r=this._playlist;if(!r)throw new Error("Playlist should have been retrieved.");var n=!this._initialPlaylistRetrieveCompleted;if(n)this._initialPlaylistRetrieveCompleted=!0,this._playlistDuration=r.getTotalDuration(),this._retrieveDurationDeferred.resolve(this._playlistDuration);else{var o=r.getTotalDuration();if(this._playlistDuration!==o)return this._logger.error("The duration from the new URL did not match the previous one."),void this._triggerError(new D("The duration from the new URL did not match the previous one.",{oldDuration:this._playlistDuration,newDuration:o}))}if(!this._transmuxerAndMSEType)throw new Error("Transmuxer should have been configured.");if(this._playlistSegmentRetriever)this._logger.debug("Switching playlist for playlist segment retriever."),this._playlistSegmentRetriever.switchPlaylist(r);else{var i=this._maxBufferLength;if(null===i)throw new Error("maxBufferLength should have been initiaized by now.");this._logger.debug("Creating playlist segment retriever.");var a=this._cacheSize;if(null===a)throw new Error("cacheSize should be set.");var s=new h.PlaylistSegmentRetriever({playlist:r,getPosition:function(){return t.getPosition()},maxBufferLength:i,cacheSize:a,transmuxer:this._transmuxerAndMSEType.transmuxer,logger:this._logger});s.onSegmentRequestQueued.subscribe(this._onSegmentRequestQueued.dispatch),s.onSegmentRequestStart.subscribe(this._onSegmentRequestStart.dispatch),s.onSegmentRetrieved.subscribe(this._onSegmentRetrieved.dispatch),s.onSegmentRequestFailed.subscribe(this._onSegmentRequestFailed.dispatch),s.onSegmentDecryptionStart.subscribe(this._onSegmentDecryptionStart.dispatch),s.onSegmentDecryptionEnd.subscribe(this._onSegmentDecryptionEnd.dispatch),s.onSegmentTransmuxStart.subscribe(this._onSegmentTransmuxStart.dispatch),s.onSegmentTransmuxEnd.subscribe(this._onSegmentTransmuxEnd.dispatch),this._playlistSegmentRetriever=s,s.onError.subscribe(function(e){t._logger.error("Error from playlist segment retriever.",e),e instanceof E.RetrievalError?t._triggerError(new y.RetrievalError(e)):t._triggerError(new M("Unexpected error when trying to retrieve segment.",e))}),s.onSegmentReady.subscribe(function(e){var r=e.eventRepresentation,n=w();t._logger.debug("Segment ready.",r),function(){var e=t._simpleMSE;if(e&&e.waitingForSegmentData()){var n=t.getSegmentDataToAppendNext();n&&(t._logger.debug("Providing segment to SimpleMSE.",r),e.provideNextSegmentData(n))}}(),t._onSegmentReady.dispatch({segment:r},{time:n})})}this._initialPlaylistRetrieveCompleted=!0,n&&this._html5PlayerReady&&e.prototype._signalReady.call(this)},t.prototype._retrievePlaylist=function(){var e=this;if(this._playlist)throw new Error("Playlist already exists.");var t=this.__playerDependencies,r=t.playlistLoader,n=t.segmentLoader,o=t.keyLoader,i=t.expectedSegmentFormat,a=t.isPlaylistResponseCodeAcceptable,s=t.isPlaylistResponseCodeRetryable,u=t.isSegmentResponseCodeAcceptable,l=t.isSegmentResponseCodeRetryable,d=t.isKeyResponseCodeAcceptable,c=t.isKeyResponseCodeRetryable;this._logger.debug("Creating playlist.",this._url);var h=new p.Playlist({url:this._url,segmentFormat:i,playlistLoader:r,segmentLoader:n,keyLoader:o,isPlaylistResponseCodeAcceptable:a,isPlaylistResponseCodeRetryable:s,isSegmentResponseCodeAcceptable:u,isSegmentResponseCodeRetryable:l,isKeyResponseCodeAcceptable:d,isKeyResponseCodeRetryable:c,logger:this._logger});h.onPlaylistRequestQueued.subscribe(this._onPlaylistRequestQueued.dispatch),h.onPlaylistRequestStart.subscribe(this._onPlaylistRequestStart.dispatch),h.onPlaylistRetrieved.subscribe(this._onPlaylistRetrieved.dispatch),h.onPlaylistRequestFailed.subscribe(this._onPlaylistRequestFailed.dispatch),h.onKeyRequestQueued.subscribe(this._onKeyRequestQueued.dispatch),h.onKeyRequestStart.subscribe(this._onKeyRequestStart.dispatch),h.onKeyRetrieved.subscribe(this._onKeyRetrieved.dispatch),h.onKeyRequestFailed.subscribe(this._onKeyRequestFailed.dispatch),h.onPlaylistParseStart.subscribe(this._onPlaylistParseStart.dispatch),h.onPlaylistParseEnd.subscribe(this._onPlaylistParseEnd.dispatch),this._playlist=h,this._playlistRetrieveJob=this._playlist.retrieve(),this._playlistRetrieveJob.onCompletion(function(){var t=e._playlist.getType();t!==p.PlaylistType.VOD?(e._logger.error("Unsupported playlist type.",t),e._triggerError(new f.UnsupportedPlaylistTypeError)):(e._logger.debug("Playlist retrieved."),e._whenPlaylistRetrieved())}),this._playlistRetrieveJob.onError(function(t){t!==O&&(e._logger.error("Error when retrieving playlist.",t),t instanceof E.RetrievalError?e._triggerError(new y.RetrievalError(t)):e._triggerError(new M("Unexpected error when retrieving playlist.",t)))})},t.prototype._findTransmuxer=function(e){var t=u.TransmuxerFactory.retrieveTransmuxers(e);this._logger.info("Finding a transmuxer...");var r=b(t,function(t){return d.MSE.isSupported(o(t.getOutputFormat(),e))})||null;return r?this._logger.info("Transmuxer found."):this._logger.warn("No transmuxer found."),r},t.prototype.getSegmentDataToAppendNext=function(){this._logger.debug("Looking for segment to append next.");var e=this._playlistSegmentRetriever;if(!e)return this._logger.debug("No segment retriever."),null;var t=this._lastSegmentAppended;if(t){var r=e.getSegmentsWithData(),n=r[r.map(function(e){return e.segment}).indexOf(t)+1];return n?(this._logger.debug("Found segment.",n.eventRepresentation),this._lastSegmentAppended=n.segment,{data:n.data,eventRepresentation:n.eventRepresentation}):(this._logger.debug("No segment found."),null)}var o=this.getPosition(),n=b(e.getSegmentsWithData(),function(e){return e.segment.getTimeRange().containsTime(o)});if(!n)return this._logger.debug("No segment found."),null;var i=o-n.segment.getTimeRange().start,a=this.getMediaElement();if(!a)throw new Error("Media element should exist.");this._logger.debug("Found initial segment.",n.eventRepresentation),this._lastSegmentAppended=n.segment,this._onFirstSegmentRetrieved&&this._onFirstSegmentRetrieved(i);var s=n.data,u=n.initData,l=s;return u&&(this._logger.debug("Prepending init data."),l=new Uint8Array(u.length+s.length),l.set(u,0),l.set(s,u.length)),{data:l,eventRepresentation:n.eventRepresentation}},t}(s.HTML5Player);t.HLSMSEPlayer=F},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(11),i=r(12),a=r(1),s=r(3),u=r(13);!function(e){e.NoDecryptorError=o.NoDecryptorError,e.PlaylistParseError=i.PlaylistParseError,e.RetrievalError=a.RetrievalError,e.UnacceptableResponseStatusCodeError=s.UnacceptableResponseStatusCodeError,e.UnsupportedEncryptionError=u.UnsupportedEncryptionError}(n=t.retrievalErrors||(t.retrievalErrors={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var o=function(){function e(e,t){for(var r=0;r>>8^255&f^99,e[c]=f,t[f]=c;var _=d[c],g=d[_],y=d[g],v=257*d[f]^16843008*f;r[c]=v<<24|v>>>8,n[c]=v<<16|v>>>16,o[c]=v<<8|v>>>24,i[c]=v,v=16843009*y^65537*g^257*_^16843008*c,a[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,u[f]=v<<8|v>>>24,l[f]=v,c?(c=_^d[d[d[y^_]]],p^=d[d[p]]):c=p=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var n,o,i=this.keySize+6,a=this.invKeySchedule,s=this.invSBox,u=this.invSubMix[0],l=this.invSubMix[1],d=this.invSubMix[2],c=this.invSubMix[3],p=this.uint8ArrayToUint32Array_(r),h=p[0],f=p[1],_=p[2],g=p[3],y=new Int32Array(e),v=new Int32Array(y.length),m=void 0,E=void 0,b=void 0,P=void 0,S=void 0,w=void 0,R=void 0,A=void 0,T=void 0,M=void 0,D=void 0,x=void 0;t>>24]^l[w>>16&255]^d[R>>8&255]^c[255&A]^a[n],E=u[w>>>24]^l[R>>16&255]^d[A>>8&255]^c[255&S]^a[n+1],b=u[R>>>24]^l[A>>16&255]^d[S>>8&255]^c[255&w]^a[n+2],P=u[A>>>24]^l[S>>16&255]^d[w>>8&255]^c[255&R]^a[n+3],S=m,w=E,R=b,A=P,n+=4;m=s[S>>>24]<<24^s[w>>16&255]<<16^s[R>>8&255]<<8^s[255&A]^a[n],E=s[w>>>24]<<24^s[R>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^a[n+1],b=s[R>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&w]^a[n+2],P=s[A>>>24]<<24^s[S>>16&255]<<16^s[w>>8&255]<<8^s[255&R]^a[n+3],n+=3,v[t]=this.networkToHostOrderSwap(m^h),v[t+1]=this.networkToHostOrderSwap(P^f),v[t+2]=this.networkToHostOrderSwap(b^_),v[t+3]=this.networkToHostOrderSwap(E^g),h=T,f=M,_=D,g=x,t+=4}return v.buffer}},{key:"destroy",value:function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0}}]),e}()},function(e,t,r){"use strict";function n(){this.buffer=null,this.bufferSize=0}t.__esModule=!0,t.MP3Parser=n;var o=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],i=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3];n.prototype.push=function(e){var t;if(this.bufferSize>0){var r=e.length+this.bufferSize;if(!this.buffer||this.buffer.length0&&n.set(this.buffer.subarray(0,this.bufferSize)),this.buffer=n}this.buffer.set(e,this.bufferSize),this.bufferSize=r,e=this.buffer,t=r}else t=e.length;for(var o,i=0;i0;)i+=o;var a=t-i;a>0&&(!this.buffer||this.buffer.lengthr)return-1;if(255===e[t]||224===(224&e[t+1])){if(t+24>r)return-1;var n=e[t+1]>>3&3,a=e[t+1]>>1&3,s=e[t+2]>>4&15,u=e[t+2]>>2&3,l=!!(2&e[t+2]);if(1!==n&&0!==s&&15!==s&&3!==u){var d=3===n?3-a:3===a?3:4,c=1e3*o[14*d+s-1],p=3===n?0:2===n?1:2,h=i[3*p+u],f=l?1:0,_=3===a?(3===n?12:6)*c/h+f<<2:(3===n?144:72)*c/h+f|0;return t+_>r?-1:(this.onFrame&&this.onFrame(e.subarray(t,t+_)),_)}}for(var g=t+2;g0&&this.onNoise&&this.onNoise(this.buffer.subarray(0,this.bufferSize)),this.buffer=null,this.bufferSize=0,this.onClose&&this.onClose()}},function(e,t,r){"use strict";t.__esModule=!0;var n,o,i=function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)};!function(e){var t;!function(e){function t(e){for(var t=new Uint8Array(4*e.length),r=0,n=0,o=e.length;n>>24&3,t[r++]=128|i>>>18&63,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|63&i):0!==(4294901760&i)?(t[r++]=240|i>>>18&7,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|63&i):0!==(4294965248&i)?(t[r++]=224|i>>>12&15,t[r++]=128|i>>>6&63,t[r++]=128|63&i):(t[r++]=192|i>>>6&31,t[r++]=128|63&i)}}return t.subarray(0,r)}function r(e){for(var t=0,r="";t>1|128;if((n&a)===o)break;o=o>>1|128,--i}while(i>=0);if(i<=0)throw new Error("Invalid UTF8 character");for(var s=n&(1<=i;--u){var l=e[t++];if(128!==(192&l))throw new Error("Invalid UTF8 character sequence");s=s<<6|63&l}r+=s>=65536?String.fromCharCode(s-65536>>10&1023|55296,1023&s|56320):String.fromCharCode(s)}}return r}e.utf8decode=t,e.utf8encode=r}(t=e.StringUtilities||(e.StringUtilities={}))}(o||(o={})),function(e){var t;!function(e){function t(e){for(var t=e.length>>1,r=new Uint8Array(t),n=0;n>4,c=o>>2&3,p=2&o?16:8,h=1&o?2:1;switch(r++,i){case d:var f=e[r++];n=f,t=1024;break;case l:var _=e[r+1]>>3&3,g=e[r+1]>>1&3;t=1===g?3===_?1152:576:3===g?384:1152}return{codecDescription:u[i],codecId:i,data:e.subarray(r),rate:s[c],size:p,channels:h,samples:t,packetType:n}}function n(e){var t=0,r=e[t]>>4,n=15&e[t];t++;var o={frameType:r,codecId:n,codecDescription:p[n]};switch(n){case f:var i=e[t++];o.packetType=i,o.compositionTime=(e[t]<<24|e[t+1]<<16|e[t+2]<<8)>>8,t+=3;break;case h:o.packetType=_.NALU,o.horizontalOffset=e[t]>>4&15,o.verticalOffset=15&e[t],o.compositionTime=0,t++}return o.data=e.subarray(t),o}function o(e){var t,r,n=[],o=-1,i=-1,a=+e.asGetPublicProperty("duration"),s=e.asGetPublicProperty("audiocodecid");switch(s){case l:case"mp3":t="mp3",r=l;break;case d:case"mp4a":t="mp4a",r=d;break;default:if(!isNaN(s))throw new Error("Unsupported audio codec: "+s);t=null,r=-1}var u,c,p=e.asGetPublicProperty("videocodecid");switch(p){case h:case"vp6f":u="vp6f",c=h;break;case f:case"avc1":u="avc1",c=f;break;default:if(!isNaN(p))throw new Error("Unsupported video codec: "+p);u=null,c=-1}var _=null===t?null:{codecDescription:t,codecId:r,language:"und",timescale:+e.asGetPublicProperty("audiosamplerate")||44100,samplerate:+e.asGetPublicProperty("audiosamplerate")||44100,channels:+e.asGetPublicProperty("audiochannels")||2,samplesize:16},g=null===u?null:{codecDescription:u,codecId:c,language:"und",timescale:6e4,framerate:+e.asGetPublicProperty("videoframerate")||+e.asGetPublicProperty("framerate"),width:+e.asGetPublicProperty("width"),height:+e.asGetPublicProperty("height")},y=e.asGetPublicProperty("trackinfo");if(y)for(var v=0;v=0&&t.push({tracks:[e.tracks[e.audioTrackId]],duration:e.duration,audioTrackId:0,videoTrackId:-1}),e.videoTrackId>=0&&t.push({tracks:[e.tracks[e.videoTrackId]],duration:e.duration,audioTrackId:-1,videoTrackId:0}),t}var a,s=[5500,11025,22050,44100],u=["PCM","ADPCM","MP3","PCM le","Nellymouser16","Nellymouser8","Nellymouser","G.711 A-law","G.711 mu-law",null,"AAC","Speex","MP3 8khz"],l=2,d=10;!function(e){e[e.HEADER=0]="HEADER",e[e.RAW=1]="RAW"}(a||(a={}));var c,p=[null,"JPEG","Sorenson","Screen","VP6","VP6 alpha","Screen2","AVC"],h=4,f=7;!function(e){e[e.KEY=1]="KEY",e[e.INNER=2]="INNER",e[e.DISPOSABLE=3]="DISPOSABLE",e[e.GENERATED=4]="GENERATED",e[e.INFO=5]="INFO"}(c||(c={}));var _;!function(e){e[e.HEADER=0]="HEADER",e[e.NALU=1]="NALU",e[e.END=2]="END"}(_||(_={}));var g,y=8,v=9,m=50,E=!0;!function(e){e[e.CAN_GENERATE_HEADER=0]="CAN_GENERATE_HEADER",e[e.NEED_HEADER_DATA=1]="NEED_HEADER_DATA",e[e.MAIN_PACKETS=2]="MAIN_PACKETS"}(g||(g={}));var b=function(){function o(e){var t=this;this.oncodecinfo=function(e){},this.ondata=function(e){throw new Error("MP4Mux.ondata is not set")},this.metadata=e,this.trackStates=this.metadata.tracks.map(function(e,r){var n={ -trackId:r+1,trackInfo:e,cachedDuration:0,samplesProcessed:0,initializationData:[]};return t.metadata.audioTrackId===r&&(t.audioTrackState=n),t.metadata.videoTrackId===r&&(t.videoTrackState=n),n},this),this._checkIfNeedHeaderData(),this.filePos=0,this.cachedPackets=[],this.chunkIndex=0}return o.prototype.pushPacket=function(e,t,o){switch(this.state===g.CAN_GENERATE_HEADER&&this._tryGenerateHeader(),e){case y:var i=this.audioTrackState,s=r(t);if(!i||i.trackInfo.codecId!==s.codecId)throw new Error("Unexpected audio packet codec: "+s.codecDescription);switch(s.codecId){default:throw new Error("Unsupported audio codec: "+s.codecDescription);case l:break;case d:if(s.packetType===a.HEADER)return void i.initializationData.push(s.data)}this.cachedPackets.push({packet:s,timestamp:o,trackId:i.trackId});break;case v:var u=this.videoTrackState,c=n(t);if(!u||u.trackInfo.codecId!==c.codecId)throw new Error("Unexpected video packet codec: "+c.codecDescription);switch(c.codecId){default:throw new Error("unsupported video codec: "+c.codecDescription);case h:break;case f:if(c.packetType===_.HEADER)return void u.initializationData.push(c.data)}this.cachedPackets.push({packet:c,timestamp:o,trackId:u.trackId});break;default:throw new Error("unknown packet type: "+e)}this.state===g.NEED_HEADER_DATA&&this._tryGenerateHeader(),this.cachedPackets.length>=m&&this.state===g.MAIN_PACKETS&&this._chunk()},o.prototype.flush=function(){this.cachedPackets.length>0&&this._chunk()},o.prototype._checkIfNeedHeaderData=function(){this.trackStates.some(function(e){return e.trackInfo.codecId===d||e.trackInfo.codecId===f})?this.state=g.NEED_HEADER_DATA:this.state=g.CAN_GENERATE_HEADER},o.prototype._tryGenerateHeader=function(){var r=this.trackStates.every(function(e){switch(e.trackInfo.codecId){case d:case f:return e.initializationData.length>0;default:return!0}});if(r){for(var n=["isom"],o=1,i=1,a=[],s=0;s>3;c.mimeTypeCodec="mp4a.40."+v;break;case l:u=new e.Iso.AudioSampleEntry(".mp3",o,p.channels,p.samplesize,p.samplerate),c.mimeTypeCodec="mp3";break;case f:var m=c.initializationData[0];u=new e.Iso.VideoSampleEntry("avc1",i,p.width,p.height),u.otherBoxes=[new e.Iso.RawTag("avcC",m)];var E=m[1]<<16|m[2]<<8|m[3];c.mimeTypeCodec="avc1."+(16777216|E).toString(16).substr(1),n.push("iso2","avc1","mp41");break;case h:u=new e.Iso.VideoSampleEntry("VP6F",i,p.width,p.height),u.otherBoxes=[new e.Iso.RawTag("glbl",t("00"))],c.mimeTypeCodec="avc1.42001E";break;default:throw new Error("not supported track type")}var b,P=e.Iso.TrackHeaderFlags.TRACK_ENABLED|e.Iso.TrackHeaderFlags.TRACK_IN_MOVIE;c===this.audioTrackState?b=new e.Iso.TrackBox(new e.Iso.TrackHeaderBox(P,c.trackId,-1,0,0,1,s),new e.Iso.MediaBox(new e.Iso.MediaHeaderBox(p.timescale,-1,p.language),new e.Iso.HandlerBox("soun","SoundHandler"),new e.Iso.MediaInformationBox(new e.Iso.SoundMediaHeaderBox,new e.Iso.DataInformationBox(new e.Iso.DataReferenceBox([new e.Iso.DataEntryUrlBox(e.Iso.SELF_CONTAINED_DATA_REFERENCE_FLAG)])),new e.Iso.SampleTableBox(new e.Iso.SampleDescriptionBox([u]),new e.Iso.RawTag("stts",t("0000000000000000")),new e.Iso.RawTag("stsc",t("0000000000000000")),new e.Iso.RawTag("stsz",t("000000000000000000000000")),new e.Iso.RawTag("stco",t("0000000000000000")))))):c===this.videoTrackState&&(b=new e.Iso.TrackBox(new e.Iso.TrackHeaderBox(P,c.trackId,-1,p.width,p.height,0,s),new e.Iso.MediaBox(new e.Iso.MediaHeaderBox(p.timescale,-1,p.language),new e.Iso.HandlerBox("vide","VideoHandler"),new e.Iso.MediaInformationBox(new e.Iso.VideoMediaHeaderBox,new e.Iso.DataInformationBox(new e.Iso.DataReferenceBox([new e.Iso.DataEntryUrlBox(e.Iso.SELF_CONTAINED_DATA_REFERENCE_FLAG)])),new e.Iso.SampleTableBox(new e.Iso.SampleDescriptionBox([u]),new e.Iso.RawTag("stts",t("0000000000000000")),new e.Iso.RawTag("stsc",t("0000000000000000")),new e.Iso.RawTag("stsz",t("000000000000000000000000")),new e.Iso.RawTag("stco",t("0000000000000000"))))))),a.push(b)}var S=new e.Iso.MovieExtendsBox(null,[new e.Iso.TrackExtendsBox(1,1,0,0,0),new e.Iso.TrackExtendsBox(2,1,0,0,0)],null),w=new e.Iso.BoxContainerBox("udat",[new e.Iso.MetaBox(new e.Iso.RawTag("hdlr",t("00000000000000006D6469726170706C000000000000000000")),[new e.Iso.RawTag("ilst",t("00000025A9746F6F0000001D6461746100000001000000004C61766635342E36332E313034"))])]),R=new e.Iso.MovieHeaderBox(1e3,0,this.trackStates.length+1),A=new e.Iso.MovieBox(R,a,S,w),T=new e.Iso.FileTypeBox("isom",512,n),M=T.layout(0),D=A.layout(M),x=new Uint8Array(M+D);T.write(x),A.write(x),this.oncodecinfo(this.trackStates.map(function(e){return e.mimeTypeCodec})),this.ondata(x),this.filePos+=x.length,this.state=g.MAIN_PACKETS}},o.prototype._chunk=function(){var t=this.cachedPackets;if(E&&this.videoTrackState){for(var r=t.length-1,n=this.videoTrackState.trackId;r>0&&(t[r].trackId!==n||t[r].packet.frameType!==c.KEY);)r--;r>0&&(t=t.slice(0,r))}if(0!==t.length){for(var o=[],i=0,a=[],s=[],u=0;u>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function n(e){return e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3)}function a(e){return(e-p)/1e3|0}function s(e){return 65536*e|0}function u(e){return 1073741824*e|0}function l(e){return 256*e|0}function d(e){return(31&e.charCodeAt(0))<<10|(31&e.charCodeAt(1))<<5|31&e.charCodeAt(2)}var c=o.StringUtilities.utf8decode,p=-20828448e5,h=[1,0,0,0,1,0,0,0,1],f=[0,0,0],_=function(){function e(e,t){this.boxtype=e,"uuid"===e&&(this.userType=t)}return e.prototype.layout=function(e){this.offset=e;var t=8;return this.userType&&(t+=16),this.size=t,t},e.prototype.write=function(e){return r(e,this.offset,this.size),r(e,this.offset+4,n(this.boxtype)),this.userType?(e.set(this.userType,this.offset+8),24):8},e.prototype.toUint8Array=function(){var e=this.layout(0),t=new Uint8Array(e);return this.write(t),t},e}();e.Box=_;var g=function(e){function t(t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var o=e.call(this,t)||this;return o.version=r,o.flags=n,o}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.version<<24|this.flags),n+4},t}(_);e.FullBox=g;var y=function(e){function t(t,r,n){var o=e.call(this,"ftype")||this;return o.majorBrand=t,o.minorVersion=r,o.compatibleBrands=n,o}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4*(2+this.compatibleBrands.length),this.size},t.prototype.write=function(t){var o=this,i=e.prototype.write.call(this,t);return r(t,this.offset+i,n(this.majorBrand)),r(t,this.offset+i+4,this.minorVersion),i+=8,this.compatibleBrands.forEach(function(e){r(t,o.offset+i,n(e)),i+=4},this),i},t}(_);e.FileTypeBox=y;var v=function(e){function t(t,r){var n=e.call(this,t)||this;return n.children=r,n}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return this.children.forEach(function(e){e&&(r+=e.layout(t+r))}),this.size=r},t.prototype.write=function(t){var r=e.prototype.write.call(this,t);return this.children.forEach(function(e){e&&(r+=e.write(t))}),r},t}(_);e.BoxContainerBox=v;var m=function(e){function r(r,n,o,i){var a=e.call(this,"moov",t([r],n,[o,i]))||this;return a.header=r,a.tracks=n,a.extendsBox=o,a.userData=i,a}return i(r,e),r}(v);e.MovieBox=m;var E=function(e){function t(t,r,n,o,i,a,s,u){void 0===o&&(o=1),void 0===i&&(i=1),void 0===a&&(a=h),void 0===s&&(s=p),void 0===u&&(u=p);var l=e.call(this,"mvhd",0,0)||this;return l.timescale=t,l.duration=r,l.nextTrackId=n,l.rate=o,l.volume=i,l.matrix=a,l.creationTime=s,l.modificationTime=u,l}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+16+4+2+2+8+36+24+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.timescale),r(t,this.offset+n+12,this.duration),n+=16,r(t,this.offset+n,s(this.rate)),r(t,this.offset+n+4,l(this.volume)<<16),r(t,this.offset+n+8,0),r(t,this.offset+n+12,0),n+=16,r(t,this.offset+n,s(this.matrix[0])),r(t,this.offset+n+4,s(this.matrix[1])),r(t,this.offset+n+8,s(this.matrix[2])),r(t,this.offset+n+12,s(this.matrix[3])),r(t,this.offset+n+16,s(this.matrix[4])),r(t,this.offset+n+20,s(this.matrix[5])),r(t,this.offset+n+24,u(this.matrix[6])),r(t,this.offset+n+28,u(this.matrix[7])),r(t,this.offset+n+32,u(this.matrix[8])),n+=36,r(t,this.offset+n,0),r(t,this.offset+n+4,0),r(t,this.offset+n+8,0),r(t,this.offset+n+12,0),r(t,this.offset+n+16,0),r(t,this.offset+n+20,0),n+=24,r(t,this.offset+n,this.nextTrackId),n+=4},t}(g);e.MovieHeaderBox=E;var b;!function(e){e[e.TRACK_ENABLED=1]="TRACK_ENABLED",e[e.TRACK_IN_MOVIE=2]="TRACK_IN_MOVIE",e[e.TRACK_IN_PREVIEW=4]="TRACK_IN_PREVIEW"}(b=e.TrackHeaderFlags||(e.TrackHeaderFlags={}));var P=function(e){function t(t,r,n,o,i,a,s,u,l,d,c){void 0===s&&(s=0),void 0===u&&(u=0),void 0===l&&(l=h),void 0===d&&(d=p),void 0===c&&(c=p);var f=e.call(this,"tkhd",0,t)||this;return f.trackId=r,f.duration=n,f.width=o,f.height=i,f.volume=a,f.alternateGroup=s,f.layer=u,f.matrix=l,f.creationTime=d,f.modificationTime=c,f}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+20+8+6+2+36+8,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.trackId),r(t,this.offset+n+12,0),r(t,this.offset+n+16,this.duration),n+=20,r(t,this.offset+n,0),r(t,this.offset+n+4,0),r(t,this.offset+n+8,this.layer<<16|this.alternateGroup),r(t,this.offset+n+12,l(this.volume)<<16),n+=16,r(t,this.offset+n,s(this.matrix[0])),r(t,this.offset+n+4,s(this.matrix[1])),r(t,this.offset+n+8,s(this.matrix[2])),r(t,this.offset+n+12,s(this.matrix[3])),r(t,this.offset+n+16,s(this.matrix[4])),r(t,this.offset+n+20,s(this.matrix[5])),r(t,this.offset+n+24,u(this.matrix[6])),r(t,this.offset+n+28,u(this.matrix[7])),r(t,this.offset+n+32,u(this.matrix[8])),n+=36,r(t,this.offset+n,s(this.width)),r(t,this.offset+n+4,s(this.height)),n+=8},t}(g);e.TrackHeaderBox=P;var S=function(e){function t(t,r,n,o,i){void 0===n&&(n="unk"),void 0===o&&(o=p),void 0===i&&(i=p);var a=e.call(this,"mdhd",0,0)||this;return a.timescale=t,a.duration=r,a.language=n,a.creationTime=o,a.modificationTime=i,a}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+16+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.timescale),r(t,this.offset+n+12,this.duration),r(t,this.offset+n+16,d(this.language)<<16),n+20},t}(g);e.MediaHeaderBox=S;var w=function(e){function t(t,r){var n=e.call(this,"hdlr",0,0)||this;return n.handlerType=t,n.name=r,n._encodedName=c(n.name),n}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+8+12+(this._encodedName.length+1),this.size},t.prototype.write=function(t){var o=e.prototype.write.call(this,t);return r(t,this.offset+o,0),r(t,this.offset+o+4,n(this.handlerType)),r(t,this.offset+o+8,0),r(t,this.offset+o+12,0),r(t,this.offset+o+16,0),o+=20,t.set(this._encodedName,this.offset+o),t[this.offset+o+this._encodedName.length]=0,o+=this._encodedName.length+1},t}(g);e.HandlerBox=w;var R=function(e){function t(t){void 0===t&&(t=0);var r=e.call(this,"smhd",0,0)||this;return r.balance=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,l(this.balance)<<16),n+4},t}(g);e.SoundMediaHeaderBox=R;var A=function(e){function t(t,r){void 0===t&&(t=0),void 0===r&&(r=f);var n=e.call(this,"vmhd",0,0)||this;return n.graphicsMode=t,n.opColor=r,n}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+8,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.graphicsMode<<16|this.opColor[0]),r(t,this.offset+n+4,this.opColor[1]<<16|this.opColor[2]),n+8},t}(g);e.VideoMediaHeaderBox=A,e.SELF_CONTAINED_DATA_REFERENCE_FLAG=1;var T=function(t){function r(r,n){void 0===n&&(n=null);var o=t.call(this,"url ",0,r)||this;return o.location=n,r&e.SELF_CONTAINED_DATA_REFERENCE_FLAG||(o._encodedLocation=c(n)),o}return i(r,t),r.prototype.layout=function(e){var r=t.prototype.layout.call(this,e);return this._encodedLocation&&(r+=this._encodedLocation.length+1),this.size=r},r.prototype.write=function(e){var r=t.prototype.write.call(this,e);return this._encodedLocation&&(e.set(this._encodedLocation,this.offset+r),e[this.offset+r+this._encodedLocation.length]=0,r+=this._encodedLocation.length),r},r}(g);e.DataEntryUrlBox=T;var M=function(e){function t(t){var r=e.call(this,"dref",0,0)||this;return r.entries=t,r}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4;return this.entries.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.entries.length),this.entries.forEach(function(e){n+=e.write(t)}),n},t}(g);e.DataReferenceBox=M;var D=function(e){function t(t){var r=e.call(this,"dinf",[t])||this;return r.dataReference=t,r}return i(t,e),t}(v);e.DataInformationBox=D;var x=function(e){function t(t){var r=e.call(this,"stsd",0,0)||this;return r.entries=t,r}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return r+=4,this.entries.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.entries.length),n+=4,this.entries.forEach(function(e){n+=e.write(t)}),n},t}(g);e.SampleDescriptionBox=x;var k=function(e){function t(t,r,n,o,i){var a=e.call(this,"stbl",[t,r,n,o,i])||this;return a.sampleDescriptions=t,a.timeToSample=r,a.sampleToChunk=n,a.sampleSizes=o,a.chunkOffset=i,a}return i(t,e),t}(v);e.SampleTableBox=k;var O=function(e){function t(t,r,n){var o=e.call(this,"minf",[t,r,n])||this;return o.header=t,o.info=r,o.sampleTable=n,o}return i(t,e),t}(v);e.MediaInformationBox=O;var C=function(e){function t(t,r,n){var o=e.call(this,"mdia",[t,r,n])||this;return o.header=t,o.handler=r,o.info=n,o}return i(t,e),t}(v);e.MediaBox=C;var I=function(e){function t(t,r){var n=e.call(this,"trak",[t,r])||this;return n.header=t,n.media=r,n}return i(t,e),t}(v);e.TrackBox=I;var L=function(e){function t(t,r,n,o,i){var a=e.call(this,"trex",0,0)||this;return a.trackId=t,a.defaultSampleDescriptionIndex=r,a.defaultSampleDuration=n,a.defaultSampleSize=o,a.defaultSampleFlags=i,a}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+20,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.trackId),r(t,this.offset+n+4,this.defaultSampleDescriptionIndex),r(t,this.offset+n+8,this.defaultSampleDuration),r(t,this.offset+n+12,this.defaultSampleSize),r(t,this.offset+n+16,this.defaultSampleFlags),n+20},t}(g);e.TrackExtendsBox=L;var N=function(e){function r(r,n,o){var i=e.call(this,"mvex",t([r],n,[o]))||this;return i.header=r,i.tracDefaults=n,i.levels=o,i}return i(r,e),r}(v);e.MovieExtendsBox=N;var F=function(e){function t(t,r){var n=e.call(this,"meta",0,0)||this;return n.handler=t,n.otherBoxes=r,n}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return r+=this.handler.layout(t+r),this.otherBoxes.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var r=e.prototype.write.call(this,t);return r+=this.handler.write(t),this.otherBoxes.forEach(function(e){r+=e.write(t)}),r},t}(g);e.MetaBox=F;var U=function(e){function t(t){var r=e.call(this,"mfhd",0,0)||this;return r.sequenceNumber=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.sequenceNumber),n+4},t}(g);e.MovieFragmentHeaderBox=U;var j;!function(e){e[e.BASE_DATA_OFFSET_PRESENT=1]="BASE_DATA_OFFSET_PRESENT",e[e.SAMPLE_DESCRIPTION_INDEX_PRESENT=2]="SAMPLE_DESCRIPTION_INDEX_PRESENT",e[e.DEFAULT_SAMPLE_DURATION_PRESENT=8]="DEFAULT_SAMPLE_DURATION_PRESENT",e[e.DEFAULT_SAMPLE_SIZE_PRESENT=16]="DEFAULT_SAMPLE_SIZE_PRESENT",e[e.DEFAULT_SAMPLE_FLAGS_PRESENT=32]="DEFAULT_SAMPLE_FLAGS_PRESENT"}(j=e.TrackFragmentFlags||(e.TrackFragmentFlags={}));var B=function(e){function t(t,r,n,o,i,a,s){var u=e.call(this,"tfhd",0,t)||this;return u.trackId=r,u.baseDataOffset=n,u.sampleDescriptionIndex=o,u.defaultSampleDuration=i,u.defaultSampleSize=a,u.defaultSampleFlags=s,u}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4,n=this.flags;return n&j.BASE_DATA_OFFSET_PRESENT&&(r+=8),n&j.SAMPLE_DESCRIPTION_INDEX_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_DURATION_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_SIZE_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_FLAGS_PRESENT&&(r+=4),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t),o=this.flags;return r(t,this.offset+n,this.trackId),n+=4,o&j.BASE_DATA_OFFSET_PRESENT&&(r(t,this.offset+n,0),r(t,this.offset+n+4,this.baseDataOffset),n+=8),o&j.SAMPLE_DESCRIPTION_INDEX_PRESENT&&(r(t,this.offset+n,this.sampleDescriptionIndex),n+=4),o&j.DEFAULT_SAMPLE_DURATION_PRESENT&&(r(t,this.offset+n,this.defaultSampleDuration),n+=4),o&j.DEFAULT_SAMPLE_SIZE_PRESENT&&(r(t,this.offset+n,this.defaultSampleSize),n+=4),o&j.DEFAULT_SAMPLE_FLAGS_PRESENT&&(r(t,this.offset+n,this.defaultSampleFlags),n+=4),n},t}(g);e.TrackFragmentHeaderBox=B;var q=function(e){function t(t){var r=e.call(this,"tfdt",0,0)||this;return r.baseMediaDecodeTime=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.baseMediaDecodeTime),n+4},t}(g);e.TrackFragmentBaseMediaDecodeTimeBox=q;var H=function(e){function t(t,r,n){var o=e.call(this,"traf",[t,r,n])||this;return o.header=t,o.decodeTime=r,o.run=n,o}return i(t,e),t}(v);e.TrackFragmentBox=H;var z;!function(e){e[e.IS_LEADING_MASK=201326592]="IS_LEADING_MASK",e[e.SAMPLE_DEPENDS_ON_MASK=50331648]="SAMPLE_DEPENDS_ON_MASK",e[e.SAMPLE_DEPENDS_ON_OTHER=16777216]="SAMPLE_DEPENDS_ON_OTHER",e[e.SAMPLE_DEPENDS_ON_NO_OTHERS=33554432]="SAMPLE_DEPENDS_ON_NO_OTHERS",e[e.SAMPLE_IS_DEPENDED_ON_MASK=12582912]="SAMPLE_IS_DEPENDED_ON_MASK",e[e.SAMPLE_HAS_REDUNDANCY_MASK=3145728]="SAMPLE_HAS_REDUNDANCY_MASK",e[e.SAMPLE_PADDING_VALUE_MASK=917504]="SAMPLE_PADDING_VALUE_MASK",e[e.SAMPLE_IS_NOT_SYNC=65536]="SAMPLE_IS_NOT_SYNC",e[e.SAMPLE_DEGRADATION_PRIORITY_MASK=65535]="SAMPLE_DEGRADATION_PRIORITY_MASK"}(z=e.SampleFlags||(e.SampleFlags={}));var G;!function(e){e[e.DATA_OFFSET_PRESENT=1]="DATA_OFFSET_PRESENT",e[e.FIRST_SAMPLE_FLAGS_PRESENT=4]="FIRST_SAMPLE_FLAGS_PRESENT",e[e.SAMPLE_DURATION_PRESENT=256]="SAMPLE_DURATION_PRESENT",e[e.SAMPLE_SIZE_PRESENT=512]="SAMPLE_SIZE_PRESENT",e[e.SAMPLE_FLAGS_PRESENT=1024]="SAMPLE_FLAGS_PRESENT",e[e.SAMPLE_COMPOSITION_TIME_OFFSET=2048]="SAMPLE_COMPOSITION_TIME_OFFSET"}(G=e.TrackRunFlags||(e.TrackRunFlags={}));var K=function(e){function t(t,r,n,o){var i=e.call(this,"trun",1,t)||this;return i.samples=r,i.dataOffset=n,i.firstSampleFlags=o,i}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4,n=this.samples.length,o=this.flags;return o&G.DATA_OFFSET_PRESENT&&(r+=4),o&G.FIRST_SAMPLE_FLAGS_PRESENT&&(r+=4),o&G.SAMPLE_DURATION_PRESENT&&(r+=4*n),o&G.SAMPLE_SIZE_PRESENT&&(r+=4*n),o&G.SAMPLE_FLAGS_PRESENT&&(r+=4*n),o&G.SAMPLE_COMPOSITION_TIME_OFFSET&&(r+=4*n),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t),o=this.samples.length,i=this.flags;r(t,this.offset+n,o),n+=4,i&G.DATA_OFFSET_PRESENT&&(r(t,this.offset+n,this.dataOffset),n+=4),i&G.FIRST_SAMPLE_FLAGS_PRESENT&&(r(t,this.offset+n,this.firstSampleFlags),n+=4);for(var a=0;a31)throw new Error("invalid compressor name");return p}return i(n,t),n.prototype.layout=function(e){var r=t.prototype.layout.call(this,e)+16+12+4+2+32+2+2;return this.otherBoxes&&this.otherBoxes.forEach(function(t){r+=t.layout(e+r)}),this.size=r},n.prototype.write=function(e){var n=t.prototype.write.call(this,e);r(e,this.offset+n,0),r(e,this.offset+n+4,0),r(e,this.offset+n+8,0),r(e,this.offset+n+12,0),n+=16,r(e,this.offset+n,this.width<<16|this.height),r(e,this.offset+n+4,s(this.horizResolution)),r(e,this.offset+n+8,s(this.vertResolution)),n+=12,r(e,this.offset+n,0),r(e,this.offset+n+4,this.frameCount<<16),n+=6,e[this.offset+n]=this.compressorName.length;for(var o=0;o<31;o++)e[this.offset+n+o+1]=o 0.");this._ensureNotDead(),this._ensureInitialized(),this._logger.debug("remove() called.",e);var t=i();return this._pendingActions.push({type:"remove",range:e,deferred:t}),this._performNextAction(),t.promise},e.prototype.kill=function(){if(!this._dead){if(this._logger.debug("kill() called."),this._dead=!0,this._sourceBuffer){this._sourceBuffer.removeEventListener("updateend",this._onSourceBufferUpdateEnd,!1),this._sourceBuffer.removeEventListener("error",this._onSourceBufferError,!1);try{this._mediaSource.removeSourceBuffer(this._sourceBuffer); -}catch(e){this._logger.error("Error from removeSourceBuffer()",e)}}this._mediaSource.removeEventListener("sourceopen",this._onMediaSourceInit,!1),this._mediaSource.removeEventListener("error",this._onMediaSourceError,!1),URL.revokeObjectURL(this._url);var e=this._currentAction?[this._currentAction]:[];e=e.concat(this._pendingActions),e.forEach(function(e){e.deferred.reject(t.killedError)}),this._whenIdleDeferred||(this._whenIdleDeferred=i()),this._whenIdleDeferred.reject(t.killedError),this._initialized||this._initializeDeferred.reject(this._error||t.killedError),this._pendingActions.length=0,this._logger.debug("Killed.")}},e.prototype._ensureInitialized=function(){if(!this._initialized)throw new Error("Not initialized yet.")},e.prototype._ensureNotDead=function(){if(this._dead)throw new Error("MSE is dead.")},e.prototype._onMediaSourceInit=function(){this._logger.debug("MSE initialized."),this._mediaSource.removeEventListener("sourceopen",this._onMediaSourceInit,!1);try{this._logger.debug("Creating source buffer.",this._type),this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.mode=this._useSegmentsMode?"segments":"sequence",this._logger.debug("Using append mode: "+this._sourceBuffer.mode),this._sourceBuffer.addEventListener("updateend",this._onSourceBufferUpdateEnd,!1),this._sourceBuffer.addEventListener("error",this._onSourceBufferError,!1)}catch(e){this._handleError(e)}this._initializeDeferred.resolve(void 0),this._whenIdleDeferred.resolve(void 0),this._initialized=!0,this._performNextAction()},e.prototype._onMediaSourceError=function(e){this._handleError(e)},e.prototype._handleError=function(e){this._ensureNotDead(),this._logger.error("Error occurred.",e),this._error=e||new Error("Unknown error."),this.kill()},e.prototype._onSourceBufferUpdateEnd=function(){var e=this._currentAction;return this._logger.debug("Update ended.",this.getBuffered()),e?"append"===e.type&&u(this.getBuffered()).end<=this._bufferEnd?void this._handleError(new Error("Buffer end point did not increase after an append.")):(this._currentAction=null,e.deferred.resolve(void 0),void this._performNextAction()):void this._handleError(new Error("No action in progress."))},e.prototype._onSourceBufferError=function(e){this._handleError(e)},e.prototype._performNextAction=function(){var e=this._whenIdleDeferred;if(!this._currentAction&&this._sourceBuffer){var t=this._pendingActions.shift();if(!t)return this._logger.debug("No more actions."),void(e&&(this._whenIdleDeferred=null,e.resolve(void 0)));switch(e||(this._whenIdleDeferred=i()),this._currentAction=t,this._logger.debug("Performing next action..."),t.type){case"append":var r=u(this.getBuffered());try{if("segments"===this._sourceBuffer.mode){var n=r.end/1e3;this._logger.debug("Setting timestampOffset because detected safari.",n),this._sourceBuffer.timestampOffset=n}this._logger.debug("Calling appendBuffer()."),this._bufferEnd=r.end,this._sourceBuffer.appendBuffer(t.data)}catch(e){this._handleError(e)}break;case"remove":try{var o=t.range;this._logger.debug("Calling remove().",o.start,o.end),this._sourceBuffer.remove(o.start/1e3,o.end/1e3)}catch(e){this._handleError(e)}}}},e}();t.MSE=_},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(0),i=o.helpers.find,a=o.eventDispatcher.EventDispatcher,s=o.helpers.abortableJob.abortedError,u=o.helpers.abortableJob.AbortableJob,l=o.logger.prefixLogger,d=o.logger.noOpLogger;!function(e){e[e.RETRIEVING_SEGMENT=0]="RETRIEVING_SEGMENT",e[e.RETRIEVED_SEGMENT=1]="RETRIEVED_SEGMENT",e[e.RETRIEVING_DATA=2]="RETRIEVING_DATA",e[e.COMPLETE=3]="COMPLETE"}(n||(n={}));var c=function(){function e(e){this._onSegmentRequestQueued=new a,this._onSegmentRequestStart=new a,this._onSegmentRetrieved=new a,this._onSegmentRequestFailed=new a,this._onSegmentDecryptionStart=new a,this._onSegmentDecryptionEnd=new a,this._onSegmentTransmuxStart=new a,this._onSegmentTransmuxEnd=new a,this._onSegmentReady=new a,this._onError=new a,this._segments=[],this._retrievingSegment=null,this._timerId=null,this._dead=!1;var t=e.playlist,r=e.getPosition,n=e.maxBufferLength,o=e.cacheSize,i=e.transmuxer,s=e.logger,u=void 0===s?d:s;if(this._logger=l(u,"PlaylistSegmentRetriever"),t&&!t.hasRetrieveCompleted())throw new Error("Playlist retrieve has not completed.");if(n<0)throw new Error("Max buffer length must be > 0.");if(o<0)throw new Error("Cache size must be > 0.");this.onSegmentRequestQueued=this._onSegmentRequestQueued.getHandle(),this.onSegmentRequestStart=this._onSegmentRequestStart.getHandle(),this.onSegmentRetrieved=this._onSegmentRetrieved.getHandle(),this.onSegmentRequestFailed=this._onSegmentRequestFailed.getHandle(),this.onSegmentDecryptionStart=this._onSegmentDecryptionStart.getHandle(),this.onSegmentDecryptionEnd=this._onSegmentDecryptionEnd.getHandle(),this.onSegmentTransmuxStart=this._onSegmentTransmuxStart.getHandle(),this.onSegmentTransmuxEnd=this._onSegmentTransmuxEnd.getHandle(),this.onSegmentReady=this._onSegmentReady.getHandle(),this.onError=this._onError.getHandle(),this._playlist=t,this._transmuxer=i,this._getPosition=r,this._maxBufferLength=n,this._cacheSize=o,this.update()}return e.prototype.updateMaxBufferLength=function(e){if(this._ensureNotDead(),e<0)throw new Error("Max buffer length must be > 0.");this._logger.debug("updateMaxBufferLength() called.",e),this._maxBufferLength=e,this.update()},e.prototype.updateCacheSize=function(e){if(this._ensureNotDead(),e<0)throw new Error("Cache size must be > 0.");this._logger.debug("updateCacheSize() called.",e),this._cacheSize=e,this.update()},e.prototype.getCacheSize=function(){return this._cacheSize},e.prototype.getCacheUsage=function(){return this._segments.reduce(function(e,t){return t.state===n.COMPLETE?e+t.data.byteLength:e},0)},e.prototype.switchPlaylist=function(e){if(this._ensureNotDead(),e&&!e.hasRetrieveCompleted())throw new Error("Playlist retrieve has not completed.");this._logger.debug("switchPlaylist() called."),this._abortCurrentRetrieve(),this._playlist=e,this._segments=this._segments.filter(function(e){return e.state===n.COMPLETE}),this.update()},e.prototype.getSegmentsWithData=function(){return this._ensureNotDead(),this._segments.filter(function(e){return e.state===n.COMPLETE}).map(function(e){if(e.state!==n.COMPLETE)throw new Error("Unexpected error.");var t=e.segment,r=e.initData,o=e.data,i=e.eventRepresentation;return{segment:t,initData:r,data:o,eventRepresentation:i}})},e.prototype.update=function(){this._ensureNotDead(),this._timerId&&(this._logger.debug("Cancelling update timer."),window.clearTimeout(this._timerId),this._timerId=null);var e=this._getPosition(),t=e;this._segments.some(function(r){if(r.state!==n.COMPLETE)return!1;var o=r.segment.getTimeRange();return!(o.end=t&&!o.containsTime(t)||(t=o.end,!1))});var r=i(this._segments,function(e){if(e.state===n.RETRIEVED_SEGMENT||e.state===n.RETRIEVING_DATA){var r=e.segment.getTimeRange();return r.containsTime(t)}return!1});return t>=e+this._maxBufferLength?(this._abortCurrentRetrieve(),this._garbageCollect(e),void this._scheduleNextUpdate()):(r?this._retrieveSegmentData(r):this._retrieveSegment(t),void this._garbageCollect(e))},e.prototype.kill=function(){this._dead||(this._logger.debug("kill() called."),this._abortCurrentRetrieve(),this._dead=!0,this._timerId&&(this._logger.debug("Cancelling update timer."),window.clearTimeout(this._timerId)),this._logger.debug("Killed."))},e.prototype._retrieveSegmentData=function(e){var t=this;if(e.state!==n.RETRIEVED_SEGMENT&&e.state!==n.RETRIEVING_DATA)throw new Error("Segment in incorrect state for data to be retrieved.");var r=this._retrievingSegment;if(!r||r.state!==n.RETRIEVING_DATA||e.segment!==r.segment){this._abortCurrentRetrieve();var o=new u(function(){var r=!1,n=e.segment.retrieveData();t._logger.debug("Retrieving segment data...");var o=n.whenComplete().then(function(e){var n=e.data,o=e.eventRepresentation;if(r)throw s;return t._logger.debug("Retrieved segment data."),t._onSegmentTransmuxStart.dispatch({segment:o}),t._transmuxer.transmux(n).then(function(e){var n=e.data,i=e.initData;if(r)throw s;return t._onSegmentTransmuxEnd.dispatch({segment:o}),t._logger.debug("Transmuxed segment."),{data:n,initData:i,eventRepresentation:o}})});return{result:o,abort:function(){r=!0,n.abort()}}}).run();o.onCompletion(function(r){var o=r.initData,i=r.data,a=r.eventRepresentation;t._retrievingSegment=null,t._segments.splice(t._segments.indexOf(e),1,{state:n.COMPLETE,initData:o,data:i,eventRepresentation:a,segment:e.segment}),t._logger.debug("Segment retrieve completed.",a),t.update(),t._onSegmentReady.dispatch({segment:e.segment,initData:o,data:i,eventRepresentation:a})}),o.onError(function(e){e!==s&&(t._logger.error("Error retrieving segment data.",e),t._scheduleNextUpdate(),t._onError.dispatch(e))}),this._retrievingSegment={state:n.RETRIEVING_DATA,dataRetrieveJob:o,segment:e.segment}}},e.prototype._retrieveSegment=function(e){var t=this,r=this._retrievingSegment,o=this._playlist,i=o?o.getSegmentIndexContainingTime(e):null;if(!r||r.state!==n.RETRIEVING_SEGMENT||r.segmentIndex!==i)if(this._abortCurrentRetrieve(),null!==i&&o){var a=o.getSegment(i);this._logger.debug("Retrieving segment.",i),a.onCompletion(function(e){t._logger.debug("Retrieved segment.",i),e.onSegmentRequestQueued.subscribe(t._onSegmentRequestQueued.dispatch),e.onSegmentRequestStart.subscribe(t._onSegmentRequestStart.dispatch),e.onSegmentRetrieved.subscribe(t._onSegmentRetrieved.dispatch),e.onSegmentRequestFailed.subscribe(t._onSegmentRequestFailed.dispatch),e.onSegmentDecryptionStart.subscribe(t._onSegmentDecryptionStart.dispatch),e.onSegmentDecryptionEnd.subscribe(t._onSegmentDecryptionEnd.dispatch),t._segments.splice(t._segments.indexOf(u),1);var r=e.getTimeRange(),o=t._segments.length;t._segments.some(function(e,t){return e.state!==n.RETRIEVING_SEGMENT&&(e.segment.getTimeRange().start>r.start&&(o=t,!0))}),t._segments.splice(o,0,{state:n.RETRIEVED_SEGMENT,segment:e}),t._retrievingSegment=null,t.update()}),a.onError(function(e){e!==s&&(t._logger.error("Error retrieving segment.",e),t._scheduleNextUpdate(),t._onError.dispatch(e))});var u={state:n.RETRIEVING_SEGMENT,segmentIndex:i,segmentRetrieveJob:a};this._segments.push(u),this._retrievingSegment=u}else this._scheduleNextUpdate()},e.prototype._abortCurrentRetrieve=function(){var e=this._retrievingSegment;e&&(e.state===n.RETRIEVING_SEGMENT?(this._logger.debug("Aborting segment retrieve job."),e.segmentRetrieveJob.abort()):e.state===n.RETRIEVING_DATA&&(this._logger.debug("Aborting segment data retrieve job."),e.dataRetrieveJob.abort()),this._retrievingSegment=null)},e.prototype._garbageCollect=function(e){var t=this._segments,r=this._cacheSize,o=this.getCacheUsage();if(!(o<=r)){var i=e+this._maxBufferLength;t.filter(function(t){if(t.state!==n.COMPLETE)return!1;var r=t.segment.getTimeRange();return r.end<=e||r.start>i}).map(function(t){if(t.state!==n.COMPLETE)throw new Error("Unexpected error.");var r=t.segment.getTimeRange(),o=Math.abs(e-r.start);return{segment:t,distance:o,size:t.data.byteLength}}).sort(function(e,t){return t.distance-e.distance}).some(function(e){return o<=r||(t.splice(t.indexOf(e.segment),1),o-=e.size,!1)})}},e.prototype._scheduleNextUpdate=function(){var e=this;this._timerId||(this._timerId=window.setTimeout(function(){e._timerId=null,e.update()},1e3))},e.prototype._ensureNotDead=function(){if(this._dead)throw new Error("Playlist segment retriever has been killed.")},e}();t.PlaylistSegmentRetriever=c},function(e,t,r){"use strict";function n(e){return 0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1?e.slice(1,-1):e}function o(e){0===e.indexOf("0x")&&(e=e.substr(2));var t=new Uint16Array(8);if(e.length%4!==0)throw new c.PlaylistParseError("Failed to parse IV (length is not multiple of 4).");for(var r=0;r>8*(15-r)&255;return t}function a(e){return!(e>=400&&e<500)}Object.defineProperty(t,"__esModule",{value:!0});var s,u=r(0),l=r(31),d=r(3),c=r(12),p=r(13),h=r(26),f=r(25),_=u.helpers.abortableJob.AbortableJob,g=u.helpers.deferred.buildDeferred,y=u.helpers.cache.buildCache,v=u.helpers.retry,m=v.retry,E=v.buildExponentialDelayCalculator,b=u.helpers.Promise,P=u.helpers.find,S=u.helpers.url,w=u.eventDispatcher.EventDispatcher,R=u.logger.prefixLogger,A=u.logger.noOpLogger,T=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT(INF): *(\d+(?:\.\d+)?)(?:,(.*))?)|(?:(?!#)()(\S.+))|(?:#EXT-X-(BYTERANGE): *(\d+(?:@\d+(?:\.\d+)?)?)|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.+))|(?:#EXT-X-(VERSION):(\d+))|(?:(#)(.*):(.*))|(?:(#)(.*)))(?:.*)\r?\n?/g,M=/(.+?)=(.+?)(?:,|$)/g,D=/^\d*(\.\d+)?$/;!function(e){e[e.NONE=0]="NONE",e[e.AES_128=1]="AES_128",e[e.SAMPLE_AES=2]="SAMPLE_AES"}(s||(s={}));var x;!function(e){e[e.VOD=0]="VOD",e[e.LIVE=1]="LIVE",e[e.EVENT=2]="EVENT"}(x=t.PlaylistType||(t.PlaylistType={}));var k=function(){function e(e){var t=e.url,r=e.playlistLoader,n=e.segmentLoader,o=e.keyLoader,i=void 0===o?null:o,s=e.segmentFormat,u=e.logger,l=void 0===u?A:u,c=e.delayCalculator,p=void 0===c?E():c,f=e.keyDelayCalculator,v=void 0===f?E():f,P=e.segmentDelayCalculator,S=e.isPlaylistResponseCodeAcceptable,T=void 0===S?function(e){return 200===e}:S,M=e.isPlaylistResponseCodeRetryable,D=void 0===M?a:M,x=e.isSegmentResponseCodeAcceptable,k=void 0===x?function(e){return 200===e}:x,O=e.isSegmentResponseCodeRetryable,C=void 0===O?a:O,I=e.isKeyResponseCodeAcceptable,L=void 0===I?function(e){return 200===e}:I,N=e.isKeyResponseCodeRetryable,F=void 0===N?a:N,U=this;this._keyRetrievalJobsCache=y(),this._data=null,this._playlistEventRepresentation=null,this._onPlaylistRequestQueued=new w,this._onPlaylistRequestStart=new w,this._onPlaylistRetrieved=new w,this._onPlaylistRequestFailed=new w,this._onPlaylistParseStart=new w,this._onPlaylistParseEnd=new w,this._onKeyRequestQueued=new w,this._onKeyRequestStart=new w,this._onKeyRetrieved=new w,this._onKeyRequestFailed=new w,this._logger=R(l,"Playlist"),this.onPlaylistRequestQueued=this._onPlaylistRequestQueued.getHandle(),this.onPlaylistRequestStart=this._onPlaylistRequestStart.getHandle(),this.onPlaylistRetrieved=this._onPlaylistRetrieved.getHandle(),this.onPlaylistRequestFailed=this._onPlaylistRequestFailed.getHandle(),this.onPlaylistParseStart=this._onPlaylistParseStart.getHandle(),this.onPlaylistParseEnd=this._onPlaylistParseEnd.getHandle(),this.onKeyRequestQueued=this._onKeyRequestQueued.getHandle(),this.onKeyRequestStart=this._onKeyRequestStart.getHandle(),this.onKeyRetrieved=this._onKeyRetrieved.getHandle(),this.onKeyRequestFailed=this._onKeyRequestFailed.getHandle(),this._url=t,this._playlistLoader=r,this._segmentLoader=n,this._keyLoader=i,this._segmentFormat=s,this._delayCalculator=p,this._keyDelayCalculator=v,this._isPlaylistResponseCodeAcceptable=T,this._isPlaylistResponseCodeRetryable=D,this._isSegmentResponseCodeAcceptable=k,this._isSegmentResponseCodeRetryable=C,this._isKeyResponseCodeAcceptable=L,this._isKeyResponseCodeRetryable=F,this._segmentDelayCalculator=P,this._downloadAbortableJob=new _(function(){var e=m(function(){return new _(function(){var e=new h.Playlist(t);U._onPlaylistRequestQueued.dispatch({playlist:e});var r=U._playlistLoader.request({url:t});r.whenRequestStarted.then(function(){U._onPlaylistRequestStart.dispatch({playlist:e})}),U._logger.debug("Requesting playlist.",t);var n=r.getResponse().then(function(r){if(!r)return U._logger.warn("Playlist request timed out.",t),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:null}),{success:!1};var n=r.statusCode;if(U._isPlaylistResponseCodeAcceptable(n)){var o=r.data;return o?(U._logger.debug("Got playlist response.",t,n),U._onPlaylistRetrieved.dispatch({playlist:e,statusCode:n}),{success:!0,result:{playlistContent:o,eventRepresentation:e}}):(U._logger.warn("Playlist response contained no data.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),{success:!1})}return U._isPlaylistResponseCodeRetryable(n)?(U._logger.debug("Playlist response code was not acceptable. Will retry.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),{success:!1}):(U._logger.debug("Playlist response code was not acceptable.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),b.reject(new d.UnacceptableResponseStatusCodeError(n)))});return{result:n,abort:function(){U._logger.debug("Aborting playlist request.",t),r.abort(),U._onPlaylistRequestFailed.dispatch({playlist:e,aborted:!0})}}})},p);return{result:e.whenComplete(),abort:function(){return e.abort()}}}),this._retrieveJob=new _(function(){var e=U._downloadAbortableJob.run(),t=g();return e.onCompletion(function(e){var r=e.playlistContent,n=e.eventRepresentation;U._onPlaylistParseStart.dispatch({playlist:n});try{U._data=U._parsePlaylist(r)}catch(e){return U._logger.error("Error when parsing playlist.",e,r),void t.reject(e)}U._playlistEventRepresentation=n,U._onPlaylistParseEnd.dispatch({playlist:n}),t.resolve(void 0)}),e.onError(t.reject),{result:t.promise,abort:function(){return e.abort()}}})}return e.prototype.retrieve=function(){return this._retrieveJob.run()},e.prototype.hasRetrieveCompleted=function(){return!!this._data},e.prototype.getStartingSequenceNumber=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.mediaSequence},e.prototype.getType=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.type},e.prototype.getTargetDuration=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.targetDuration},e.prototype.getTotalDuration=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.totalDuration},e.prototype.hasEnded=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.ended},e.prototype.getSegmentCount=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.segments.length},e.prototype.getSegment=function(e){return this.getSegments(e,e+1)[0]},e.prototype.getSegments=function(e,t){var r=this,n=this._data;if(!n)throw new Error("Not loaded yet.");var o=n.mediaSequence;void 0===e&&(e=o);var i=n.segments.length;if(void 0===t&&(t=o+i),e= the first segment index.");if(t= the first segment index.");if(t>o+i)throw new Error("End index cannot be > than the index of the last segment.");if(t= start index.");return n.segments.slice(e-o,t-o).map(function(t,n){var o=new _(function(){var o=t.encryptionData,i=e+n,a=r._playlistEventRepresentation;if(!a)throw new Error("Playlist event representation should exist.");var s=r._buildEncryptionConfig(o,i),u=s.whenComplete().then(function(e){return new l.Segment({url:t.url,index:i,timeRange:t.timeRange,format:r._segmentFormat,loader:r._segmentLoader,playlistEventRepresentation:a,logger:r._logger,delayCalculator:r._segmentDelayCalculator,isResponseCodeAcceptable:r._isSegmentResponseCodeAcceptable,isResponseCodeRetryable:r._isSegmentResponseCodeRetryable,encryptionConfig:e})});return{result:u,abort:function(){return s.abort()}}});return o.run()})},e.prototype.getSegmentIndexContainingTime=function(e){var t=this._data;if(!t)throw new Error("Not loaded yet.");var r=P(t.segments,function(t){return t.timeRange.containsTime(e)});return r?t.mediaSequence+t.segments.indexOf(r):null},e.prototype._buildEncryptionConfig=function(e,t){var r=this,n=new _(function(){if(e.method===s.NONE)return{result:b.resolve(void 0)};if(e.method!==s.AES_128)return r._logger.error("Unsupported encryption method.",e.method),{result:b.reject(new p.UnsupportedEncryptionError)};var n=r._keyLoader;if(!n)return{result:b.reject(new Error("Encryption method not supported as no key loader provided."))};var o=r._retrieveKey(e.keyUrl),a=o.whenComplete().then(function(r){return{cipher:"AES-CBC",key:r,iv:e.iv||i(t)}});return{result:a,abort:function(){return o.abort()}}});return n.run()},e.prototype._retrieveKey=function(e){var t=this,r=this._keyLoader;if(!r)throw new Error("No key loader.");var n=this._keyRetrievalJobsCache.get(e);if(n)this._logger.debug("Key retrieval already in progress.",e);else{var o=this._playlistEventRepresentation;if(!o)throw new Error("Playlist event representation should exist.");n=new _(function(){var n=m(function(){return new _(function(){var n=new f.Key(o,e);t._onKeyRequestQueued.dispatch({key:n});var i=r.request({url:e});i.whenRequestStarted.then(function(){return t._onKeyRequestStart.dispatch({key:n})}),t._logger.debug("Retrieving key.",e);var a=i.getResponse().then(function(r){if(!r)return t._logger.warn("Key request timed out.",e),t._onKeyRequestFailed.dispatch({key:n,statusCode:null}),{success:!1};var o=r.statusCode;if(t._isKeyResponseCodeAcceptable(o)){var i=r.data;return i?(t._logger.debug("Got key response.",e,o),t._onKeyRetrieved.dispatch({key:n,statusCode:o}),{success:!0,result:new Uint8Array(i)}):(t._logger.warn("Key response contained no data.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),{success:!1})}return t._isKeyResponseCodeRetryable(o)?(t._logger.warn("Key response code was not acceptable. Will retry.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),{success:!1}):(t._logger.warn("Key response code was not acceptable.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),b.reject(new d.UnacceptableResponseStatusCodeError(o)))});return{result:a,abort:function(){t._logger.debug("Aborting key request.",e),i.abort(),t._onKeyRequestFailed.dispatch({key:n,aborted:!0})}}})},t._keyDelayCalculator);return{result:n.whenComplete(),abort:function(){return n.abort()}}}),this._keyRetrievalJobsCache.set(e,n)}return n.run()},e.prototype._parsePlaylist=function(e){var t={version:null,type:x.LIVE,mediaSequence:null,targetDuration:null,totalDuration:0,ended:!1},r=[],i={method:s.NONE},a=null;T.lastIndex=0;for(var l,d=0,p=!1;null!==(l=T.exec(e));){var h=l.filter(function(e,t){return 0!==t&&void 0!==e}).map(function(e,t){return 0===t?e.toLowerCase():e}),f=h[0],_=h.slice(1);if(0===d){if("extm3u"!==f)throw new c.PlaylistParseError("First line did not contain EXTM3U tag.")}else{if(!p)switch(f){case"playlist-type":if(t.type!==x.LIVE)throw new c.PlaylistParseError("Already have playlist type.");switch(_[0].toLowerCase()){case"vod":t.type=x.VOD;break;case"event":t.type=x.EVENT;break;default:throw new c.PlaylistParseError("Invalid playlist type.")}break;case"media-sequence":if(null!==t.mediaSequence)throw new c.PlaylistParseError("Already have media sequence number.");var g=parseInt(_[0],10);if(g+""!==_[0])throw new c.PlaylistParseError("Invalid media sequence number.");t.mediaSequence=g;break;case"targetduration":if(null!==t.targetDuration)throw new c.PlaylistParseError("Already have target duration.");var y=parseInt(_[0],10);if(y+""!==_[0]||y<0)throw new c.PlaylistParseError("Invalid target duration.");t.targetDuration=1e3*y;break;case"version":if(null!==t.version)throw new c.PlaylistParseError("Already have version.");var v=parseInt(_[0],10);if(v+""!==_[0])throw new c.PlaylistParseError("Invalid version.");if(v<3)throw new c.PlaylistParseError("HLS version must be 3 or above.");t.version=v;break;default:p=!0}if(p)switch(f){case"key":M.lastIndex=0;for(var m=void 0,E=null,b=null,P=null;null!==(m=M.exec(_[0]));){if(3!==m.length)throw new c.PlaylistParseError("Error parsing key attributes.");var w=m[1].trim().toLowerCase(),R=n(m[2].trim());switch(w){case"method":E=R.toLowerCase();break;case"uri":b=S.buildAbsoluteUrl(this._url,R);break;case"iv":P=o(R);break;default:this._logger.warn("Unknown attribute when parsing KEY line.",w)}}if(!E)throw new c.PlaylistParseError("Missing encryption method.");if(!b&&"none"!==E)throw new c.PlaylistParseError("Missing key url.");switch(E){case"none":if(null!==b)throw new c.PlaylistParseError("Key url not allowed.");if(null!==P)throw new c.PlaylistParseError("IV not allowed.");i={method:s.NONE};break;case"aes-128":if(!b)throw new c.PlaylistParseError("Key url required.");i={method:s.AES_128,keyUrl:b,iv:P};break;case"sample-aes":if(!b)throw new c.PlaylistParseError("Key url required.");i={method:s.SAMPLE_AES,keyUrl:b,iv:P};break;default:throw new c.PlaylistParseError("Unknown encryption method.")}break;case"inf":if(!_[0].match(D))throw new c.PlaylistParseError("Invalid segment duration.");a=1e3*parseFloat(_[0]);break;case"":if(t.ended)throw new c.PlaylistParseError("Already received ENDLIST tag.");if(null===a)throw new c.PlaylistParseError("Not received segment duration.");var A=S.buildAbsoluteUrl(this._url,_[0]);r.push({url:A,timeRange:new u.TimeRange(t.totalDuration,a),encryptionData:i}),t.totalDuration+=a,a=null;break;case"endlist":if(t.ended)throw new c.PlaylistParseError("Already had ENDLIST tag.");t.ended=!0;break;default:this._logger.warn("Unable to parse playlist line.",f)}}d++}var k=t.version,O=t.type,C=t.mediaSequence,I=t.targetDuration,L=t.ended,N=t.totalDuration;if(null===k)throw new c.PlaylistParseError("Missing version.");if(null===I)throw new c.PlaylistParseError("Missing target duration.");if(L&&O===x.LIVE)throw new c.PlaylistParseError("Cannot be ended if type is LIVE.");if(!L&&O===x.VOD)throw new c.PlaylistParseError("Must be ended if type is VOD.");return null===C&&(C=0),{version:k,type:O,mediaSequence:C,targetDuration:I,totalDuration:N,ended:L,segments:r}},e}();t.Playlist=k},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(22),i=r(3),a=r(11),s=r(27),u=n.helpers.abortableJob.AbortableJob,l=n.helpers.retry,d=l.retry,c=l.buildExponentialDelayCalculator,p=n.helpers.Promise,h=n.eventDispatcher.EventDispatcher,f=n.logger.prefixLogger,_=n.logger.noOpLogger,g=function(){function e(e){var t=e.url,r=e.index,n=e.timeRange,o=e.encryptionConfig,a=e.format,l=e.loader,g=e.playlistEventRepresentation,y=e.logger,v=void 0===y?_:y,m=e.delayCalculator,E=void 0===m?c():m,b=e.isResponseCodeAcceptable,P=void 0===b?function(e){return 200===e}:b,S=e.isResponseCodeRetryable,w=void 0===S?function(e){return!(e>=400&&e<500)}:S,R=this;this._onSegmentRequestQueued=new h,this._onSegmentRequestStart=new h,this._onSegmentRetrieved=new h,this._onSegmentRequestFailed=new h,this._onSegmentDecryptionStart=new h,this._onSegmentDecryptionEnd=new h,this._logger=f(v,"Segment"),this.onSegmentRequestQueued=this._onSegmentRequestQueued.getHandle(),this.onSegmentRequestStart=this._onSegmentRequestStart.getHandle(),this.onSegmentRetrieved=this._onSegmentRetrieved.getHandle(),this.onSegmentRequestFailed=this._onSegmentRequestFailed.getHandle(),this.onSegmentDecryptionStart=this._onSegmentDecryptionStart.getHandle(),this.onSegmentDecryptionEnd=this._onSegmentDecryptionEnd.getHandle(),this._timeRange=n,this._encryptionConfig=o||null,this._format=a,this._loader=l,this._isResponseCodeAcceptable=P,this._isResponseCodeRetryable=w,this._downloadAbortableJob=new u(function(){var e=d(function(){return new u(function(){var e=new s.Segment(g,t,r);R._onSegmentRequestQueued.dispatch({segment:e});var n=R._loader.request({url:t});n.whenRequestStarted.then(function(){return R._onSegmentRequestStart.dispatch({segment:e})}),R._logger.debug("Requesting segment.",t);var o=n.getResponse().then(function(r){if(!r)return R._logger.warn("Segment request timed out.",t),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:null}),{success:!1};var n=r.statusCode;if(R._isResponseCodeAcceptable(n)){var o=r.data;return o?(R._logger.debug("Got segment response.",t,n),R._onSegmentRetrieved.dispatch({segment:e,statusCode:n}),{success:!0,result:{data:new Uint8Array(o),eventRepresentation:e}}):(R._logger.warn("Segment response contained no data.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),{success:!1})}return R._isResponseCodeRetryable(n)?(R._logger.debug("Segment response code was not acceptable. Will retry.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),{success:!1}):(R._logger.debug("Segment response code was not acceptable.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),p.reject(new i.UnacceptableResponseStatusCodeError(n)))});return{result:o,abort:function(){R._logger.debug("Aborting segment request.",t),n.abort(),R._onSegmentRequestFailed.dispatch({segment:e,aborted:!0})}}})},E);return{result:e.whenComplete(),abort:function(){return e.abort()}}}),this._retrieveAbortableJob=new u(function(){var e=R._downloadAbortableJob.run(),t=e.whenComplete().then(function(e){var t=e.data,r=e.eventRepresentation;return R.decrypt(t,r).then(function(e){return{data:e,eventRepresentation:r}})});return{result:t,abort:function(){e.abort()}}})}return e.prototype.getTimeRange=function(){return this._timeRange},e.prototype.retrieveData=function(){return this._retrieveAbortableJob.run()},e.prototype.decrypt=function(e,t){var r=this,n=this._encryptionConfig;if(!n)return p.resolve(e);this._logger.info("Finding a decryptor...");var i=o.DecryptorFactory.retrieveDecryptor(n);if(!i)return this._logger.error("Could not find a decryptor."),p.reject(new a.NoDecryptorError);this._logger.info("Decryptor found."),this._onSegmentDecryptionStart.dispatch({segment:t});var s=i.decrypt(e,n);return s.then(function(){r._logger.debug("Decrypted."),r._onSegmentDecryptionEnd.dispatch({segment:t})}),s},e}();t.Segment=g},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(4),i=n.helpers.Promise,a=n.eventDispatcher.EventDispatcher,s=n.logger.prefixLogger,u=n.logger.noOpLogger,l=o.helpers.timeRanges.getCoverage,d=7e3,c=function(){function e(e,t,r,n,o){void 0===o&&(o=u);var i=this;this._onAppendQueued=new a,this._onAppendEnd=new a,this._updateTimerId=null,this._waitingForData=!1,this._started=!1,this._resettingPromise=null,this._error=null,this._logger=s(o,"SimpleMSE"),this.onAppendQueued=this._onAppendQueued.getHandle(),this.onAppendEnd=this._onAppendEnd.getHandle(),this._mse=e,this._getNextSegmentData=t,this._getPosition=r,this._onError=n,e.whenInitialized().then(function(){!i._error&&i._started&&(i._logger.debug("MSE initialized. Preparing to update."),i._prepareUpdate())}).catch(function(e){i._error||(i._logger.error("Error when waiting for MSE to initialize.",e),i._handleError(e||new Error("Error waiting for MSE to initialize.")))})}return e.prototype.start=function(){if(this._checkNotErrored(),this._resettingPromise)throw new Error("start() is not allowed whilst a reset is in progress.");if(this._started)throw new Error("Already started. reset() first.");this._logger.debug("start() called."),this._started=!0,this._prepareUpdate()},e.prototype.kill=function(){this._error||(this._logger.debug("kill() called."),this._updateTimerId&&(this._logger.debug("Clearing update timer."),window.clearTimeout(this._updateTimerId),this._updateTimerId=null),this._error=new Error("Killed."),this._logger.debug("Killed."))},e.prototype.reset=function(){var e=this;if(this._checkNotErrored(),this._logger.debug("reset() called."),this._resettingPromise)return this._logger.debug("Reset already in progress."),this._resettingPromise;if(!this._started)return this._logger.debug("Nothing to do to, already reset."),i.resolve();var t=this._mse;return this._waitingForData=!1,this._started=!1,this._updateTimerId&&(this._logger.debug("Claring update timer."),window.clearTimeout(this._updateTimerId),this._updateTimerId=null),this._logger.debug("Waiting to clear MSE buffer..."),this._resettingPromise=t.whenIdle().then(function(){e._logger.debug("Clearing MSE buffer.");var r=t.getBuffered(),n=l(r);if(n.duration>0)return t.remove(n)}).then(function(){e._logger.debug("MSE buffer cleared."),e._resettingPromise=null}).catch(function(t){if(!e._error){ -e._logger.error("Error resetting MSE.",t);var r=t||new Error("Error resetting MSE.");throw e._handleError(r),r}})},e.prototype.waitingForSegmentData=function(){return this._checkNotErrored(),this._waitingForData},e.prototype.provideNextSegmentData=function(e){if(this._checkNotErrored(),!this._waitingForData)throw new Error("Not waiting for data.");this._logger.debug("Segment data provided."),this._waitingForData=!1,this._update(e)},e.prototype._prepareUpdate=function(){if(!this._updateTimerId){var e=this._mse;if(e.hasInitialized()){var t=l(e.getBuffered());if(t.end<=this._getPosition()+d){this._logger.debug("Requesting next segment data.");var r=this._getNextSegmentData();r?(this._logger.debug("Got segment data."),this._update(r)):(this._logger.debug("Did not get any data."),this._waitingForData=!0)}else this._scheduleUpdate()}}},e.prototype._update=function(e){var t=this;this._logger.debug("Updating...");var r=this._mse;this._onAppendQueued.dispatch({segment:e.eventRepresentation}),this._logger.debug("Appending..."),r.append(e.data).then(function(){t._logger.debug("Appended."),t._onAppendEnd.dispatch({segment:e.eventRepresentation}),t._resettingPromise||t._scheduleUpdate()}).catch(function(e){t._error||(t._logger.error("Error updating MSE.",e),t._handleError(e||new Error("Error updating MSE.")))})},e.prototype._scheduleUpdate=function(){var e=this;this._updateTimerId=window.setTimeout(function(){e._updateTimerId=null,e._prepareUpdate()},500)},e.prototype._checkNotErrored=function(){if(this._error)throw this._error},e.prototype._handleError=function(e){this._error||(this._error=e,this._onError(e))},e}();t.SimpleMSE=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(34),o=r(14),i=[n.PassThrough,o.MP3ToMP4];t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=n.helpers.Promise;t.PassThrough={getInputFormat:function(){return{}},getOutputFormat:function(){return{}},transmux:function(e){return o.resolve({data:e})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(33);t.TransmuxerFactory={retrieveTransmuxers:function(e,t){return n.default.filter(function(r){var n=r.getInputFormat(),o=r.getOutputFormat();return!(e&&(n.mimeType&&e.mimeType&&e.mimeType!==n.mimeType||n.audioCodec&&e.audioCodec&&e.audioCodec.id!==n.audioCodec.id||n.videoCodec&&e.videoCodec&&e.videoCodec.id!==n.videoCodec.id)||t&&(o.mimeType&&t.mimeType&&t.mimeType!==o.mimeType||o.audioCodec&&t.audioCodec&&t.audioCodec.id!==o.audioCodec.id||o.videoCodec&&t.videoCodec&&t.videoCodec.id!==o.videoCodec.id))})},retrieveTransmuxer:function(e,r){return t.TransmuxerFactory.retrieveTransmuxers(e,r)[0]||null}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.0.5",t.buildNumber=790;var n=r(16);t.HLSMSEPlayer=n.HLSMSEPlayer;var o=r(15);t.errors=o.errors;var i=r(17);t.retrievalErrors=i.retrievalErrors}])})},function(e,t,r){!function(t,n){e.exports=n(r(2))}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(t,r){t.exports=e},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"An unrecoverable error occurred whilst decoding.")||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.DECODE_ERROR"},t}(o.errors.PlayerFatalError);t.DecodeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"An unrecoverable network error occurred.")||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.NETWORK_ERROR"},t}(o.errors.PlayerFatalError);t.NetworkError=i},function(e,t,r){"use strict";function n(e){return e.slice(0).sort(function(e,t){return e.start-t.start}).reduce(function(e,t,r){var n=e.length-1;return r>0&&e[n].end>=t.start?e[n].end=t.end:e.push(t),e},[])}function o(e){for(var t=[],r=e.length,o=0;or&&(r=e.end)}),new u.TimeRange(t,r-t)}Object.defineProperty(t,"__esModule",{value:!0});var u=r(0);t.normalizeRawTimeRanges=n,t.buildTimeRanges=o,t.containsTime=i,t.normalizeTimeRanges=a,t.getCoverage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(1),i=r(2);!function(e){e.DecodeError=o.DecodeError,e.NetworkError=i.NetworkError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(3);!function(e){var t;!function(e){e.buildTimeRanges=o.buildTimeRanges,e.containsTime=o.containsTime,e.getCoverage=o.getCoverage,e.normalizeTimeRanges=o.normalizeTimeRanges}(t=e.timeRanges||(e.timeRanges={}))}(n=t.helpers||(t.helpers={}))},function(e,t,r){"use strict";function n(e){e.load()}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=r(1),s=r(2),u=r(3),l=r(7),d=i.helpers.deferred.buildDeferred,c=i.helpers.url.getExtension,p=i.helpers.Promise,h=i.logger.prefixLogger,f=i.errors.NotSupportedError,_=i.errors.PlayerFatalError,g=new Error("Media element was revoked."),y=function(e){function t(t,r){var n=this.constructor,o=e.call(this,r)||this;o._duration=null,o._stallDetected=!1,o._initialized=!1,o._deferredProvideMediaElementCallback=null,o._playInProgress={inProgress:!1},o._lastStallCheckPos=null,o._stallCheckTimerId=null,o._endedOverride=!1,o._volume=1,o._muted=!1,o._positionWhenMediaElementRevoked=0,o._playingWhenMediaElementRevoked=!1,o._provideMediaElementDeferred=null,o._mediaElementAndState=null,o._listeners=[],o._currentSeekCallback=null,o._logger=h(o._logger,"HTML5Player"),o._descriptor=t,o._playerDependencies=r,o._mimeType=t.getFormat().mimeType||n.inferMimeType(t.getUrl());var a=void 0!==r.mediaElement?r.mediaElement:o._createDefaultMediaElement();return a&&o.provideMediaElement(a).catch(function(e){return e===g?void o._logger.debug("Initial provideMediaElement() call was aborted."):void o._triggerError(new l.InitializeError(e))}),o._logger.info("Checking if the player can play the provided descriptor."),o._canPlayTimer=window.setTimeout(function(){o._canPlay().then(function(e){if(!o.isDead())return e instanceof i.errors.NotSupportedError?(o._logger.info("Player not supported.",e),void o._triggerError(e)):e?(o._logger.info("Player supported."),void o._initialize()):(o._logger.info("Player not supported."),void o._triggerError(new f))}).catch(function(e){o._logger.error("Unexpected error during can play check.",e),o._triggerError(new _("An unexpected error occured during initialization.",e))})},0),o}return o(t,e),t.inferMimeType=function(e){var t=c(e);switch(t){case"mp3":return"audio/mpeg";case"mp4":return"video/mp4";case"m3u8":return"application/x-mpegURL";default:return null}},t.prototype.getMediaElement=function(){return this._mediaElementAndState&&this._mediaElementAndState.element},t.prototype.provideMediaElement=function(e){var t=this;if(this._ensureNotDead(),this._mediaElementAndState)throw new Error("Already have a media element.");this._logger.debug("provideMediaElement() called.",e),this._initMediaElementLocal(e,null);var r=this._provideMediaElementDeferred=d();this._mediaElementAndState={element:e,state:"INITIALIZING"};var n=function(){t._logger.debug("Initializing media element."),t._initMediaElement(e,t._descriptor.getUrl()),t._attachListeners();var n=t._listenToOnce("error",function(){t._provideMediaElementDeferred=null;var n=e.error.code+" = "+(e.error.message||"[unknown]");t._logger.error("Error whilst initializing media element.",n),t.revokeMediaElement(),r.reject(new Error("Error when initializing media element. Error: "+n))},{earlyAttach:!0});t._listenToOnce("loadeddata",function(){t._logger.debug("Got loadeddata event from media element."),o()},{earlyAttach:!0});var o=function(){t._logger.debug("Putting media element in the state that is expected..."),i()},i=function(){null===t._getQueuedSeekPosition()&&t._positionWhenMediaElementRevoked>0?(t._logger.debug("Seeking to expected position..."),t._performSeek(t._positionWhenMediaElementRevoked,function(e){return void 0!==e?(t._provideMediaElementDeferred=null,t._logger.error("An error occurred when trying to seek to the expected position."),t.revokeMediaElement(),void r.reject(new Error("An error occurred when trying to restore the position."))):(t._logger.debug("Seeked to expected position."),void a())})):a()},a=function(){t.isPlaying()===t.isActuallyPlaying()&&t._playingWhenMediaElementRevoked?(t._logger.debug("Calling play to match previous state..."),t._play().catch(function(){t._provideMediaElementDeferred=null,t._logger.error("An error occurred when trying to play."),t.revokeMediaElement(),r.reject(new Error("Browser refused play() request on media element."))}),t._listenToOnce("play",function(){t._logger.debug("Play succeeded."),s()},{earlyAttach:!0})):s()},s=function(){t._provideMediaElementDeferred=null,n.remove(),r.resolve(void 0),t._mediaElementAndState.state="STABLE",t._logger.debug("Finished putting element in expected state."),null!==t._duration&&t._atomic(function(){t.isReady()||t._signalReady(),t._handleDefferredPauseAndSeek()})}};return this._initialized?n():this._deferredProvideMediaElementCallback=n,this._provideMediaElementDeferred.promise},t.prototype.revokeMediaElement=function(){if(!this._mediaElementAndState)throw new Error("There is no media element to revoke.");this._deferredProvideMediaElementCallback=null,this._provideMediaElementDeferred&&(this._provideMediaElementDeferred.reject(g),this._provideMediaElementDeferred=null),this._logger.debug("revokeMediaElement() called."),this._detachListeners();var e=this._mediaElementAndState.element;this.isDead()||(this._positionWhenMediaElementRevoked=this.getPosition(),this._playingWhenMediaElementRevoked=this.isPlaying()),this._mediaElementAndState=null,this._initMediaElement(e,null),this.isDead()||this._handleStalled()},t.prototype.getVolume=function(){return this._volume},t.prototype.getMuted=function(){return this._muted},t.prototype.setMuted=function(e){this._muted=e,this._mediaElementAndState&&(this._mediaElementAndState.element.muted=e)},t.prototype.getBufferedTimeRanges=function(){return this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state?u.buildTimeRanges(this._mediaElementAndState.element.buffered):[]},t.prototype.getMaxBufferLength=function(){return null},t.prototype._setVolume=function(e){this._volume=e,this._mediaElementAndState&&(this._mediaElementAndState.element.volume=e)},t.prototype._getResolvedMimeType=function(){return this._mimeType},t.prototype._canPlay=function(){return this._mimeType&&this._canPlayProtocol(this._descriptor.getProtocol())&&this._canPlayType(this._mimeType)?p.resolve(!0):p.resolve(!1)},t.prototype._canPlayProtocol=function(e){return["http","hls"].indexOf(e.name)>=0},t.prototype._canPlayType=function(e){try{var t=document.createElement("audio");return!!t.canPlayType(e)}catch(e){return!1}},t.prototype._initialize=function(){var e=this;this._initialized=!0,this._listenTo("error",function(){if("INITIALIZING"===e._mediaElementAndState.state)return void e._logger.debug("An error occurred, but the media element is initializing, so ignoring...");var t=e._mediaElementAndState.element.error;switch(t.code){case 2:e._triggerError(new s.NetworkError);break;case 3:e._triggerError(new a.DecodeError);break;default:e._triggerError(new i.errors.PlayerFatalError("An unexpected error occurred."))}},{earlyAttach:!0}),this._listenTo("playing",function(){e._logger.debug("Media element playing event."),e._mediaElementAndState&&!e._mediaElementAndState.element.paused?e._handlePlayingEvent():e._logger.debug("Ignoring playing event because media element is reporting it is paused.")}),this._listenTo("pause",function(){e._logger.debug("Media element pause event."),e._mediaElementAndState&&e._mediaElementAndState.element.paused?e._handlePauseEvent():e._logger.debug("Ignoring pause event because media element is reporting it is not paused.")}),this._listenTo("ended",function(){e._logger.debug("Media element ended event."),e._mediaElementAndState&&!e._mediaElementAndState.element.ended?e._handleEndedEvent():e._logger.debug("Ignoring ended event because media element is reporting it is not ended.")}),this._listenTo("stalled",function(){e._logger.debug("Media element stalled event."),e._checkIfStalled()}),this._stallCheckTimerId=window.setInterval(function(){return e._checkIfStalled()},400),this._retrieveDuration().then(function(t){e._logger.debug("Duration retrieved.",t),e._duration=t,e._atomic(function(){e._provideDuration(t),e._mediaElementAndState&&"STABLE"===e._mediaElementAndState.state&&(e._signalReady(),e._handleDefferredPauseAndSeek())})}).catch(function(t){e._triggerError(new i.errors.PlayerFatalError("An unexpected error occurred when attempting to retrieve the duration.",t))}),this._deferredProvideMediaElementCallback&&this._deferredProvideMediaElementCallback()},t.prototype._createDefaultMediaElement=function(){return document.createElement(this._playerDependencies.mediaElementType||"audio")},t.prototype._handlePauseEvent=function(){var e=this;this._atomic(function(){e._shouldBeEnded()?e._signalEnded():(e._notifyNotStalled(),e._notifyPlaying(!1))})},t.prototype._handlePlayingEvent=function(){var e=this,t=this._duration;if(null===t)throw new Error("Expecting duration to exist.");var r=this._getTruePosition();return r>=t?void this._logger.warn("Got a media element playing event and the positon was >= the duration.",r,t):this.isEnded()||this._shouldBeEnded()?void this._logger.warn("Got a media element playing event when the player is/should be ended."):void this._atomic(function(){e._endedOverride=!1,e._notifyNotStalled(),e._signalNotEnded(),e._notifyPlaying(!0)})},t.prototype._handleEndedEvent=function(){var e=this;return null!==this._getQueuedSeekPosition()?void this._logger.warn("Got a media element ended event but ignoring because a seek is in progress."):void this._atomic(function(){e._endedOverride=!0,e._signalEnded()})},t.prototype._shouldBeEnded=function(){return this._endedOverride||this._mediaElementReportingEnded()},t.prototype._mediaElementReportingEnded=function(){return!(!this._mediaElementAndState||!this._mediaElementAndState.element.ended)},t.prototype._signalNotEnded=function(){if(this._shouldBeEnded())throw new Error("Attempt to signal not ended when it should be.");e.prototype._signalNotEnded.call(this)},t.prototype._retrieveDuration=function(){var e=this;return new p(function(t){e._listenToOnce("loadedmetadata",function(){t(1e3*e._mediaElementAndState.element.duration)},{reattach:!0,earlyAttach:!0})})},t.prototype._handlePlayPauseChange=function(e){var t=this;if(this.isEnded())return void this._notifyPlaying(e);if(this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state){var r=this._mediaElementAndState.element,n=this._playInProgress.inProgress||!r.paused;if(n!==e)if(e){var o={inProgress:!0};this._playInProgress=o,this._play().then(function(){return o.inProgress=!1}).catch(function(e){o.inProgress=!1,t._notifyPlayRejection(e)})}else this._playInProgress={inProgress:!1},r.pause(),this._notifyPlaying(!1);else this._playInProgress.inProgress||this._notifyPlaying(e)}},t.prototype._handleSeekChange=function(e){var t=this,r=this._mediaElementAndState;r&&"USABLE"===r.state&&(this._endedOverride=!1,this._performSeek(e,function(r){return void 0!==r?void t._triggerError(new i.errors.PlayerFatalError("An error occurred when trying to seek.",r)):(e===t._duration&&(t._endedOverride=!0),void t._atomic(function(){t._signalSeekComplete(),t.isEnded()||t._handlePlayPauseChange(t.isPlaying())}))}))},t.prototype._performSeek=function(e,t){var r=this,n=this._mediaElementAndState;if(!n)throw new Error("Media element does not exist.");var o=this._currentSeekCallback;if(o&&(this._currentSeekCallback=null,o.listenerHandle.remove()),n.element.currentTime===e/1e3)return void t();n.element.currentTime=e/1e3;var i=this._listenToOnce("seeked",function(){r._currentSeekCallback=null,t()},{earlyAttach:!0});this._currentSeekCallback={listenerHandle:i,callback:t}},t.prototype._getPosition=function(){var e=null!==this._duration?this._duration:1/0;if(!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)return this._positionWhenMediaElementRevoked;var t=Math.min(this._getTruePosition(),e);return this._shouldBeEnded()?e:t},t.prototype._getTruePosition=function(){if(!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)throw new Error("Media element does not exist or is in invalid state.");var e=this._mediaElementAndState.element;return 1e3*e.currentTime},t.prototype._kill=function(){window.clearTimeout(this._canPlayTimer),this._mediaElementAndState&&this.revokeMediaElement(),this._stallCheckTimerId&&window.clearInterval(this._stallCheckTimerId),this._listeners=[]},t.prototype._listenToOnce=function(e,t,r){void 0===r&&(r={});var n=r.reattach,o=r.earlyAttach;void 0===n&&(n=!1),void 0===o&&(o=!1);var i=function(e){a.remove(),t(e)},a=this._listenTo(e,i,{reattach:n,earlyAttach:o});return a},t.prototype._listenTo=function(e,t,r){var n=this;void 0===r&&(r={});var o=r.reattach,i=r.earlyAttach;void 0===o&&(o=!0),void 0===i&&(i=!1);var a={attached:!1,handler:t,eventType:e,once:!1,reattach:o,earlyAttach:i};if(this._listeners.push(a),!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state&&!i)return{remove:function(){var e=n._listeners.indexOf(a);e>=0&&n._listeners.splice(e,1)}};var s=this._mediaElementAndState.element;return s.addEventListener(e,t,!1),a.attached=!0,{remove:function(){var r=n._listeners.indexOf(a);r>=0&&(n._listeners.splice(r,1),s.removeEventListener(e,t,!1))}}},t.prototype._notifyNotStalled=function(){this._stallDetected=!1,this._lastStallCheckPos=null,this._handleStalled()},t.prototype._initMediaElement=function(e,t){this._initMediaElementLocal(e,t)},t.prototype._initMediaElementLocal=function(e,t){e.setAttribute("msAudioCategory","BackgroundCapableMedia"),e.mozAudioChannelType="content",e.removeAttribute("src"),n(e),t&&(this._logger.debug("Setting media element src.",t),e.src=t),e.volume=this._volume,e.muted=this._muted,e.playbackRate=1,e.setAttribute("preload","metadata"),e.load()},t.prototype._checkIfStalled=function(){if(this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state){var e=this._mediaElementAndState.element;if(!e.paused&&this.isActuallyPlaying()){var t=e.currentTime;this._stallDetected=e.readyState<=2||this._lastStallCheckPos===t,this._lastStallCheckPos=t,this._handleStalled()}}},t.prototype._handleStalled=function(){this._shouldBeEnded()&&null===this._getQueuedSeekPosition()?this.isEnded()||(this._logger.debug("Signalling ended because stalled near end."),this._signalEnded()):this._notifyStalled(this._stallDetected||!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)},t.prototype._play=function(){var e=this;if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");if(this._mediaElementAndState.element.ended)return this._logger.debug("Not calling play() because we are at the end. It will be called after a seek."),p.resolve();var t=this._mediaElementAndState.element.play();return new p(function(r,n){t?t.then(function(){r()}).catch(function(t){"AbortError"===t.name?(e._logger.debug("Media element play() promise rejected with AbortError."),r()):n(t)}):r()})},t.prototype._handleDefferredPauseAndSeek=function(){var e=this;if(!this._mediaElementAndState||"STABLE"!==this._mediaElementAndState.state)throw new Error("Media element must be in the STABLE state.");this._logger.debug("Handling deferred pause and seek..."),this._mediaElementAndState.state="USABLE",this._attachListeners(),this._atomic(function(){e._handleStalled();var t=e._getQueuedSeekPosition();null!==t&&e._handleSeekChange(t),e.isPlaying()!==e.isActuallyPlaying()&&e._handlePlayPauseChange(e.isPlaying())})},t.prototype._detachListeners=function(){if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");var e=this._mediaElementAndState.element;this._listeners.forEach(function(t){t.attached&&(e.removeEventListener(t.eventType,t.handler,!1),t.attached=!1)}),this._listeners=this._listeners.filter(function(e){return e.reattach})},t.prototype._attachListeners=function(){if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");this._logger.debug("Attaching listeners...");var e=this._mediaElementAndState,t=e.element,r=e.state;this._listeners.forEach(function(e){e.attached||!e.reattach||"USABLE"!==r&&!e.earlyAttach||(t.addEventListener(e.eventType,e.handler,!1),e.attached=!0)}),this._logger.debug("Attached listeners.")},t}(i.BasePlayer);t.HTML5Player=y},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){return e.call(this,"An error occurred when initializing the media element.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.INITIALIZE_ERROR"},t}(o.errors.PlayerFatalError);t.InitializeError=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.0.5",t.buildNumber=790;var n=r(6);t.HTML5Player=n.HTML5Player;var o=r(4);t.errors=o.errors;var i=r(5);t.helpers=i.helpers}])})},function(e,t,r){!function(t,n){e.exports=n(r(2))}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(5),i=function(e){function t(t,r,n){void 0===r&&(r={}),void 0===n&&(n=2e4);var o=e.call(this)||this;o.__aborted=!1;var i=new XMLHttpRequest;return o.xhr=i,i.addEventListener("load",function(){return o._onLoad()}),i.addEventListener("error",function(){return o._onError()}),i.addEventListener("timeout",function(){return o._onTimeout()}),i.open("GET",t,!0),i.timeout=n,i.responseType=o._getResponseType(),Object.keys(r).forEach(function(e){return i.setRequestHeader(e,r[e])}),o._signalRequestStart(),i.send(),o}return n(t,e),t.prototype._abort=function(){this.__aborted=!0,this.xhr.abort()},t.prototype._onTimeout=function(){this.__aborted||this._provideResponse(null)},t.prototype._onLoad=function(){if(!this.__aborted){var e=this.xhr;this._provideResponse({statusCode:e.status,data:this.xhr.response,headers:this._parseHeaders(e.getAllResponseHeaders()||"")})}},t.prototype._onError=function(){this.__aborted||(0===this.xhr.status?this._provideResponse({statusCode:0,data:null,headers:{}}):this._provideResponse(new Error("An error occurred.")))},t.prototype._parseHeaders=function(e){var t={};if(!e)return t;for(var r=e.split("\r\n"),n=0,o=r.length;n0){var s=i.substring(0,a).trim(),u=i.substring(a+2);t[s]=u}}return t},t}(o.loader.LoaderRequest);t.LoaderRequest=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.arrayBufferLoader={request:function(e){var t=e.url,r=e.headers,o=e.timeout;return new n.ArrayBufferLoaderRequest(t,r,o)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);t.stringLoader={request:function(e){var t=e.url,r=e.headers,o=e.timeout;return new n.StringLoaderRequest(t,r,o)}}},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._getResponseType=function(){return"arraybuffer"},t}(o.LoaderRequest);t.ArrayBufferLoaderRequest=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._getResponseType=function(){return"text"},t}(o.LoaderRequest);t.StringLoaderRequest=i},function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.0.5",t.buildNumber=790;var n=r(2);t.stringLoader=n.stringLoader;var o=r(1);t.arrayBufferLoader=o.arrayBufferLoader}])})},function(e,t,r){!function(t,n){e.exports=n(r(2),r(1))}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=r(3),a=r(1),s=o.helpers.abortableJob.AbortableJob,u=o.helpers.find,l=o.helpers.time,d=300,c=new a.Limiter(d,3e5),p=5e3,h=[i.renditions.encryptedHlsMp3,i.renditions.hlsMp3,i.renditions.httpMp3],f=function(e){function t(t){var r=t.loader,n=t.clientId,o=t.trackId,i=t.secretToken,a=void 0===i?null:i,s=t.requestAuthorization,u=void 0===s?null:s,l=t.excludedRenditions,d=void 0===l?[]:l,c=t.maxBitrate,p=void 0===c?1/0:c,h=t.endpointBaseUrl,f=void 0===h?"https://api.soundcloud.com/":h,_=t.encryptedStreamsEnabled,g=void 0!==_&&_,y=e.call(this)||this;if(y._getUrlsJob=null,y._clearResponseTimer=null,!r)throw new Error("loader required.");if("string"!=typeof n)throw new Error("clientId invalid.");if("number"!=typeof o)throw new Error("trackId invalid.");if(null!==a&&"string"!=typeof a)throw new Error("secretToken invalid.");if(null!==u&&"string"!=typeof u)throw new Error("requestAuthorizaton invalid.");if("number"!=typeof p||p<=0)throw new Error("maxBitrate must be > 0.");if("string"!=typeof f)throw new Error("endpointBaseUrl must be > 0.");if("boolean"!=typeof g)throw new Error("encryptedStreamsEnabled invalid.");return y._loader=r,y._clientId=n,y._requestAuthorization=u,y._trackId=o,y._secretToken=a,y._endpointBaseUrl=f,y._encryptedStreamsEnabled=g,y._excludedRenditions=d,y._excludedRenditionsOnLastURLRequest=d.slice(),y._maxBitrate=p,y}return n(t,e),t.prototype.getTrackId=function(){return this._trackId},t.prototype.excludeRendition=function(e){this._excludedRenditions.indexOf(e)<0&&this._excludedRenditions.push(e)},t.prototype.updateRequestAuthorization=function(e){if(null!==e&&"string"!=typeof e)throw new Error("requestAuthorizaton invalid.");this._requestAuthorization=e},t.prototype.clearCache=function(){this._clearResponseTimer&&(window.clearTimeout(this._clearResponseTimer),this._clearResponseTimer=null),this._getUrlsJob=null},t.prototype.getMaxBitrate=function(){return this._maxBitrate},t.prototype.setMaxBitrate=function(e){if("number"!=typeof e||e<=0)throw new Error("maxBitrate must be > 0.");this._maxBitrate=e},t.prototype.getUrl=function(){var e=this,t=this._maxBitrate,r=this._excludedRenditions,n=new s(function(){e._excludedRenditionsOnLastURLRequest.length===e._excludedRenditions.length?e.clearCache():e._excludedRenditionsOnLastURLRequest=e._excludedRenditions.slice();var n=e._getUrls(),o=n.whenComplete().then(function(e){var n=e.urls,o=e.timeRetrieved,i=null;return h.filter(function(e){return r.indexOf(e)<0}).some(function(e){var r=n.filter(function(t){return t.rendition===e}).map(function(e){return{url:e.url,bitrate:e.bitrate}}),a=u(r.sort(function(e,t){return t.bitrate-e.bitrate}),function(e){return e.bitrate<=t});return!!a&&(i={url:a.url,rendition:e,bitrate:a.bitrate,timeRetrieved:o},!0)}),i});return{result:o,abort:function(){return n.abort()}}});return n.run()},t.prototype._getUrls=function(){var e=this;return this._getUrlsJob||(this._getUrlsJob=new s(function(){var t=o.helpers.deferred.buildDeferred(),r=null,n=c.execute(function(){var n=e._requestAuthorization?{Authorization:e._requestAuthorization}:{},o=e._endpointBaseUrl+"i1/tracks/"+encodeURI(e._trackId+"")+"/streams?client_id="+encodeURIComponent(e._clientId);e._encryptedStreamsEnabled&&(o+="&with_encrypted_streams=true"),e._secretToken&&(o+="&secret_token="+encodeURI(e._secretToken)),r=e._loader.request({url:o,headers:n});var a=r.getResponse().then(function(e){if(!e)throw new i.RequestError(null); -if(200!==e.statusCode)throw new i.RequestError(e.statusCode);if(!e.data)throw new Error("Response contained no data.");var t=l.now(),r=JSON.parse(e.data),n=[];return Object.keys(r).map(function(e){var t=e.split("_"),o=t[0],i=t[1],a=t[2],s=parseInt(a,10);if(o&&i&&!isNaN(s)){var l=u(h,function(e){return e.scProtocol===o&&e.scFormat===i});l&&n.push({rendition:l,bitrate:s,url:r[e]})}}),{urls:n,timeRetrieved:t}});a.then(t.resolve,t.reject)});return{result:t.promise,abort:function(){n.abort(),r&&r.abort()}}}),this._clearResponseTimer=window.setTimeout(function(){e._clearResponseTimer=null,e._getUrlsJob=null},p)),this._getUrlsJob.run()},t}(i.BaseStreamUrlRetriever);t.StreamUrlRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){if(void 0===t&&(t=6e4),this._limit=e,this._period=t,this._jobs=[],this._jobsRunInPeriod=0,e<=0)throw new Error("limit must be > 0.");if(t<=0)throw new Error("period must be > 0.")}return e.prototype.execute=function(e){var t=this,r={job:e};return this._jobs.push(r),this._executeNextJob(),{abort:function(){var e=t._jobs.indexOf(r);e>=0&&t._jobs.splice(e,1)}}},e.prototype._executeNextJob=function(){var e=this;if(this._jobsRunInPeriod=3){var t=parseInt(e[1],10),r=parseInt(e[2],10);if(!isNaN(t)&&!isNaN(r))return{major:t,minor:r}}return null}function i(){return u}Object.defineProperty(t,"__esModule",{value:!0});var a="undefined"!=typeof navigator?navigator.userAgent:"",s=!/chrome|opera/i.test(a)&&/safari/i.test(a),u=a.indexOf("MSIE ")>=0||a.indexOf("Trident/")>=0,l=/version\/(\d+)\.(\d+)/i;t.isSafari=n,t.getSafariVersion=o,t.isIE=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this._counter=0,this._onExit=e,this._onEnter=t||null}return e.prototype.enter=function(e){this._counter++,1===this._counter&&this._onEnter&&(this._enterReturnVal=this._onEnter());try{return e?e(this._enterReturnVal):void 0}finally{this._counter--,0===this._counter&&this._onExit(this._enterReturnVal)}},e}();t.OnExit=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10);t.Promise=n.Promise},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r){this.url=e,this.protocol=t,this.format=r}return e.prototype.getUrl=function(){return this.url},e.prototype.getProtocol=function(){return this.protocol},e.prototype.getFormat=function(){return this.format},e}();t.Descriptor=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(11),i=r(12),a=r(26),s=r(13),u=r(4),l=r(0);!function(e){e.PlayerError=u.PlayerError,e.PlayerFatalError=l.PlayerFatalError,e.DependencyError=o.DependencyError,e.NotSupportedError=i.NotSupportedError,e.URLUpdateError=a.URLUpdateError,e.ProxyProvidedPlayerFatalError=s.ProxyProvidedPlayerFatalError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(1),i=r(14),a=r(29),s=r(17),u=r(5),l=r(27),d=r(6),c=r(18),h=r(15),p=r(28),f=r(16),_=r(30);!function(e){e.OnExit=s.OnExit,e.find=u.find,e.Promise=c.Promise,e.always=h.always,e.compact=p.compact;var t;!function(e){e.buildCache=l.buildCache}(t=e.cache||(e.cache={}));var r;!function(e){e.buildDeferred=o.buildDeferred}(r=e.deferred||(e.deferred={}));var n;!function(e){e.getExtension=_.getExtension,e.buildAbsoluteUrl=_.buildAbsoluteUrl}(n=e.url||(e.url={}));var g;!function(e){e.AbortableJob=i.AbortableJob,e.abortedError=i.abortedError}(g=e.abortableJob||(e.abortableJob={}));var y;!function(e){e.noMoreAttemptsError=a.noMoreAttemptsError,e.retry=a.retry,e.buildExponentialDelayCalculator=a.buildExponentialDelayCalculator}(y=e.retry||(e.retry={}));var v;!function(e){e.isSafari=f.isSafari,e.getSafariVersion=f.getSafariVersion,e.isIE=f.isIE}(v=e.browser||(e.browser={}));var m;!function(e){e.now=d.now}(m=e.time||(e.time={}))}(n=t.helpers||(t.helpers={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(2),i=function(){function e(){this._aborted=!1,this._requestStarted=!1,this._response=null,this._responseDeferred=n.buildDeferred(),this._requestStartedDeferred=n.buildDeferred(),this._onRequestStart=new o.EventDispatcher,this.onRequestStart=this._onRequestStart.getHandle(),this.whenRequestStarted=this._requestStartedDeferred.promise}return e.prototype.getResponse=function(){return this._responseDeferred.promise},e.prototype.hasRequestStarted=function(){return this._requestStarted},e.prototype.abort=function(){if(!this._aborted){if(this._aborted=!0,this._response)throw new Error("Already have a response.");this._abort(),this._responseDeferred.reject(new Error("Aborted.")),this._requestStarted||this._requestStartedDeferred.reject(new Error("Aborted."))}},e.prototype._provideResponse=function(e){if(this._aborted)throw new Error("Response aborted.");if(this._response)throw new Error("Response already provided.");if(e instanceof Error)this._aborted=!0,this._responseDeferred.reject(e);else{if(!this._requestStarted)throw new Error("Request hasn't started yet.");this._response=e,this._responseDeferred.resolve(e)}},e.prototype._signalRequestStart=function(){if(this._aborted)throw new Error("Response aborted.");if(this._requestStarted)throw new Error("Request already started.");this._requestStarted=!0,this._requestStartedDeferred.resolve(void 0),this._onRequestStart.dispatch(void 0)},e}();t.LoaderRequest=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=r(3),a=r(8),s=r(13),u=function(e){function t(t){var r=e.call(this,t)||this;return r._onPlayerProvided=new o.EventDispatcher,r._onPlayerRemoved=new o.EventDispatcher,r._shouldPassThroughFatalErrors=!!t.shouldPassThroughFatalErrors,r.onPlayerProvided=r._onPlayerProvided.getHandle(),r.onPlayerRemoved=r._onPlayerRemoved.getHandle(),r._logger=i.prefixLogger(r._logger,"ProxyPlayer"),r}return n(t,e),t.prototype.providePlayer=function(e,t){void 0===t&&(t={syncPosition:!0,syncVolume:!0}),this._providePlayer(e,t),this._onPlayerProvided.dispatch(e)},t.prototype.removePlayer=function(){var e=this._getPlayer();if(!e)throw new Error("There is no player to remove.");this._removePlayer(),this._onPlayerRemoved.dispatch(e)},t.prototype.setInitialDuration=function(e){this._setInitialDuration(e)},t.prototype.getPlayer=function(){return this._getPlayer()},t.prototype._handleFatalError=function(e){this._shouldPassThroughFatalErrors?this._triggerError(e):this._triggerError(new s.ProxyProvidedPlayerFatalError(e))},t}(a.ProxyPlayerBase);t.ProxyPlayer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){if(this.start=e,this.duration=t,t<0)throw new RangeError("Duration must be >= 0.");this.end=e+t}return e.prototype.containsTime=function(e){return this.start<=e&&this.end>e},e}();t.TimeRange=n},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(e){if(d===setTimeout)return setTimeout(e,0);if((d===r||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function i(e){if(c===clearTimeout)return clearTimeout(e);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function a(){_&&p&&(_=!1,p.length?f=p.concat(f):g=-1,f.length&&s())}function s(){if(!_){var e=o(a);_=!0;for(var t=f.length;t;){for(p=f,f=[];++g1)for(var r=1;r= 0.")):null===o?i.reject(t.noMoreAttemptsError):l=n(function(){l=null,d()},o)}}),u.onError(function(e){u=null,i.reject(e)})};return d(),{result:i.promise,abort:function(){u&&u.abort(),l&&o(l)}}});return s.run()}function o(e){var t=void 0===e?{}:e,r=t.timeBase,n=void 0===r?500:r,o=t.threshold,i=void 0===o?3:o,a=t.delayCap,s=void 0===a?45e3:a,u=t.jitter,l=void 0===u?200:u,d=t.maxAttempts,c=void 0===d?null:d;if(n<=0)throw new Error("Time base must be > 0.");if(i<=0)throw new Error("Threshold must be > 0.");if(0===s)throw new Error("Delay cap must be null or > 0.");if(null!==c&&c<1)throw new Error("Max attempts must be >= 1.");return function(e){if(null!==c&&e>=c)return null;var t=e>0?Math.pow(2,e/i-1):0;return Math.min(t*n,s||1/0)+Math.round(Math.random()*l)}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(14),a=r(1);t.noMoreAttemptsError=new Error("No more attempts remaining."),t.retry=n,t.buildExponentialDelayCalculator=o},function(e,t,r){"use strict";function n(e){var t=a.exec(e);return t?t[1].toLowerCase():null}function o(e,t){return i.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}Object.defineProperty(t,"__esModule",{value:!0});var i=r(32),a=/^.*\.([^\.;\?#]*).*$/;t.getExtension=n,t.buildAbsoluteUrl=o},function(e,t,r){"use strict";function n(e){var t=Object.create(null);return Object.keys(e).forEach(function(r){t[r]=e[r]}),t}Object.defineProperty(t,"__esModule",{value:!0});var o=r(17),i=function(){},a=function(){function e(e,t){void 0===t&&(t={});var r=this;this._subscribers=[],this._onExit=new o.OnExit(function(){return r._after()}),this._dead=!1,this._state=n(e),this._initialState=n(e),this._afterUpdate=t.afterUpdate||i,this._afterDispatches=t.afterDispatches||i}return e.prototype.subscribe=function(e,t){var r=this;if(void 0===t&&(t=!0),this._dead){var o=!1;return{retrieve:function(){},remove:function(){return!o&&(o=!0)}}}var i=function(){var o={callback:e,localState:t?n(r._state):r._initialState};return r._subscribers.push(o),{remove:function(){var t=r._subscribers.map(function(e){return e.callback}).indexOf(e);return t>=0&&(r._subscribers.splice(t,1),!0)},retrieve:function(){r._updateSubscriber(o)}}};return t?i():this._onExit.enter(i)},e.prototype.subscribeIndividual=function(e,t,r){return this.subscribe(function(r){var n=r[e];void 0!==n&&t(n)},r)},e.prototype.getHandle=function(){return{subscribe:this.subscribe.bind(this)}},e.prototype.getIndividualHandle=function(e){var t=this;return{subscribe:function(r){return t.subscribeIndividual(e,r)}}},e.prototype.update=function(e){var t=this;return this._onExit.enter(function(){return e(t._state)})},e.prototype.getState=function(){return this._state},e.prototype.kill=function(){var e=this;this._dead||this._onExit.enter(function(){e._dead=!0})},e.prototype._after=function(){var e=this;try{this._afterUpdate(this._state)}finally{this._subscribers.forEach(function(t){return e._updateSubscriber(t)}),this._afterDispatches(this._state)}this._dead&&this._subscribers.splice(0)},e.prototype._updateSubscriber=function(e){var t=this._calculateDiff(e.localState);if(Object.keys(t).length){e.localState=n(this._state);try{e.callback(t,e.localState)}catch(e){window.setTimeout(function(){throw e},0)}}},e.prototype._calculateDiff=function(e){var t=this,r=Object.create(null);return Object.keys(this._state).forEach(function(n){var o=t._state[n];o!==e[n]&&(r[n]=o)}),r},e}();t.StateManager=a},function(e,t,r){!function(t){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),t=t.trim(),!t){if(!r.alwaysNormalize)return e;var o=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return o.path=a.normalizePath(o.path),a.buildURLFromParts(o)}var i=this.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):t;var s=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var l={scheme:s.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(l.netLoc=s.netLoc,"/"!==i.path[0]))if(i.path){var d=s.path,c=d.substring(0,d.lastIndexOf("/")+1)+i.path;l.path=a.normalizePath(c)}else l.path=s.path,i.params||(l.params=s.params,i.query||(l.query=s.query));return null===l.path&&(l.path=r.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(l)},parseURL:function(e){var t=r.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(o,"");e.length!==(e=e.replace(i,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a}(this)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.4.1",t.buildNumber=844;var n=r(2),o=r(22),i=r(3),a=r(23);t.ProxyPlayer=a.ProxyPlayer;var s=r(8);t.ProxyPlayerBase=s.ProxyPlayerBase;var u=r(20);t.errors=u.errors;var l=r(21);t.helpers=l.helpers;var d=r(7);t.BasePlayer=d.BasePlayer;var c=r(19);t.Descriptor=c.Descriptor;var h=r(9);t.State=h.State;var p=r(24);t.TimeRange=p.TimeRange;var f;!function(e){e.EventDispatcher=n.EventDispatcher}(f=t.eventDispatcher||(t.eventDispatcher={}));var _;!function(e){e.LoaderRequest=o.LoaderRequest}(_=t.loader||(t.loader={}));var g;!function(e){e.noOpLogger=i.noOpLogger,e.consoleLogger=i.consoleLogger,e.prefixLogger=i.prefixLogger,e.cloneLogger=i.cloneLogger}(g=t.logger||(t.logger={}))}])})},function(e,t,r){!function(t,n){e.exports=n(r(2),r(4))}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=36)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.getCode=function(){return"GENERIC"},e}();t.RetrievalError=n},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.MSE_ERROR"},t}(o.errors.PlayerFatalError);t.MSEError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(t){var r=e.call(this)||this;return r._statusCode=t,r}return n(t,e),t.prototype.getStatusCode=function(){return this._statusCode},t.prototype.getCode=function(){return"UNACCEPTABLE_RESPONSE_STATUS_CODE"},t}(o.RetrievalError);t.UnacceptableResponseStatusCodeError=i},function(e,r){e.exports=t},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=function(e){function t(t){return e.call(this,"An error occurred trying to append to the buffer.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.APPEND_ERROR"},t}(o.MSEError);t.AppendError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=function(e){function t(t){return e.call(this,"An error occurred trying to initialize the buffer.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.INITIALIZE_ERROR"},t}(o.MSEError);t.InitializeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"A format could not be determined.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.NO_FORMAT_DETERMINED_ERROR"},t}(o.errors.NotSupportedError);t.NoFormatDeterminedError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"A transmuxer could not be found.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.NO_TRANSMUXER_ERROR"},t}(o.errors.NotSupportedError);t.NoTransmuxerError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){var r=e.call(this,"An error occurred when trying to retrieve a segment.",t)||this;return r._internalRetrievalError=t,r}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.RETRIEVAL_ERROR."+this._internalRetrievalError.getCode()},t}(o.errors.PlayerError);t.RetrievalError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"The playlist type is not supported.")||this}return n(t,e),t.prototype.getCode=function(){return"HLS_MSE_PLAYER.UNSUPPORTED_PLAYLIST_TYPE_ERROR"},t}(o.errors.PlayerFatalError);t.UnsupportedPlaylistTypeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"NO_DECRYPTOR"},t}(o.RetrievalError);t.NoDecryptorError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]); +};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(t){var r=e.call(this)||this;return r._details=t,r}return n(t,e),t.prototype.getDetails=function(){return this._details},t.prototype.getCode=function(){return"PLAYLIST_PARSE"},t}(o.RetrievalError);t.PlaylistParseError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getCode=function(){return"UNSUPPORTED_ENCRYPTION_ERROR"},t}(o.RetrievalError);t.UnsupportedEncryptionError=i},function(e,t,r){"use strict";function n(e){var t=e.reduce(function(e,t){return e+t.length},0),r=new Uint8Array(t),n=0;return e.forEach(function(e){r.set(e,n),n+=e.length}),r}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=r(19),a=r(20),s=o.helpers.Promise,u={rate:44100,id:3},l=16,d=2,c=u.rate,h=2,p=8;t.MP3ToMP4={getInputFormat:function(){return{mimeType:"audio/mpeg",audioCodec:{id:"mp3"}}},getOutputFormat:function(){return{mimeType:"audio/mp4",audioCodec:{id:"mp3"}}},transmux:function(e){return new s(function(t,r){function o(e){f||(f=!0,r(e))}function s(e){f||t(e)}var f=!1;try{var _=[],g=new i.MP3Parser,y=new a.MP4Mux({audioTrackId:0,videoTrackId:-1,tracks:[{codecId:h,channels:d,samplerate:u.rate,samplesize:l,timescale:c}]});if(y.ondata=function(e){return _.push(e)},g.onFrame=function(e){try{var t=new Uint8Array(e.length+1),r=h<<4;r|=u.id<<2,r|=(16===l?1:0)<<1,r|=2===d?1:0,t[0]=r,t.set(e,1);var n=0;y.pushPacket(p,t,n)}catch(e){o(e)}},g.push(e),g.close(),y.flush(),0===_.length)o(new Error("There was no output."));else{var v=_.shift();v?s({initData:v,data:n(_)}):o(new Error("No init data."))}}catch(e){o(e)}})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(5),i=r(6),a=r(2),s=r(7),u=r(8),l=r(9),d=r(10);!function(e){e.AppendError=o.AppendError,e.InitializeError=i.InitializeError,e.MSEError=a.MSEError,e.NoFormatDeterminedError=s.NoFormatDeterminedError,e.NoTransmuxerError=u.NoTransmuxerError,e.RetrievalError=l.RetrievalError,e.UnsupportedPlaylistTypeError=d.UnsupportedPlaylistTypeError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";function n(e){return void 0!==e.mimeType}function o(e,t){void 0===t&&(t={});var r=e.mimeType||t.mimeType,n=e.audioCodec||t.audioCodec,o=e.videoCodec||t.videoCodec,i=P([n,o]),a=i.length>0?'; codecs="'+i.map(function(e){return e.id}).join(",")+'"':"";return r+a}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=r(4),u=r(35),l=r(14),d=r(28),c=r(32),h=r(30),p=r(29),f=r(10),_=r(5),g=r(6),y=r(9),v=r(8),m=r(7),E=r(1),b=a.helpers.find,w=a.helpers.Promise,P=a.helpers.compact,S=a.helpers.time.now,R=a.helpers.deferred.buildDeferred,T=s.helpers.timeRanges.normalizeTimeRanges,A=a.errors.DependencyError,M=a.errors.PlayerFatalError,D=a.errors.URLUpdateError,x=a.eventDispatcher.EventDispatcher,k=a.logger.prefixLogger,O=a.helpers.abortableJob.abortedError,C=a.helpers.browser.getSafariVersion(),L=a.helpers.browser.isSafari(),I=3e4,N=1e8,F=400,U=50,j=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n._onPlaylistRequestQueued=new x,n._onPlaylistRequestStart=new x,n._onPlaylistRetrieved=new x,n._onPlaylistRequestFailed=new x,n._onKeyRequestQueued=new x,n._onKeyRequestStart=new x,n._onKeyRetrieved=new x,n._onKeyRequestFailed=new x,n._onPlaylistParseStart=new x,n._onPlaylistParseEnd=new x,n._onSegmentRequestQueued=new x,n._onSegmentRequestStart=new x,n._onSegmentRetrieved=new x,n._onSegmentRequestFailed=new x,n._onSegmentTransmuxStart=new x,n._onSegmentTransmuxEnd=new x,n._onSegmentDecryptionStart=new x,n._onSegmentDecryptionEnd=new x,n._onSegmentReady=new x,n._onSegmentAppendQueued=new x,n._onSegmentAppendEnd=new x,n._playlist=null,n._playlistSegmentRetriever=null,n._initialPlaylistRetrieveCompleted=!1,n._mse=null,n._simpleMSE=null,n._retrieveDurationDeferred=R(),n._html5PlayerReady=!1,n._startPositionOffset=0,n._transmuxerAndMSEType=null,n._lastSegmentAppended=null,n._maxBufferLength=null,n._cacheSize=null,n._onFirstSegmentRetrieved=null,n._seekAttemptTimer=null,n._seekMetadataEventHandle=null,n._playlistDuration=null,n._logger=k(n._logger,"HLSMSEPlayer"),n.onPlaylistRequestQueued=n._onPlaylistRequestQueued.getHandle(),n.onPlaylistRequestStart=n._onPlaylistRequestStart.getHandle(),n.onPlaylistRetrieved=n._onPlaylistRetrieved.getHandle(),n.onPlaylistRequestFailed=n._onPlaylistRequestFailed.getHandle(),n.onKeyRequestQueued=n._onKeyRequestQueued.getHandle(),n.onKeyRequestStart=n._onKeyRequestStart.getHandle(),n.onKeyRetrieved=n._onKeyRetrieved.getHandle(),n.onKeyRequestFailed=n._onKeyRequestFailed.getHandle(),n.onPlaylistParseStart=n._onPlaylistParseStart.getHandle(),n.onPlaylistParseEnd=n._onPlaylistParseEnd.getHandle(),n.onSegmentRequestQueued=n._onSegmentRequestQueued.getHandle(),n.onSegmentRequestStart=n._onSegmentRequestStart.getHandle(),n.onSegmentRetrieved=n._onSegmentRetrieved.getHandle(),n.onSegmentRequestFailed=n._onSegmentRequestFailed.getHandle(),n.onSegmentTransmuxStart=n._onSegmentTransmuxStart.getHandle(),n.onSegmentTransmuxEnd=n._onSegmentTransmuxEnd.getHandle(),n.onSegmentDecryptionStart=n._onSegmentDecryptionStart.getHandle(),n.onSegmentDecryptionEnd=n._onSegmentDecryptionEnd.getHandle(),n.onSegmentReady=n._onSegmentReady.getHandle(),n.onSegmentAppendQueued=n._onSegmentAppendQueued.getHandle(),n.onSegmentAppendEnd=n._onSegmentAppendEnd.getHandle(),n.__descriptor=t,n.__playerDependencies=r,n._url=t.getUrl(),n}return i(t,e),t.prototype.getBufferedTimeRanges=function(){var e=this._playlistSegmentRetriever;return e?T(e.getSegmentsWithData().map(function(e){return e.segment.getTimeRange()})):[]},t.prototype.getMaxBufferLength=function(){return this._maxBufferLength},t.prototype.getBufferController=function(){var e=this;return{setMaxBufferLength:function(t){if(t<0)throw new Error("Max buffer length cannot be < 0.");e._logger.debug("Updating max buffer length.",t),e._maxBufferLength=t,e._playlistSegmentRetriever?e._playlistSegmentRetriever.updateMaxBufferLength(t):e._logger.debug("Cannot update right now. Playlist segment retriever doesn't exist.")}}},t.prototype.getUrlController=function(){var e=this;return{updateUrl:function(t){e._logger.debug("Updating URL.",t),e._url=t;var r=e._playlist;return r?(e._playlistRetrieveJob&&(e._playlistRetrieveJob.abort(),e._playlistRetrieveJob=null,e._logger.debug("Aborted playlist retrieve job.")),e._playlistSegmentRetriever&&(e._playlistSegmentRetriever.switchPlaylist(null),e._logger.debug("Removed current URL.")),e._playlist=null,void e._retrievePlaylist()):void e._logger.debug("Cannot update right now. Playlist doesn't exist yet.")}}},t.prototype.getMemoryCacheMaxSize=function(){return null!==this._cacheSize?this._cacheSize:N},t.prototype.getMemoryCacheUsage=function(){return this._playlistSegmentRetriever?this._playlistSegmentRetriever.getCacheUsage():0},t.prototype.getMemoryCacheController=function(){var e=this;return{setMaxCacheSize:function(t){if(t<0)throw new Error("Max size cannot be < 0.");e._logger.debug("Updating maximum cache size.",t),e._cacheSize=t,e._playlistSegmentRetriever&&e._playlistSegmentRetriever.updateCacheSize(t)}}},t.prototype._canPlay=function(){var t=this;return d.MSE.isSupported()?e.prototype._canPlay.call(this).then(function(e){if(e!==!0)return w.resolve(e);var r=t.__playerDependencies.expectedSegmentFormat;if(!r||!n(r))return t._logger.debug("Format could not be determined."),w.resolve(new m.NoFormatDeterminedError);var i=t._findTransmuxer(r);if(!i)return t._logger.debug("No transmuxer found."),w.resolve(new v.NoTransmuxerError);var a=i.getOutputFormat(),s=r;return t._transmuxerAndMSEType={transmuxer:i,mseType:o(a,s)},w.resolve(!0)}):(this._logger.debug("MSE not supported."),w.resolve(!1))},t.prototype._canPlayProtocol=function(e){return"hls"===e.name},t.prototype._canPlayType=function(e){return"application/x-mpegURL"===e},t.prototype._retrieveDuration=function(){return this._retrieveDurationDeferred.promise},t.prototype._signalReady=function(){this._html5PlayerReady=!0,this._initialPlaylistRetrieveCompleted&&e.prototype._signalReady.call(this)},t.prototype._initialize=function(){var t=this.__playerDependencies;if(null===this._maxBufferLength)if(void 0!==t.maxBufferLength){if(t.maxBufferLength<0)return void this._triggerError(new A("maxBufferLength cannot be < 0."));this._maxBufferLength=t.maxBufferLength}else this._maxBufferLength=I;if(this._logger.debug("Initialized max buffer length.",this._maxBufferLength),null===this._cacheSize)if(void 0!==t.memoryCacheSize){if(t.memoryCacheSize<0)return void this._triggerError(new A("memoryCacheSize cannot be < 0."));this._cacheSize=t.memoryCacheSize}else this._cacheSize=N;this._logger.debug("Initialized cache size.",this._cacheSize),e.prototype._initialize.call(this),this._retrievePlaylist()},t.prototype._initMediaElement=function(t,r){if(this._simpleMSE&&(this._simpleMSE.kill(),this._simpleMSE=null,this._logger.debug("Killed SimpleMSE.")),this._mse&&(this._mse.kill(),this._mse=null,this._logger.debug("Killed MSE.")),null!==this._seekAttemptTimer&&(window.clearTimeout(this._seekAttemptTimer),this._seekAttemptTimer=null,this._logger.debug("Cancelled seek attempt timer.")),this._onFirstSegmentRetrieved=null,this._seekMetadataEventHandle&&(this._seekMetadataEventHandle.remove(),this._seekMetadataEventHandle=null),null===r)e.prototype._initMediaElement.call(this,t,null);else{this._initMSE();var n=this._mse.getUrl();this._logger.debug("Setting MSE url.",n),e.prototype._initMediaElement.call(this,t,n)}},t.prototype._handleEndedEvent=function(){},t.prototype._shouldBeEnded=function(){if(e.prototype._shouldBeEnded.call(this))return!0;if(!this.getMediaElement())return!1;var t=this._duration;return this._stallDetected&&null!==t&&this._getTruePosition()>=t-F},t.prototype._getTruePosition=function(){var e=this.getMediaElement();if(!e)throw new Error("Media element should exist.");return this._startPositionOffset+this._getMediaElementPosition()},t.prototype._handleSeekChange=function(t){this._playlistSegmentRetriever&&(this._logger.debug("Explicitly updating playlist segment retriever, as seek requested."),this._playlistSegmentRetriever.update()),e.prototype._handleSeekChange.call(this,t)},t.prototype._performSeek=function(t,r){var n=this,o=this,i=o._simpleMSE,a=o._mse,s=this.getMediaElement();if(!i)throw new Error("SimpleMSE should exist.");if(!a)throw new Error("MSE should exist.");if(!s)throw new Error("Media element should exist.");var u=!s.paused;null!==this._seekAttemptTimer&&(window.clearTimeout(this._seekAttemptTimer),this._seekAttemptTimer=null,this._logger.debug("Cancelled previous seek attempt timer.")),this._seekMetadataEventHandle&&(this._seekMetadataEventHandle.remove(),this._seekMetadataEventHandle=null,this._logger.debug("Removed previous loaded metadata event handler.")),i.kill(),a.kill(),this._logger.debug("SimpleMSE and MSE destroyed."),this._startPositionOffset=t;var l=null;this._onFirstSegmentRetrieved=function(e){return l=e},this._logger.debug("Initializing MSE and SimpleMSE for new position."),this._initMSE();var d=this._mse.getUrl();if(this._logger.debug("Updated media element MSE src.",d),e.prototype._initMediaElement.call(this,s,d),u){this._logger.debug("Calling play() on media element as it was playing previously.");var c=s.play();c&&c.catch&&c.catch(function(e){"AbortError"!==e.name&&(n._logger.error("Unexpected play() error.",e),n._triggerError(new M("Exception from calling play() after seek.",e)))})}var h=function(e){L&&e>>8^255&f^99,e[c]=f,t[f]=c;var _=d[c],g=d[_],y=d[g],v=257*d[f]^16843008*f;r[c]=v<<24|v>>>8,n[c]=v<<16|v>>>16,o[c]=v<<8|v>>>24,i[c]=v,v=16843009*y^65537*g^257*_^16843008*c,a[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,u[f]=v<<8|v>>>24,l[f]=v,c?(c=_^d[d[d[y^_]]],h^=d[d[h]]):c=h=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var n,o,i=this.keySize+6,a=this.invKeySchedule,s=this.invSBox,u=this.invSubMix[0],l=this.invSubMix[1],d=this.invSubMix[2],c=this.invSubMix[3],h=this.uint8ArrayToUint32Array_(r),p=h[0],f=h[1],_=h[2],g=h[3],y=new Int32Array(e),v=new Int32Array(y.length),m=void 0,E=void 0,b=void 0,w=void 0,P=void 0,S=void 0,R=void 0,T=void 0,A=void 0,M=void 0,D=void 0,x=void 0;t>>24]^l[S>>16&255]^d[R>>8&255]^c[255&T]^a[n],E=u[S>>>24]^l[R>>16&255]^d[T>>8&255]^c[255&P]^a[n+1],b=u[R>>>24]^l[T>>16&255]^d[P>>8&255]^c[255&S]^a[n+2],w=u[T>>>24]^l[P>>16&255]^d[S>>8&255]^c[255&R]^a[n+3],P=m,S=E,R=b,T=w,n+=4;m=s[P>>>24]<<24^s[S>>16&255]<<16^s[R>>8&255]<<8^s[255&T]^a[n],E=s[S>>>24]<<24^s[R>>16&255]<<16^s[T>>8&255]<<8^s[255&P]^a[n+1],b=s[R>>>24]<<24^s[T>>16&255]<<16^s[P>>8&255]<<8^s[255&S]^a[n+2],w=s[T>>>24]<<24^s[P>>16&255]<<16^s[S>>8&255]<<8^s[255&R]^a[n+3],n+=3,v[t]=this.networkToHostOrderSwap(m^p),v[t+1]=this.networkToHostOrderSwap(w^f),v[t+2]=this.networkToHostOrderSwap(b^_),v[t+3]=this.networkToHostOrderSwap(E^g),p=A,f=M,_=D,g=x,t+=4}return v.buffer}},{key:"destroy",value:function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0}}]),e}()},function(e,t,r){"use strict";function n(){this.buffer=null,this.bufferSize=0}t.__esModule=!0,t.MP3Parser=n;var o=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],i=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3];n.prototype.push=function(e){var t;if(this.bufferSize>0){var r=e.length+this.bufferSize;if(!this.buffer||this.buffer.length0&&n.set(this.buffer.subarray(0,this.bufferSize)),this.buffer=n}this.buffer.set(e,this.bufferSize),this.bufferSize=r,e=this.buffer,t=r}else t=e.length;for(var o,i=0;i0;)i+=o;var a=t-i;a>0&&(!this.buffer||this.buffer.lengthr)return-1;if(255===e[t]||224===(224&e[t+1])){if(t+24>r)return-1;var n=e[t+1]>>3&3,a=e[t+1]>>1&3,s=e[t+2]>>4&15,u=e[t+2]>>2&3,l=!!(2&e[t+2]);if(1!==n&&0!==s&&15!==s&&3!==u){var d=3===n?3-a:3===a?3:4,c=1e3*o[14*d+s-1],h=3===n?0:2===n?1:2,p=i[3*h+u],f=l?1:0,_=3===a?(3===n?12:6)*c/p+f<<2:(3===n?144:72)*c/p+f|0;return t+_>r?-1:(this.onFrame&&this.onFrame(e.subarray(t,t+_)),_)}}for(var g=t+2;g0&&this.onNoise&&this.onNoise(this.buffer.subarray(0,this.bufferSize)),this.buffer=null,this.bufferSize=0,this.onClose&&this.onClose()}},function(e,t,r){"use strict";t.__esModule=!0;var n,o,i=function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)};!function(e){var t;!function(e){function t(e){for(var t=new Uint8Array(4*e.length),r=0,n=0,o=e.length;n>>24&3,t[r++]=128|i>>>18&63,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|63&i):0!==(4294901760&i)?(t[r++]=240|i>>>18&7,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|63&i):0!==(4294965248&i)?(t[r++]=224|i>>>12&15,t[r++]=128|i>>>6&63,t[r++]=128|63&i):(t[r++]=192|i>>>6&31,t[r++]=128|63&i)}}return t.subarray(0,r)}function r(e){for(var t=0,r="";t>1|128;if((n&a)===o)break;o=o>>1|128,--i}while(i>=0);if(i<=0)throw new Error("Invalid UTF8 character");for(var s=n&(1<=i;--u){var l=e[t++];if(128!==(192&l))throw new Error("Invalid UTF8 character sequence");s=s<<6|63&l}r+=s>=65536?String.fromCharCode(s-65536>>10&1023|55296,1023&s|56320):String.fromCharCode(s)}}return r}e.utf8decode=t,e.utf8encode=r}(t=e.StringUtilities||(e.StringUtilities={}))}(o||(o={})),function(e){var t;!function(e){function t(e){for(var t=e.length>>1,r=new Uint8Array(t),n=0;n>4,c=o>>2&3,h=2&o?16:8,p=1&o?2:1;switch(r++,i){case d:var f=e[r++];n=f,t=1024;break;case l:var _=e[r+1]>>3&3,g=e[r+1]>>1&3;t=1===g?3===_?1152:576:3===g?384:1152}return{codecDescription:u[i],codecId:i,data:e.subarray(r),rate:s[c],size:h,channels:p,samples:t,packetType:n}}function n(e){var t=0,r=e[t]>>4,n=15&e[t];t++;var o={frameType:r,codecId:n,codecDescription:h[n]};switch(n){case f:var i=e[t++];o.packetType=i,o.compositionTime=(e[t]<<24|e[t+1]<<16|e[t+2]<<8)>>8,t+=3;break;case p:o.packetType=_.NALU,o.horizontalOffset=e[t]>>4&15,o.verticalOffset=15&e[t],o.compositionTime=0,t++}return o.data=e.subarray(t),o}function o(e){var t,r,n=[],o=-1,i=-1,a=+e.asGetPublicProperty("duration"),s=e.asGetPublicProperty("audiocodecid");switch(s){case l:case"mp3":t="mp3",r=l;break;case d:case"mp4a":t="mp4a",r=d;break;default:if(!isNaN(s))throw new Error("Unsupported audio codec: "+s);t=null,r=-1}var u,c,h=e.asGetPublicProperty("videocodecid");switch(h){case p:case"vp6f":u="vp6f",c=p;break;case f:case"avc1":u="avc1",c=f;break;default:if(!isNaN(h))throw new Error("Unsupported video codec: "+h);u=null,c=-1}var _=null===t?null:{codecDescription:t,codecId:r,language:"und",timescale:+e.asGetPublicProperty("audiosamplerate")||44100,samplerate:+e.asGetPublicProperty("audiosamplerate")||44100,channels:+e.asGetPublicProperty("audiochannels")||2,samplesize:16},g=null===u?null:{codecDescription:u,codecId:c,language:"und",timescale:6e4,framerate:+e.asGetPublicProperty("videoframerate")||+e.asGetPublicProperty("framerate"),width:+e.asGetPublicProperty("width"),height:+e.asGetPublicProperty("height")},y=e.asGetPublicProperty("trackinfo");if(y)for(var v=0;v=0&&t.push({tracks:[e.tracks[e.audioTrackId]],duration:e.duration,audioTrackId:0,videoTrackId:-1}),e.videoTrackId>=0&&t.push({tracks:[e.tracks[e.videoTrackId]],duration:e.duration,audioTrackId:-1,videoTrackId:0}),t}var a,s=[5500,11025,22050,44100],u=["PCM","ADPCM","MP3","PCM le","Nellymouser16","Nellymouser8","Nellymouser","G.711 A-law","G.711 mu-law",null,"AAC","Speex","MP3 8khz"],l=2,d=10;!function(e){e[e.HEADER=0]="HEADER",e[e.RAW=1]="RAW"}(a||(a={}));var c,h=[null,"JPEG","Sorenson","Screen","VP6","VP6 alpha","Screen2","AVC"],p=4,f=7;!function(e){e[e.KEY=1]="KEY",e[e.INNER=2]="INNER",e[e.DISPOSABLE=3]="DISPOSABLE",e[e.GENERATED=4]="GENERATED",e[e.INFO=5]="INFO"; +}(c||(c={}));var _;!function(e){e[e.HEADER=0]="HEADER",e[e.NALU=1]="NALU",e[e.END=2]="END"}(_||(_={}));var g,y=8,v=9,m=50,E=!0;!function(e){e[e.CAN_GENERATE_HEADER=0]="CAN_GENERATE_HEADER",e[e.NEED_HEADER_DATA=1]="NEED_HEADER_DATA",e[e.MAIN_PACKETS=2]="MAIN_PACKETS"}(g||(g={}));var b=function(){function o(e){var t=this;this.oncodecinfo=function(e){},this.ondata=function(e){throw new Error("MP4Mux.ondata is not set")},this.metadata=e,this.trackStates=this.metadata.tracks.map(function(e,r){var n={trackId:r+1,trackInfo:e,cachedDuration:0,samplesProcessed:0,initializationData:[]};return t.metadata.audioTrackId===r&&(t.audioTrackState=n),t.metadata.videoTrackId===r&&(t.videoTrackState=n),n},this),this._checkIfNeedHeaderData(),this.filePos=0,this.cachedPackets=[],this.chunkIndex=0}return o.prototype.pushPacket=function(e,t,o){switch(this.state===g.CAN_GENERATE_HEADER&&this._tryGenerateHeader(),e){case y:var i=this.audioTrackState,s=r(t);if(!i||i.trackInfo.codecId!==s.codecId)throw new Error("Unexpected audio packet codec: "+s.codecDescription);switch(s.codecId){default:throw new Error("Unsupported audio codec: "+s.codecDescription);case l:break;case d:if(s.packetType===a.HEADER)return void i.initializationData.push(s.data)}this.cachedPackets.push({packet:s,timestamp:o,trackId:i.trackId});break;case v:var u=this.videoTrackState,c=n(t);if(!u||u.trackInfo.codecId!==c.codecId)throw new Error("Unexpected video packet codec: "+c.codecDescription);switch(c.codecId){default:throw new Error("unsupported video codec: "+c.codecDescription);case p:break;case f:if(c.packetType===_.HEADER)return void u.initializationData.push(c.data)}this.cachedPackets.push({packet:c,timestamp:o,trackId:u.trackId});break;default:throw new Error("unknown packet type: "+e)}this.state===g.NEED_HEADER_DATA&&this._tryGenerateHeader(),this.cachedPackets.length>=m&&this.state===g.MAIN_PACKETS&&this._chunk()},o.prototype.flush=function(){this.cachedPackets.length>0&&this._chunk()},o.prototype._checkIfNeedHeaderData=function(){this.trackStates.some(function(e){return e.trackInfo.codecId===d||e.trackInfo.codecId===f})?this.state=g.NEED_HEADER_DATA:this.state=g.CAN_GENERATE_HEADER},o.prototype._tryGenerateHeader=function(){var r=this.trackStates.every(function(e){switch(e.trackInfo.codecId){case d:case f:return e.initializationData.length>0;default:return!0}});if(r){for(var n=["isom"],o=1,i=1,a=[],s=0;s>3;c.mimeTypeCodec="mp4a.40."+v;break;case l:u=new e.Iso.AudioSampleEntry(".mp3",o,h.channels,h.samplesize,h.samplerate),c.mimeTypeCodec="mp3";break;case f:var m=c.initializationData[0];u=new e.Iso.VideoSampleEntry("avc1",i,h.width,h.height),u.otherBoxes=[new e.Iso.RawTag("avcC",m)];var E=m[1]<<16|m[2]<<8|m[3];c.mimeTypeCodec="avc1."+(16777216|E).toString(16).substr(1),n.push("iso2","avc1","mp41");break;case p:u=new e.Iso.VideoSampleEntry("VP6F",i,h.width,h.height),u.otherBoxes=[new e.Iso.RawTag("glbl",t("00"))],c.mimeTypeCodec="avc1.42001E";break;default:throw new Error("not supported track type")}var b,w=e.Iso.TrackHeaderFlags.TRACK_ENABLED|e.Iso.TrackHeaderFlags.TRACK_IN_MOVIE;c===this.audioTrackState?b=new e.Iso.TrackBox(new e.Iso.TrackHeaderBox(w,c.trackId,-1,0,0,1,s),new e.Iso.MediaBox(new e.Iso.MediaHeaderBox(h.timescale,-1,h.language),new e.Iso.HandlerBox("soun","SoundHandler"),new e.Iso.MediaInformationBox(new e.Iso.SoundMediaHeaderBox,new e.Iso.DataInformationBox(new e.Iso.DataReferenceBox([new e.Iso.DataEntryUrlBox(e.Iso.SELF_CONTAINED_DATA_REFERENCE_FLAG)])),new e.Iso.SampleTableBox(new e.Iso.SampleDescriptionBox([u]),new e.Iso.RawTag("stts",t("0000000000000000")),new e.Iso.RawTag("stsc",t("0000000000000000")),new e.Iso.RawTag("stsz",t("000000000000000000000000")),new e.Iso.RawTag("stco",t("0000000000000000")))))):c===this.videoTrackState&&(b=new e.Iso.TrackBox(new e.Iso.TrackHeaderBox(w,c.trackId,-1,h.width,h.height,0,s),new e.Iso.MediaBox(new e.Iso.MediaHeaderBox(h.timescale,-1,h.language),new e.Iso.HandlerBox("vide","VideoHandler"),new e.Iso.MediaInformationBox(new e.Iso.VideoMediaHeaderBox,new e.Iso.DataInformationBox(new e.Iso.DataReferenceBox([new e.Iso.DataEntryUrlBox(e.Iso.SELF_CONTAINED_DATA_REFERENCE_FLAG)])),new e.Iso.SampleTableBox(new e.Iso.SampleDescriptionBox([u]),new e.Iso.RawTag("stts",t("0000000000000000")),new e.Iso.RawTag("stsc",t("0000000000000000")),new e.Iso.RawTag("stsz",t("000000000000000000000000")),new e.Iso.RawTag("stco",t("0000000000000000"))))))),a.push(b)}var P=new e.Iso.MovieExtendsBox(null,[new e.Iso.TrackExtendsBox(1,1,0,0,0),new e.Iso.TrackExtendsBox(2,1,0,0,0)],null),S=new e.Iso.BoxContainerBox("udat",[new e.Iso.MetaBox(new e.Iso.RawTag("hdlr",t("00000000000000006D6469726170706C000000000000000000")),[new e.Iso.RawTag("ilst",t("00000025A9746F6F0000001D6461746100000001000000004C61766635342E36332E313034"))])]),R=new e.Iso.MovieHeaderBox(1e3,0,this.trackStates.length+1),T=new e.Iso.MovieBox(R,a,P,S),A=new e.Iso.FileTypeBox("isom",512,n),M=A.layout(0),D=T.layout(M),x=new Uint8Array(M+D);A.write(x),T.write(x),this.oncodecinfo(this.trackStates.map(function(e){return e.mimeTypeCodec})),this.ondata(x),this.filePos+=x.length,this.state=g.MAIN_PACKETS}},o.prototype._chunk=function(){var t=this.cachedPackets;if(E&&this.videoTrackState){for(var r=t.length-1,n=this.videoTrackState.trackId;r>0&&(t[r].trackId!==n||t[r].packet.frameType!==c.KEY);)r--;r>0&&(t=t.slice(0,r))}if(0!==t.length){for(var o=[],i=0,a=[],s=[],u=0;u>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function n(e){return e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3)}function a(e){return(e-h)/1e3|0}function s(e){return 65536*e|0}function u(e){return 1073741824*e|0}function l(e){return 256*e|0}function d(e){return(31&e.charCodeAt(0))<<10|(31&e.charCodeAt(1))<<5|31&e.charCodeAt(2)}var c=o.StringUtilities.utf8decode,h=-20828448e5,p=[1,0,0,0,1,0,0,0,1],f=[0,0,0],_=function(){function e(e,t){this.boxtype=e,"uuid"===e&&(this.userType=t)}return e.prototype.layout=function(e){this.offset=e;var t=8;return this.userType&&(t+=16),this.size=t,t},e.prototype.write=function(e){return r(e,this.offset,this.size),r(e,this.offset+4,n(this.boxtype)),this.userType?(e.set(this.userType,this.offset+8),24):8},e.prototype.toUint8Array=function(){var e=this.layout(0),t=new Uint8Array(e);return this.write(t),t},e}();e.Box=_;var g=function(e){function t(t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var o=e.call(this,t)||this;return o.version=r,o.flags=n,o}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.version<<24|this.flags),n+4},t}(_);e.FullBox=g;var y=function(e){function t(t,r,n){var o=e.call(this,"ftype")||this;return o.majorBrand=t,o.minorVersion=r,o.compatibleBrands=n,o}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4*(2+this.compatibleBrands.length),this.size},t.prototype.write=function(t){var o=this,i=e.prototype.write.call(this,t);return r(t,this.offset+i,n(this.majorBrand)),r(t,this.offset+i+4,this.minorVersion),i+=8,this.compatibleBrands.forEach(function(e){r(t,o.offset+i,n(e)),i+=4},this),i},t}(_);e.FileTypeBox=y;var v=function(e){function t(t,r){var n=e.call(this,t)||this;return n.children=r,n}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return this.children.forEach(function(e){e&&(r+=e.layout(t+r))}),this.size=r},t.prototype.write=function(t){var r=e.prototype.write.call(this,t);return this.children.forEach(function(e){e&&(r+=e.write(t))}),r},t}(_);e.BoxContainerBox=v;var m=function(e){function r(r,n,o,i){var a=e.call(this,"moov",t([r],n,[o,i]))||this;return a.header=r,a.tracks=n,a.extendsBox=o,a.userData=i,a}return i(r,e),r}(v);e.MovieBox=m;var E=function(e){function t(t,r,n,o,i,a,s,u){void 0===o&&(o=1),void 0===i&&(i=1),void 0===a&&(a=p),void 0===s&&(s=h),void 0===u&&(u=h);var l=e.call(this,"mvhd",0,0)||this;return l.timescale=t,l.duration=r,l.nextTrackId=n,l.rate=o,l.volume=i,l.matrix=a,l.creationTime=s,l.modificationTime=u,l}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+16+4+2+2+8+36+24+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.timescale),r(t,this.offset+n+12,this.duration),n+=16,r(t,this.offset+n,s(this.rate)),r(t,this.offset+n+4,l(this.volume)<<16),r(t,this.offset+n+8,0),r(t,this.offset+n+12,0),n+=16,r(t,this.offset+n,s(this.matrix[0])),r(t,this.offset+n+4,s(this.matrix[1])),r(t,this.offset+n+8,s(this.matrix[2])),r(t,this.offset+n+12,s(this.matrix[3])),r(t,this.offset+n+16,s(this.matrix[4])),r(t,this.offset+n+20,s(this.matrix[5])),r(t,this.offset+n+24,u(this.matrix[6])),r(t,this.offset+n+28,u(this.matrix[7])),r(t,this.offset+n+32,u(this.matrix[8])),n+=36,r(t,this.offset+n,0),r(t,this.offset+n+4,0),r(t,this.offset+n+8,0),r(t,this.offset+n+12,0),r(t,this.offset+n+16,0),r(t,this.offset+n+20,0),n+=24,r(t,this.offset+n,this.nextTrackId),n+=4},t}(g);e.MovieHeaderBox=E;var b;!function(e){e[e.TRACK_ENABLED=1]="TRACK_ENABLED",e[e.TRACK_IN_MOVIE=2]="TRACK_IN_MOVIE",e[e.TRACK_IN_PREVIEW=4]="TRACK_IN_PREVIEW"}(b=e.TrackHeaderFlags||(e.TrackHeaderFlags={}));var w=function(e){function t(t,r,n,o,i,a,s,u,l,d,c){void 0===s&&(s=0),void 0===u&&(u=0),void 0===l&&(l=p),void 0===d&&(d=h),void 0===c&&(c=h);var f=e.call(this,"tkhd",0,t)||this;return f.trackId=r,f.duration=n,f.width=o,f.height=i,f.volume=a,f.alternateGroup=s,f.layer=u,f.matrix=l,f.creationTime=d,f.modificationTime=c,f}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+20+8+6+2+36+8,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.trackId),r(t,this.offset+n+12,0),r(t,this.offset+n+16,this.duration),n+=20,r(t,this.offset+n,0),r(t,this.offset+n+4,0),r(t,this.offset+n+8,this.layer<<16|this.alternateGroup),r(t,this.offset+n+12,l(this.volume)<<16),n+=16,r(t,this.offset+n,s(this.matrix[0])),r(t,this.offset+n+4,s(this.matrix[1])),r(t,this.offset+n+8,s(this.matrix[2])),r(t,this.offset+n+12,s(this.matrix[3])),r(t,this.offset+n+16,s(this.matrix[4])),r(t,this.offset+n+20,s(this.matrix[5])),r(t,this.offset+n+24,u(this.matrix[6])),r(t,this.offset+n+28,u(this.matrix[7])),r(t,this.offset+n+32,u(this.matrix[8])),n+=36,r(t,this.offset+n,s(this.width)),r(t,this.offset+n+4,s(this.height)),n+=8},t}(g);e.TrackHeaderBox=w;var P=function(e){function t(t,r,n,o,i){void 0===n&&(n="unk"),void 0===o&&(o=h),void 0===i&&(i=h);var a=e.call(this,"mdhd",0,0)||this;return a.timescale=t,a.duration=r,a.language=n,a.creationTime=o,a.modificationTime=i,a}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+16+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,a(this.creationTime)),r(t,this.offset+n+4,a(this.modificationTime)),r(t,this.offset+n+8,this.timescale),r(t,this.offset+n+12,this.duration),r(t,this.offset+n+16,d(this.language)<<16),n+20},t}(g);e.MediaHeaderBox=P;var S=function(e){function t(t,r){var n=e.call(this,"hdlr",0,0)||this;return n.handlerType=t,n.name=r,n._encodedName=c(n.name),n}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+8+12+(this._encodedName.length+1),this.size},t.prototype.write=function(t){var o=e.prototype.write.call(this,t);return r(t,this.offset+o,0),r(t,this.offset+o+4,n(this.handlerType)),r(t,this.offset+o+8,0),r(t,this.offset+o+12,0),r(t,this.offset+o+16,0),o+=20,t.set(this._encodedName,this.offset+o),t[this.offset+o+this._encodedName.length]=0,o+=this._encodedName.length+1},t}(g);e.HandlerBox=S;var R=function(e){function t(t){void 0===t&&(t=0);var r=e.call(this,"smhd",0,0)||this;return r.balance=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,l(this.balance)<<16),n+4},t}(g);e.SoundMediaHeaderBox=R;var T=function(e){function t(t,r){void 0===t&&(t=0),void 0===r&&(r=f);var n=e.call(this,"vmhd",0,0)||this;return n.graphicsMode=t,n.opColor=r,n}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+8,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.graphicsMode<<16|this.opColor[0]),r(t,this.offset+n+4,this.opColor[1]<<16|this.opColor[2]),n+8},t}(g);e.VideoMediaHeaderBox=T,e.SELF_CONTAINED_DATA_REFERENCE_FLAG=1;var A=function(t){function r(r,n){void 0===n&&(n=null);var o=t.call(this,"url ",0,r)||this;return o.location=n,r&e.SELF_CONTAINED_DATA_REFERENCE_FLAG||(o._encodedLocation=c(n)),o}return i(r,t),r.prototype.layout=function(e){var r=t.prototype.layout.call(this,e);return this._encodedLocation&&(r+=this._encodedLocation.length+1),this.size=r},r.prototype.write=function(e){var r=t.prototype.write.call(this,e);return this._encodedLocation&&(e.set(this._encodedLocation,this.offset+r),e[this.offset+r+this._encodedLocation.length]=0,r+=this._encodedLocation.length),r},r}(g);e.DataEntryUrlBox=A;var M=function(e){function t(t){var r=e.call(this,"dref",0,0)||this;return r.entries=t,r}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4;return this.entries.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.entries.length),this.entries.forEach(function(e){n+=e.write(t)}),n},t}(g);e.DataReferenceBox=M;var D=function(e){function t(t){var r=e.call(this,"dinf",[t])||this;return r.dataReference=t,r}return i(t,e),t}(v);e.DataInformationBox=D;var x=function(e){function t(t){var r=e.call(this,"stsd",0,0)||this;return r.entries=t,r}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return r+=4,this.entries.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.entries.length),n+=4,this.entries.forEach(function(e){n+=e.write(t)}),n},t}(g);e.SampleDescriptionBox=x;var k=function(e){function t(t,r,n,o,i){var a=e.call(this,"stbl",[t,r,n,o,i])||this;return a.sampleDescriptions=t,a.timeToSample=r,a.sampleToChunk=n,a.sampleSizes=o,a.chunkOffset=i,a}return i(t,e),t}(v);e.SampleTableBox=k;var O=function(e){function t(t,r,n){var o=e.call(this,"minf",[t,r,n])||this;return o.header=t,o.info=r,o.sampleTable=n,o}return i(t,e),t}(v);e.MediaInformationBox=O;var C=function(e){function t(t,r,n){var o=e.call(this,"mdia",[t,r,n])||this;return o.header=t,o.handler=r,o.info=n,o}return i(t,e),t}(v);e.MediaBox=C;var L=function(e){function t(t,r){var n=e.call(this,"trak",[t,r])||this;return n.header=t,n.media=r,n}return i(t,e),t}(v);e.TrackBox=L;var I=function(e){function t(t,r,n,o,i){var a=e.call(this,"trex",0,0)||this;return a.trackId=t,a.defaultSampleDescriptionIndex=r,a.defaultSampleDuration=n,a.defaultSampleSize=o,a.defaultSampleFlags=i,a}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+20,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.trackId),r(t,this.offset+n+4,this.defaultSampleDescriptionIndex),r(t,this.offset+n+8,this.defaultSampleDuration),r(t,this.offset+n+12,this.defaultSampleSize),r(t,this.offset+n+16,this.defaultSampleFlags),n+20},t}(g);e.TrackExtendsBox=I;var N=function(e){function r(r,n,o){var i=e.call(this,"mvex",t([r],n,[o]))||this;return i.header=r,i.tracDefaults=n,i.levels=o,i}return i(r,e),r}(v);e.MovieExtendsBox=N;var F=function(e){function t(t,r){var n=e.call(this,"meta",0,0)||this;return n.handler=t,n.otherBoxes=r,n}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t);return r+=this.handler.layout(t+r),this.otherBoxes.forEach(function(e){r+=e.layout(t+r)}),this.size=r},t.prototype.write=function(t){var r=e.prototype.write.call(this,t);return r+=this.handler.write(t),this.otherBoxes.forEach(function(e){r+=e.write(t)}),r},t}(g);e.MetaBox=F;var U=function(e){function t(t){var r=e.call(this,"mfhd",0,0)||this;return r.sequenceNumber=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.sequenceNumber),n+4},t}(g);e.MovieFragmentHeaderBox=U;var j;!function(e){e[e.BASE_DATA_OFFSET_PRESENT=1]="BASE_DATA_OFFSET_PRESENT",e[e.SAMPLE_DESCRIPTION_INDEX_PRESENT=2]="SAMPLE_DESCRIPTION_INDEX_PRESENT",e[e.DEFAULT_SAMPLE_DURATION_PRESENT=8]="DEFAULT_SAMPLE_DURATION_PRESENT",e[e.DEFAULT_SAMPLE_SIZE_PRESENT=16]="DEFAULT_SAMPLE_SIZE_PRESENT",e[e.DEFAULT_SAMPLE_FLAGS_PRESENT=32]="DEFAULT_SAMPLE_FLAGS_PRESENT"}(j=e.TrackFragmentFlags||(e.TrackFragmentFlags={}));var B=function(e){function t(t,r,n,o,i,a,s){var u=e.call(this,"tfhd",0,t)||this;return u.trackId=r,u.baseDataOffset=n,u.sampleDescriptionIndex=o,u.defaultSampleDuration=i,u.defaultSampleSize=a,u.defaultSampleFlags=s,u}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4,n=this.flags;return n&j.BASE_DATA_OFFSET_PRESENT&&(r+=8),n&j.SAMPLE_DESCRIPTION_INDEX_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_DURATION_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_SIZE_PRESENT&&(r+=4),n&j.DEFAULT_SAMPLE_FLAGS_PRESENT&&(r+=4),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t),o=this.flags;return r(t,this.offset+n,this.trackId),n+=4,o&j.BASE_DATA_OFFSET_PRESENT&&(r(t,this.offset+n,0),r(t,this.offset+n+4,this.baseDataOffset),n+=8),o&j.SAMPLE_DESCRIPTION_INDEX_PRESENT&&(r(t,this.offset+n,this.sampleDescriptionIndex),n+=4),o&j.DEFAULT_SAMPLE_DURATION_PRESENT&&(r(t,this.offset+n,this.defaultSampleDuration),n+=4),o&j.DEFAULT_SAMPLE_SIZE_PRESENT&&(r(t,this.offset+n,this.defaultSampleSize),n+=4),o&j.DEFAULT_SAMPLE_FLAGS_PRESENT&&(r(t,this.offset+n,this.defaultSampleFlags),n+=4),n},t}(g);e.TrackFragmentHeaderBox=B;var q=function(e){function t(t){var r=e.call(this,"tfdt",0,0)||this;return r.baseMediaDecodeTime=t,r}return i(t,e),t.prototype.layout=function(t){return this.size=e.prototype.layout.call(this,t)+4,this.size},t.prototype.write=function(t){var n=e.prototype.write.call(this,t);return r(t,this.offset+n,this.baseMediaDecodeTime),n+4},t}(g);e.TrackFragmentBaseMediaDecodeTimeBox=q;var H=function(e){function t(t,r,n){var o=e.call(this,"traf",[t,r,n])||this;return o.header=t,o.decodeTime=r,o.run=n,o}return i(t,e),t}(v);e.TrackFragmentBox=H;var z;!function(e){e[e.IS_LEADING_MASK=201326592]="IS_LEADING_MASK",e[e.SAMPLE_DEPENDS_ON_MASK=50331648]="SAMPLE_DEPENDS_ON_MASK",e[e.SAMPLE_DEPENDS_ON_OTHER=16777216]="SAMPLE_DEPENDS_ON_OTHER",e[e.SAMPLE_DEPENDS_ON_NO_OTHERS=33554432]="SAMPLE_DEPENDS_ON_NO_OTHERS",e[e.SAMPLE_IS_DEPENDED_ON_MASK=12582912]="SAMPLE_IS_DEPENDED_ON_MASK",e[e.SAMPLE_HAS_REDUNDANCY_MASK=3145728]="SAMPLE_HAS_REDUNDANCY_MASK",e[e.SAMPLE_PADDING_VALUE_MASK=917504]="SAMPLE_PADDING_VALUE_MASK",e[e.SAMPLE_IS_NOT_SYNC=65536]="SAMPLE_IS_NOT_SYNC",e[e.SAMPLE_DEGRADATION_PRIORITY_MASK=65535]="SAMPLE_DEGRADATION_PRIORITY_MASK"}(z=e.SampleFlags||(e.SampleFlags={}));var G;!function(e){e[e.DATA_OFFSET_PRESENT=1]="DATA_OFFSET_PRESENT",e[e.FIRST_SAMPLE_FLAGS_PRESENT=4]="FIRST_SAMPLE_FLAGS_PRESENT",e[e.SAMPLE_DURATION_PRESENT=256]="SAMPLE_DURATION_PRESENT",e[e.SAMPLE_SIZE_PRESENT=512]="SAMPLE_SIZE_PRESENT",e[e.SAMPLE_FLAGS_PRESENT=1024]="SAMPLE_FLAGS_PRESENT",e[e.SAMPLE_COMPOSITION_TIME_OFFSET=2048]="SAMPLE_COMPOSITION_TIME_OFFSET"}(G=e.TrackRunFlags||(e.TrackRunFlags={}));var K=function(e){function t(t,r,n,o){var i=e.call(this,"trun",1,t)||this;return i.samples=r,i.dataOffset=n,i.firstSampleFlags=o,i}return i(t,e),t.prototype.layout=function(t){var r=e.prototype.layout.call(this,t)+4,n=this.samples.length,o=this.flags;return o&G.DATA_OFFSET_PRESENT&&(r+=4),o&G.FIRST_SAMPLE_FLAGS_PRESENT&&(r+=4),o&G.SAMPLE_DURATION_PRESENT&&(r+=4*n),o&G.SAMPLE_SIZE_PRESENT&&(r+=4*n),o&G.SAMPLE_FLAGS_PRESENT&&(r+=4*n),o&G.SAMPLE_COMPOSITION_TIME_OFFSET&&(r+=4*n),this.size=r},t.prototype.write=function(t){var n=e.prototype.write.call(this,t),o=this.samples.length,i=this.flags;r(t,this.offset+n,o),n+=4,i&G.DATA_OFFSET_PRESENT&&(r(t,this.offset+n,this.dataOffset),n+=4),i&G.FIRST_SAMPLE_FLAGS_PRESENT&&(r(t,this.offset+n,this.firstSampleFlags),n+=4);for(var a=0;a31)throw new Error("invalid compressor name");return h}return i(n,t),n.prototype.layout=function(e){var r=t.prototype.layout.call(this,e)+16+12+4+2+32+2+2;return this.otherBoxes&&this.otherBoxes.forEach(function(t){r+=t.layout(e+r)}),this.size=r},n.prototype.write=function(e){var n=t.prototype.write.call(this,e);r(e,this.offset+n,0),r(e,this.offset+n+4,0),r(e,this.offset+n+8,0),r(e,this.offset+n+12,0),n+=16,r(e,this.offset+n,this.width<<16|this.height),r(e,this.offset+n+4,s(this.horizResolution)),r(e,this.offset+n+8,s(this.vertResolution)),n+=12,r(e,this.offset+n,0),r(e,this.offset+n+4,this.frameCount<<16),n+=6,e[this.offset+n]=this.compressorName.length;for(var o=0;o<31;o++)e[this.offset+n+o+1]=o 0.");this._ensureNotDead(),this._ensureInitialized(), +this._logger.debug("remove() called.",e);var t=i();return this._pendingActions.push({type:"remove",range:e,deferred:t}),this._performNextAction(),t.promise},e.prototype.kill=function(){if(!this._dead){if(this._logger.debug("kill() called."),this._dead=!0,this._sourceBuffer){this._sourceBuffer.removeEventListener("updateend",this._onSourceBufferUpdateEnd,!1),this._sourceBuffer.removeEventListener("error",this._onSourceBufferError,!1);try{this._mediaSource.removeSourceBuffer(this._sourceBuffer)}catch(e){this._logger.error("Error from removeSourceBuffer()",e)}}this._mediaSource.removeEventListener("sourceopen",this._onMediaSourceInit,!1),this._mediaSource.removeEventListener("error",this._onMediaSourceError,!1),URL.revokeObjectURL(this._url);var e=this._currentAction?[this._currentAction]:[];e=e.concat(this._pendingActions),e.forEach(function(e){e.deferred.reject(t.killedError)}),this._whenIdleDeferred||(this._whenIdleDeferred=i()),this._whenIdleDeferred.reject(t.killedError),this._initialized||this._initializeDeferred.reject(this._error||t.killedError),this._pendingActions.length=0,this._logger.debug("Killed.")}},e.prototype._ensureInitialized=function(){if(!this._initialized)throw new Error("Not initialized yet.")},e.prototype._ensureNotDead=function(){if(this._dead)throw new Error("MSE is dead.")},e.prototype._onMediaSourceInit=function(){this._logger.debug("MSE initialized."),this._mediaSource.removeEventListener("sourceopen",this._onMediaSourceInit,!1);try{this._logger.debug("Creating source buffer.",this._type),this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.mode=this._useSegmentsMode?"segments":"sequence",this._logger.debug("Using append mode: "+this._sourceBuffer.mode),this._sourceBuffer.addEventListener("updateend",this._onSourceBufferUpdateEnd,!1),this._sourceBuffer.addEventListener("error",this._onSourceBufferError,!1)}catch(e){this._handleError(e)}this._initializeDeferred.resolve(void 0),this._whenIdleDeferred.resolve(void 0),this._initialized=!0,this._performNextAction()},e.prototype._onMediaSourceError=function(e){this._handleError(e)},e.prototype._handleError=function(e){this._ensureNotDead(),this._logger.error("Error occurred.",e),this._error=e||new Error("Unknown error."),this.kill()},e.prototype._onSourceBufferUpdateEnd=function(){var e=this._currentAction;return this._logger.debug("Update ended.",this.getBuffered()),e?"append"===e.type&&u(this.getBuffered()).end<=this._bufferEnd?void this._handleError(new Error("Buffer end point did not increase after an append.")):(this._currentAction=null,e.deferred.resolve(void 0),void this._performNextAction()):void this._handleError(new Error("No action in progress."))},e.prototype._onSourceBufferError=function(e){this._handleError(e)},e.prototype._performNextAction=function(){var e=this._whenIdleDeferred;if(!this._currentAction&&this._sourceBuffer){var t=this._pendingActions.shift();if(!t)return this._logger.debug("No more actions."),void(e&&(this._whenIdleDeferred=null,e.resolve(void 0)));switch(e||(this._whenIdleDeferred=i()),this._currentAction=t,this._logger.debug("Performing next action..."),t.type){case"append":var r=u(this.getBuffered());try{if("segments"===this._sourceBuffer.mode){var n=r.end/1e3;this._logger.debug("Setting timestampOffset because detected safari.",n),this._sourceBuffer.timestampOffset=n}this._logger.debug("Calling appendBuffer()."),this._bufferEnd=r.end,this._sourceBuffer.appendBuffer(t.data)}catch(e){this._handleError(e)}break;case"remove":try{var o=t.range;this._logger.debug("Calling remove().",o.start,o.end),this._sourceBuffer.remove(o.start/1e3,o.end/1e3)}catch(e){this._handleError(e)}}}},e}();t.MSE=_},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(0),i=o.helpers.find,a=o.eventDispatcher.EventDispatcher,s=o.helpers.abortableJob.abortedError,u=o.helpers.abortableJob.AbortableJob,l=o.logger.prefixLogger,d=o.logger.noOpLogger;!function(e){e[e.RETRIEVING_SEGMENT=0]="RETRIEVING_SEGMENT",e[e.RETRIEVED_SEGMENT=1]="RETRIEVED_SEGMENT",e[e.RETRIEVING_DATA=2]="RETRIEVING_DATA",e[e.COMPLETE=3]="COMPLETE"}(n||(n={}));var c=function(){function e(e){this._onSegmentRequestQueued=new a,this._onSegmentRequestStart=new a,this._onSegmentRetrieved=new a,this._onSegmentRequestFailed=new a,this._onSegmentDecryptionStart=new a,this._onSegmentDecryptionEnd=new a,this._onSegmentTransmuxStart=new a,this._onSegmentTransmuxEnd=new a,this._onSegmentReady=new a,this._onError=new a,this._segments=[],this._retrievingSegment=null,this._timerId=null,this._dead=!1;var t=e.playlist,r=e.getPosition,n=e.maxBufferLength,o=e.cacheSize,i=e.transmuxer,s=e.logger,u=void 0===s?d:s;if(this._logger=l(u,"PlaylistSegmentRetriever"),t&&!t.hasRetrieveCompleted())throw new Error("Playlist retrieve has not completed.");if(n<0)throw new Error("Max buffer length must be > 0.");if(o<0)throw new Error("Cache size must be > 0.");this.onSegmentRequestQueued=this._onSegmentRequestQueued.getHandle(),this.onSegmentRequestStart=this._onSegmentRequestStart.getHandle(),this.onSegmentRetrieved=this._onSegmentRetrieved.getHandle(),this.onSegmentRequestFailed=this._onSegmentRequestFailed.getHandle(),this.onSegmentDecryptionStart=this._onSegmentDecryptionStart.getHandle(),this.onSegmentDecryptionEnd=this._onSegmentDecryptionEnd.getHandle(),this.onSegmentTransmuxStart=this._onSegmentTransmuxStart.getHandle(),this.onSegmentTransmuxEnd=this._onSegmentTransmuxEnd.getHandle(),this.onSegmentReady=this._onSegmentReady.getHandle(),this.onError=this._onError.getHandle(),this._playlist=t,this._transmuxer=i,this._getPosition=r,this._maxBufferLength=n,this._cacheSize=o,this.update()}return e.prototype.updateMaxBufferLength=function(e){if(this._ensureNotDead(),e<0)throw new Error("Max buffer length must be > 0.");this._logger.debug("updateMaxBufferLength() called.",e),this._maxBufferLength=e,this.update()},e.prototype.updateCacheSize=function(e){if(this._ensureNotDead(),e<0)throw new Error("Cache size must be > 0.");this._logger.debug("updateCacheSize() called.",e),this._cacheSize=e,this.update()},e.prototype.getCacheSize=function(){return this._cacheSize},e.prototype.getCacheUsage=function(){return this._segments.reduce(function(e,t){return t.state===n.COMPLETE?e+t.data.byteLength+(t.initData?t.initData.byteLength:0):e},0)},e.prototype.switchPlaylist=function(e){if(this._ensureNotDead(),e&&!e.hasRetrieveCompleted())throw new Error("Playlist retrieve has not completed.");this._logger.debug("switchPlaylist() called."),this._abortCurrentRetrieve(),this._playlist=e,this._segments=this._segments.filter(function(e){return e.state===n.COMPLETE}),this.update()},e.prototype.getSegmentsWithData=function(){return this._ensureNotDead(),this._segments.filter(function(e){return e.state===n.COMPLETE}).map(function(e){if(e.state!==n.COMPLETE)throw new Error("Unexpected error.");var t=e.segment,r=e.initData,o=e.data,i=e.eventRepresentation;return{segment:t,initData:r,data:o,eventRepresentation:i}})},e.prototype.update=function(){this._ensureNotDead(),this._timerId&&(this._logger.debug("Cancelling update timer."),window.clearTimeout(this._timerId),this._timerId=null);var e=this._getPosition(),t=e;this._segments.some(function(r){if(r.state!==n.COMPLETE)return!1;var o=r.segment.getTimeRange();return!(o.end=t&&!o.containsTime(t)||(t=o.end,!1))});var r=i(this._segments,function(e){if(e.state===n.RETRIEVED_SEGMENT||e.state===n.RETRIEVING_DATA){var r=e.segment.getTimeRange();return r.containsTime(t)}return!1});return t>=e+this._maxBufferLength?(this._abortCurrentRetrieve(),this._garbageCollect(e),void this._scheduleNextUpdate()):(r?this._retrieveSegmentData(r):this._retrieveSegment(t),void this._garbageCollect(e))},e.prototype.kill=function(){this._dead||(this._logger.debug("kill() called."),this._abortCurrentRetrieve(),this._dead=!0,this._timerId&&(this._logger.debug("Cancelling update timer."),window.clearTimeout(this._timerId)),this._segments=[],this._logger.debug("Killed."))},e.prototype._retrieveSegmentData=function(e){var t=this;if(e.state!==n.RETRIEVED_SEGMENT&&e.state!==n.RETRIEVING_DATA)throw new Error("Segment in incorrect state for data to be retrieved.");var r=this._retrievingSegment;if(!r||r.state!==n.RETRIEVING_DATA||e.segment!==r.segment){this._abortCurrentRetrieve();var o=new u(function(){var r=!1,n=e.segment.retrieveData();t._logger.debug("Retrieving segment data...");var o=n.whenComplete().then(function(e){var n=e.data,o=e.eventRepresentation;if(r)throw s;return t._logger.debug("Retrieved segment data."),t._onSegmentTransmuxStart.dispatch({segment:o}),t._transmuxer.transmux(n).then(function(e){var n=e.data,i=e.initData;if(r)throw s;return t._onSegmentTransmuxEnd.dispatch({segment:o}),t._logger.debug("Transmuxed segment."),{data:n,initData:i,eventRepresentation:o}})});return{result:o,abort:function(){r=!0,n.abort()}}},{storeResult:!1}).run();o.onCompletion(function(r){var o=r.initData,i=r.data,a=r.eventRepresentation;t._retrievingSegment=null,t._segments.splice(t._segments.indexOf(e),1,{state:n.COMPLETE,initData:o,data:i,eventRepresentation:a,segment:e.segment}),t._logger.debug("Segment retrieve completed.",a),t.update(),t._onSegmentReady.dispatch({segment:e.segment,initData:o,data:i,eventRepresentation:a})}),o.onError(function(e){e!==s&&(t._logger.error("Error retrieving segment data.",e),t._scheduleNextUpdate(),t._onError.dispatch(e))}),this._retrievingSegment={state:n.RETRIEVING_DATA,dataRetrieveJob:o,segment:e.segment}}},e.prototype._retrieveSegment=function(e){var t=this,r=this._retrievingSegment,o=this._playlist,i=o?o.getSegmentIndexContainingTime(e):null;if(!r||r.state!==n.RETRIEVING_SEGMENT||r.segmentIndex!==i)if(this._abortCurrentRetrieve(),null!==i&&o){var a=o.getSegment(i);this._logger.debug("Retrieving segment.",i),a.onCompletion(function(e){t._logger.debug("Retrieved segment.",i),e.onSegmentRequestQueued.subscribe(t._onSegmentRequestQueued.dispatch),e.onSegmentRequestStart.subscribe(t._onSegmentRequestStart.dispatch),e.onSegmentRetrieved.subscribe(t._onSegmentRetrieved.dispatch),e.onSegmentRequestFailed.subscribe(t._onSegmentRequestFailed.dispatch),e.onSegmentDecryptionStart.subscribe(t._onSegmentDecryptionStart.dispatch),e.onSegmentDecryptionEnd.subscribe(t._onSegmentDecryptionEnd.dispatch),t._segments.splice(t._segments.indexOf(u),1);var r=e.getTimeRange(),o=t._segments.length;t._segments.some(function(e,t){return e.state!==n.RETRIEVING_SEGMENT&&(e.segment.getTimeRange().start>r.start&&(o=t,!0))}),t._segments.splice(o,0,{state:n.RETRIEVED_SEGMENT,segment:e}),t._retrievingSegment=null,t.update()}),a.onError(function(e){e!==s&&(t._logger.error("Error retrieving segment.",e),t._scheduleNextUpdate(),t._onError.dispatch(e))});var u={state:n.RETRIEVING_SEGMENT,segmentIndex:i,segmentRetrieveJob:a};this._segments.push(u),this._retrievingSegment=u}else this._scheduleNextUpdate()},e.prototype._abortCurrentRetrieve=function(){var e=this._retrievingSegment;e&&(e.state===n.RETRIEVING_SEGMENT?(this._logger.debug("Aborting segment retrieve job."),e.segmentRetrieveJob.abort()):e.state===n.RETRIEVING_DATA&&(this._logger.debug("Aborting segment data retrieve job."),e.dataRetrieveJob.abort()),this._retrievingSegment=null)},e.prototype._garbageCollect=function(e){var t=this._segments,r=this._cacheSize,o=this.getCacheUsage();if(!(o<=r)){var i=e+this._maxBufferLength;t.filter(function(t){if(t.state!==n.COMPLETE)return!1;var r=t.segment.getTimeRange();return r.end<=e||r.start>i}).map(function(t){if(t.state!==n.COMPLETE)throw new Error("Unexpected error.");var r=t.segment.getTimeRange(),o=Math.abs(e-r.start);return{segment:t,distance:o,size:t.data.byteLength+(t.initData?t.initData.byteLength:0)}}).sort(function(e,t){return t.distance-e.distance}).some(function(e){return o<=r||(t.splice(t.indexOf(e.segment),1),o-=e.size,!1)})}},e.prototype._scheduleNextUpdate=function(){var e=this;this._timerId||(this._timerId=window.setTimeout(function(){e._timerId=null,e.update()},1e3))},e.prototype._ensureNotDead=function(){if(this._dead)throw new Error("Playlist segment retriever has been killed.")},e}();t.PlaylistSegmentRetriever=c},function(e,t,r){"use strict";function n(e){return 0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1?e.slice(1,-1):e}function o(e){0===e.indexOf("0x")&&(e=e.substr(2));var t=new Uint16Array(8);if(e.length%4!==0)throw new c.PlaylistParseError("Failed to parse IV (length is not multiple of 4).");for(var r=0;r>8*(15-r)&255;return t}function a(e){return!(e>=400&&e<500)}Object.defineProperty(t,"__esModule",{value:!0});var s,u=r(0),l=r(31),d=r(3),c=r(12),h=r(13),p=r(26),f=r(25),_=u.helpers.abortableJob.AbortableJob,g=u.helpers.deferred.buildDeferred,y=u.helpers.cache.buildCache,v=u.helpers.retry,m=v.retry,E=v.buildExponentialDelayCalculator,b=u.helpers.Promise,w=u.helpers.find,P=u.helpers.url,S=u.eventDispatcher.EventDispatcher,R=u.logger.prefixLogger,T=u.logger.noOpLogger,A=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT(INF): *(\d+(?:\.\d+)?)(?:,(.*))?)|(?:(?!#)()(\S.+))|(?:#EXT-X-(BYTERANGE): *(\d+(?:@\d+(?:\.\d+)?)?)|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.+))|(?:#EXT-X-(VERSION):(\d+))|(?:(#)(.*):(.*))|(?:(#)(.*)))(?:.*)\r?\n?/g,M=/(.+?)=(.+?)(?:,|$)/g,D=/^\d*(\.\d+)?$/;!function(e){e[e.NONE=0]="NONE",e[e.AES_128=1]="AES_128",e[e.SAMPLE_AES=2]="SAMPLE_AES"}(s||(s={}));var x;!function(e){e[e.VOD=0]="VOD",e[e.LIVE=1]="LIVE",e[e.EVENT=2]="EVENT"}(x=t.PlaylistType||(t.PlaylistType={}));var k=function(){function e(e){var t=e.url,r=e.playlistLoader,n=e.segmentLoader,o=e.keyLoader,i=void 0===o?null:o,s=e.segmentFormat,u=e.logger,l=void 0===u?T:u,c=e.delayCalculator,h=void 0===c?E():c,f=e.keyDelayCalculator,v=void 0===f?E():f,w=e.segmentDelayCalculator,P=e.isPlaylistResponseCodeAcceptable,A=void 0===P?function(e){return 200===e}:P,M=e.isPlaylistResponseCodeRetryable,D=void 0===M?a:M,x=e.isSegmentResponseCodeAcceptable,k=void 0===x?function(e){return 200===e}:x,O=e.isSegmentResponseCodeRetryable,C=void 0===O?a:O,L=e.isKeyResponseCodeAcceptable,I=void 0===L?function(e){return 200===e}:L,N=e.isKeyResponseCodeRetryable,F=void 0===N?a:N,U=this;this._keyRetrievalJobsCache=y(),this._data=null,this._playlistEventRepresentation=null,this._onPlaylistRequestQueued=new S,this._onPlaylistRequestStart=new S,this._onPlaylistRetrieved=new S,this._onPlaylistRequestFailed=new S,this._onPlaylistParseStart=new S,this._onPlaylistParseEnd=new S,this._onKeyRequestQueued=new S,this._onKeyRequestStart=new S,this._onKeyRetrieved=new S,this._onKeyRequestFailed=new S,this._logger=R(l,"Playlist"),this.onPlaylistRequestQueued=this._onPlaylistRequestQueued.getHandle(),this.onPlaylistRequestStart=this._onPlaylistRequestStart.getHandle(),this.onPlaylistRetrieved=this._onPlaylistRetrieved.getHandle(),this.onPlaylistRequestFailed=this._onPlaylistRequestFailed.getHandle(),this.onPlaylistParseStart=this._onPlaylistParseStart.getHandle(),this.onPlaylistParseEnd=this._onPlaylistParseEnd.getHandle(),this.onKeyRequestQueued=this._onKeyRequestQueued.getHandle(),this.onKeyRequestStart=this._onKeyRequestStart.getHandle(),this.onKeyRetrieved=this._onKeyRetrieved.getHandle(),this.onKeyRequestFailed=this._onKeyRequestFailed.getHandle(),this._url=t,this._playlistLoader=r,this._segmentLoader=n,this._keyLoader=i,this._segmentFormat=s,this._delayCalculator=h,this._keyDelayCalculator=v,this._isPlaylistResponseCodeAcceptable=A,this._isPlaylistResponseCodeRetryable=D,this._isSegmentResponseCodeAcceptable=k,this._isSegmentResponseCodeRetryable=C,this._isKeyResponseCodeAcceptable=I,this._isKeyResponseCodeRetryable=F,this._segmentDelayCalculator=w,this._downloadAbortableJob=new _(function(){var e=m(function(){return new _(function(){var e=new p.Playlist(t);U._onPlaylistRequestQueued.dispatch({playlist:e});var r=U._playlistLoader.request({url:t});r.whenRequestStarted.then(function(){U._onPlaylistRequestStart.dispatch({playlist:e})}),U._logger.debug("Requesting playlist.",t);var n=r.getResponse().then(function(r){if(!r)return U._logger.warn("Playlist request timed out.",t),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:null}),{success:!1};var n=r.statusCode;if(U._isPlaylistResponseCodeAcceptable(n)){var o=r.data;return o?(U._logger.debug("Got playlist response.",t,n),U._onPlaylistRetrieved.dispatch({playlist:e,statusCode:n}),{success:!0,result:{playlistContent:o,eventRepresentation:e}}):(U._logger.warn("Playlist response contained no data.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),{success:!1})}return U._isPlaylistResponseCodeRetryable(n)?(U._logger.debug("Playlist response code was not acceptable. Will retry.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),{success:!1}):(U._logger.debug("Playlist response code was not acceptable.",t,n),U._onPlaylistRequestFailed.dispatch({playlist:e,statusCode:n}),b.reject(new d.UnacceptableResponseStatusCodeError(n)))});return{result:n,abort:function(){U._logger.debug("Aborting playlist request.",t),r.abort(),U._onPlaylistRequestFailed.dispatch({playlist:e,aborted:!0})}}})},h);return{result:e.whenComplete(),abort:function(){return e.abort()}}},{storeResult:!1}),this._retrieveJob=new _(function(){var e=U._downloadAbortableJob.run(),t=g();return e.onCompletion(function(e){var r=e.playlistContent,n=e.eventRepresentation;U._onPlaylistParseStart.dispatch({playlist:n});try{U._data=U._parsePlaylist(r)}catch(e){return U._logger.error("Error when parsing playlist.",e,r),void t.reject(e)}U._playlistEventRepresentation=n,U._onPlaylistParseEnd.dispatch({playlist:n}),t.resolve(void 0)}),e.onError(t.reject),{result:t.promise,abort:function(){return e.abort()}}},{storeResult:!1})}return e.prototype.retrieve=function(){return this._retrieveJob.run()},e.prototype.hasRetrieveCompleted=function(){return!!this._data},e.prototype.getStartingSequenceNumber=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.mediaSequence},e.prototype.getType=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.type},e.prototype.getTargetDuration=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.targetDuration},e.prototype.getTotalDuration=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.totalDuration},e.prototype.hasEnded=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.ended},e.prototype.getSegmentCount=function(){if(!this._data)throw new Error("Not loaded yet.");return this._data.segments.length},e.prototype.getSegment=function(e){return this.getSegments(e,e+1)[0]},e.prototype.getSegments=function(e,t){var r=this,n=this._data;if(!n)throw new Error("Not loaded yet.");var o=n.mediaSequence;void 0===e&&(e=o);var i=n.segments.length;if(void 0===t&&(t=o+i),e= the first segment index.");if(t= the first segment index.");if(t>o+i)throw new Error("End index cannot be > than the index of the last segment.");if(t= start index.");return n.segments.slice(e-o,t-o).map(function(t,n){var o=new _(function(){var o=t.encryptionData,i=e+n,a=r._playlistEventRepresentation;if(!a)throw new Error("Playlist event representation should exist.");var s=r._buildEncryptionConfig(o,i),u=s.whenComplete().then(function(e){return new l.Segment({url:t.url,index:i,timeRange:t.timeRange,format:r._segmentFormat,loader:r._segmentLoader,playlistEventRepresentation:a,logger:r._logger,delayCalculator:r._segmentDelayCalculator,isResponseCodeAcceptable:r._isSegmentResponseCodeAcceptable,isResponseCodeRetryable:r._isSegmentResponseCodeRetryable,encryptionConfig:e})});return{result:u,abort:function(){return s.abort()}}},{storeResult:!1});return o.run()})},e.prototype.getSegmentIndexContainingTime=function(e){var t=this._data;if(!t)throw new Error("Not loaded yet.");var r=w(t.segments,function(t){return t.timeRange.containsTime(e)});return r?t.mediaSequence+t.segments.indexOf(r):null},e.prototype._buildEncryptionConfig=function(e,t){var r=this,n=new _(function(){if(e.method===s.NONE)return{result:b.resolve(void 0)};if(e.method!==s.AES_128)return r._logger.error("Unsupported encryption method.",e.method),{result:b.reject(new h.UnsupportedEncryptionError)};var n=r._keyLoader;if(!n)return{result:b.reject(new Error("Encryption method not supported as no key loader provided."))};var o=r._retrieveKey(e.keyUrl),a=o.whenComplete().then(function(r){return{cipher:"AES-CBC",key:r,iv:e.iv||i(t)}});return{result:a,abort:function(){return o.abort()}}});return n.run()},e.prototype._retrieveKey=function(e){var t=this,r=this._keyLoader;if(!r)throw new Error("No key loader.");var n=this._keyRetrievalJobsCache.get(e);if(n)this._logger.debug("Key retrieval already in progress.",e);else{var o=this._playlistEventRepresentation;if(!o)throw new Error("Playlist event representation should exist.");n=new _(function(){var n=m(function(){return new _(function(){var n=new f.Key(o,e);t._onKeyRequestQueued.dispatch({key:n});var i=r.request({url:e});i.whenRequestStarted.then(function(){return t._onKeyRequestStart.dispatch({key:n})}),t._logger.debug("Retrieving key.",e);var a=i.getResponse().then(function(r){if(!r)return t._logger.warn("Key request timed out.",e),t._onKeyRequestFailed.dispatch({key:n,statusCode:null}),{success:!1};var o=r.statusCode;if(t._isKeyResponseCodeAcceptable(o)){var i=r.data;return i?(t._logger.debug("Got key response.",e,o),t._onKeyRetrieved.dispatch({key:n,statusCode:o}),{success:!0,result:new Uint8Array(i)}):(t._logger.warn("Key response contained no data.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),{success:!1})}return t._isKeyResponseCodeRetryable(o)?(t._logger.warn("Key response code was not acceptable. Will retry.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),{success:!1}):(t._logger.warn("Key response code was not acceptable.",e,o),t._onKeyRequestFailed.dispatch({key:n,statusCode:o}),b.reject(new d.UnacceptableResponseStatusCodeError(o)))});return{result:a,abort:function(){t._logger.debug("Aborting key request.",e),i.abort(),t._onKeyRequestFailed.dispatch({key:n,aborted:!0})}}})},t._keyDelayCalculator);return{result:n.whenComplete(),abort:function(){return n.abort()}}},{storeResult:!1}),this._keyRetrievalJobsCache.set(e,n)}return n.run()},e.prototype._parsePlaylist=function(e){var t={version:null,type:x.LIVE,mediaSequence:null,targetDuration:null,totalDuration:0,ended:!1},r=[],i={method:s.NONE},a=null;A.lastIndex=0;for(var l,d=0,h=!1;null!==(l=A.exec(e));){var p=l.filter(function(e,t){return 0!==t&&void 0!==e}).map(function(e,t){return 0===t?e.toLowerCase():e}),f=p[0],_=p.slice(1);if(0===d){if("extm3u"!==f)throw new c.PlaylistParseError("First line did not contain EXTM3U tag.")}else{if(!h)switch(f){case"playlist-type":if(t.type!==x.LIVE)throw new c.PlaylistParseError("Already have playlist type.");switch(_[0].toLowerCase()){case"vod":t.type=x.VOD;break;case"event":t.type=x.EVENT;break;default:throw new c.PlaylistParseError("Invalid playlist type.")}break;case"media-sequence":if(null!==t.mediaSequence)throw new c.PlaylistParseError("Already have media sequence number.");var g=parseInt(_[0],10);if(g+""!==_[0])throw new c.PlaylistParseError("Invalid media sequence number.");t.mediaSequence=g;break;case"targetduration":if(null!==t.targetDuration)throw new c.PlaylistParseError("Already have target duration.");var y=parseInt(_[0],10);if(y+""!==_[0]||y<0)throw new c.PlaylistParseError("Invalid target duration.");t.targetDuration=1e3*y;break;case"version":if(null!==t.version)throw new c.PlaylistParseError("Already have version.");var v=parseInt(_[0],10);if(v+""!==_[0])throw new c.PlaylistParseError("Invalid version.");if(v<3)throw new c.PlaylistParseError("HLS version must be 3 or above.");t.version=v;break;default:h=!0}if(h)switch(f){case"key":M.lastIndex=0;for(var m=void 0,E=null,b=null,w=null;null!==(m=M.exec(_[0]));){if(3!==m.length)throw new c.PlaylistParseError("Error parsing key attributes.");var S=m[1].trim().toLowerCase(),R=n(m[2].trim());switch(S){case"method":E=R.toLowerCase();break;case"uri":b=P.buildAbsoluteUrl(this._url,R);break;case"iv":w=o(R);break;default:this._logger.warn("Unknown attribute when parsing KEY line.",S)}}if(!E)throw new c.PlaylistParseError("Missing encryption method.");if(!b&&"none"!==E)throw new c.PlaylistParseError("Missing key url.");switch(E){case"none":if(null!==b)throw new c.PlaylistParseError("Key url not allowed.");if(null!==w)throw new c.PlaylistParseError("IV not allowed.");i={method:s.NONE};break;case"aes-128":if(!b)throw new c.PlaylistParseError("Key url required.");i={method:s.AES_128,keyUrl:b,iv:w};break;case"sample-aes":if(!b)throw new c.PlaylistParseError("Key url required.");i={method:s.SAMPLE_AES,keyUrl:b,iv:w};break;default:throw new c.PlaylistParseError("Unknown encryption method.")}break;case"inf":if(!_[0].match(D))throw new c.PlaylistParseError("Invalid segment duration.");a=1e3*parseFloat(_[0]);break;case"":if(t.ended)throw new c.PlaylistParseError("Already received ENDLIST tag.");if(null===a)throw new c.PlaylistParseError("Not received segment duration.");var T=P.buildAbsoluteUrl(this._url,_[0]);r.push({url:T,timeRange:new u.TimeRange(t.totalDuration,a),encryptionData:i}),t.totalDuration+=a,a=null;break;case"endlist":if(t.ended)throw new c.PlaylistParseError("Already had ENDLIST tag.");t.ended=!0;break;default:this._logger.warn("Unable to parse playlist line.",f)}}d++}var k=t.version,O=t.type,C=t.mediaSequence,L=t.targetDuration,I=t.ended,N=t.totalDuration;if(null===k)throw new c.PlaylistParseError("Missing version.");if(null===L)throw new c.PlaylistParseError("Missing target duration.");if(I&&O===x.LIVE)throw new c.PlaylistParseError("Cannot be ended if type is LIVE.");if(!I&&O===x.VOD)throw new c.PlaylistParseError("Must be ended if type is VOD.");return null===C&&(C=0),{version:k,type:O,mediaSequence:C,targetDuration:L,totalDuration:N,ended:I,segments:r}},e}();t.Playlist=k},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(22),i=r(3),a=r(11),s=r(27),u=n.helpers.abortableJob.AbortableJob,l=n.helpers.retry,d=l.retry,c=l.buildExponentialDelayCalculator,h=n.helpers.Promise,p=n.eventDispatcher.EventDispatcher,f=n.logger.prefixLogger,_=n.logger.noOpLogger,g=function(){function e(e){var t=e.url,r=e.index,n=e.timeRange,o=e.encryptionConfig,a=e.format,l=e.loader,g=e.playlistEventRepresentation,y=e.logger,v=void 0===y?_:y,m=e.delayCalculator,E=void 0===m?c():m,b=e.isResponseCodeAcceptable,w=void 0===b?function(e){return 200===e}:b,P=e.isResponseCodeRetryable,S=void 0===P?function(e){return!(e>=400&&e<500)}:P,R=this;this._onSegmentRequestQueued=new p,this._onSegmentRequestStart=new p,this._onSegmentRetrieved=new p,this._onSegmentRequestFailed=new p,this._onSegmentDecryptionStart=new p,this._onSegmentDecryptionEnd=new p,this._logger=f(v,"Segment"),this.onSegmentRequestQueued=this._onSegmentRequestQueued.getHandle(),this.onSegmentRequestStart=this._onSegmentRequestStart.getHandle(),this.onSegmentRetrieved=this._onSegmentRetrieved.getHandle(),this.onSegmentRequestFailed=this._onSegmentRequestFailed.getHandle(),this.onSegmentDecryptionStart=this._onSegmentDecryptionStart.getHandle(),this.onSegmentDecryptionEnd=this._onSegmentDecryptionEnd.getHandle(),this._timeRange=n,this._encryptionConfig=o||null,this._format=a,this._loader=l,this._isResponseCodeAcceptable=w,this._isResponseCodeRetryable=S,this._downloadAbortableJob=new u(function(){var e=d(function(){return new u(function(){var e=new s.Segment(g,t,r);R._onSegmentRequestQueued.dispatch({segment:e});var n=R._loader.request({url:t});n.whenRequestStarted.then(function(){return R._onSegmentRequestStart.dispatch({segment:e})}),R._logger.debug("Requesting segment.",t);var o=n.getResponse().then(function(r){if(!r)return R._logger.warn("Segment request timed out.",t),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:null}),{success:!1};var n=r.statusCode;if(R._isResponseCodeAcceptable(n)){var o=r.data;return o?(R._logger.debug("Got segment response.",t,n),R._onSegmentRetrieved.dispatch({segment:e,statusCode:n}),{success:!0,result:{data:new Uint8Array(o),eventRepresentation:e}}):(R._logger.warn("Segment response contained no data.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),{success:!1})}return R._isResponseCodeRetryable(n)?(R._logger.debug("Segment response code was not acceptable. Will retry.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),{success:!1}):(R._logger.debug("Segment response code was not acceptable.",t,n),R._onSegmentRequestFailed.dispatch({segment:e,statusCode:n}),h.reject(new i.UnacceptableResponseStatusCodeError(n)))});return{result:o,abort:function(){R._logger.debug("Aborting segment request.",t),n.abort(),R._onSegmentRequestFailed.dispatch({segment:e,aborted:!0})}}})},E);return{result:e.whenComplete(),abort:function(){return e.abort()}}},{storeResult:!1}),this._retrieveAbortableJob=new u(function(){var e=R._downloadAbortableJob.run(),t=e.whenComplete().then(function(e){var t=e.data,r=e.eventRepresentation;return R.decrypt(t,r).then(function(e){return{data:e,eventRepresentation:r}})});return{result:t,abort:function(){e.abort()}}},{storeResult:!1})}return e.prototype.getTimeRange=function(){return this._timeRange},e.prototype.retrieveData=function(){return this._retrieveAbortableJob.run()},e.prototype.decrypt=function(e,t){var r=this,n=this._encryptionConfig;if(!n)return h.resolve(e);this._logger.info("Finding a decryptor...");var i=o.DecryptorFactory.retrieveDecryptor(n);if(!i)return this._logger.error("Could not find a decryptor."),h.reject(new a.NoDecryptorError);this._logger.info("Decryptor found."),this._onSegmentDecryptionStart.dispatch({segment:t});var s=i.decrypt(e,n);return s.then(function(){r._logger.debug("Decrypted."),r._onSegmentDecryptionEnd.dispatch({segment:t})}),s},e}();t.Segment=g},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(4),i=n.helpers.Promise,a=n.eventDispatcher.EventDispatcher,s=n.logger.prefixLogger,u=n.logger.noOpLogger,l=o.helpers.timeRanges.getCoverage,d=7e3,c=function(){function e(e,t,r,n,o){void 0===o&&(o=u);var i=this;this._onAppendQueued=new a,this._onAppendEnd=new a,this._updateTimerId=null,this._waitingForData=!1,this._started=!1,this._resettingPromise=null,this._error=null,this._logger=s(o,"SimpleMSE"),this.onAppendQueued=this._onAppendQueued.getHandle(),this.onAppendEnd=this._onAppendEnd.getHandle(),this._mse=e,this._getNextSegmentData=t,this._getPosition=r,this._onError=n,e.whenInitialized().then(function(){!i._error&&i._started&&(i._logger.debug("MSE initialized. Preparing to update."),i._prepareUpdate())}).catch(function(e){i._error||(i._logger.error("Error when waiting for MSE to initialize.",e),i._handleError(e||new Error("Error waiting for MSE to initialize.")))})}return e.prototype.start=function(){if(this._checkNotErrored(),this._resettingPromise)throw new Error("start() is not allowed whilst a reset is in progress.");if(this._started)throw new Error("Already started. reset() first.");this._logger.debug("start() called."),this._started=!0,this._prepareUpdate()},e.prototype.kill=function(){this._error||(this._logger.debug("kill() called."),this._updateTimerId&&(this._logger.debug("Clearing update timer."),window.clearTimeout(this._updateTimerId),this._updateTimerId=null),this._error=new Error("Killed."),this._logger.debug("Killed."))},e.prototype.reset=function(){var e=this;if(this._checkNotErrored(),this._logger.debug("reset() called."),this._resettingPromise)return this._logger.debug("Reset already in progress."), +this._resettingPromise;if(!this._started)return this._logger.debug("Nothing to do to, already reset."),i.resolve();var t=this._mse;return this._waitingForData=!1,this._started=!1,this._updateTimerId&&(this._logger.debug("Claring update timer."),window.clearTimeout(this._updateTimerId),this._updateTimerId=null),this._logger.debug("Waiting to clear MSE buffer..."),this._resettingPromise=t.whenIdle().then(function(){e._logger.debug("Clearing MSE buffer.");var r=t.getBuffered(),n=l(r);if(n.duration>0)return t.remove(n)}).then(function(){e._logger.debug("MSE buffer cleared."),e._resettingPromise=null}).catch(function(t){if(!e._error){e._logger.error("Error resetting MSE.",t);var r=t||new Error("Error resetting MSE.");throw e._handleError(r),r}})},e.prototype.waitingForSegmentData=function(){return this._checkNotErrored(),this._waitingForData},e.prototype.provideNextSegmentData=function(e){if(this._checkNotErrored(),!this._waitingForData)throw new Error("Not waiting for data.");this._logger.debug("Segment data provided."),this._waitingForData=!1,this._update(e)},e.prototype._prepareUpdate=function(){if(!this._updateTimerId){var e=this._mse;if(e.hasInitialized()){var t=l(e.getBuffered());if(t.end<=this._getPosition()+d){this._logger.debug("Requesting next segment data.");var r=this._getNextSegmentData();r?(this._logger.debug("Got segment data."),this._update(r)):(this._logger.debug("Did not get any data."),this._waitingForData=!0)}else this._scheduleUpdate()}}},e.prototype._update=function(e){var t=this;this._logger.debug("Updating...");var r=this._mse;this._onAppendQueued.dispatch({segment:e.eventRepresentation}),this._logger.debug("Appending..."),r.append(e.data).then(function(){t._logger.debug("Appended."),t._onAppendEnd.dispatch({segment:e.eventRepresentation}),t._resettingPromise||t._scheduleUpdate()}).catch(function(e){t._error||(t._logger.error("Error updating MSE.",e),t._handleError(e||new Error("Error updating MSE.")))})},e.prototype._scheduleUpdate=function(){var e=this;this._updateTimerId=window.setTimeout(function(){e._updateTimerId=null,e._prepareUpdate()},500)},e.prototype._checkNotErrored=function(){if(this._error)throw this._error},e.prototype._handleError=function(e){this._error||(this._error=e,this._onError(e))},e}();t.SimpleMSE=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(34),o=r(14),i=[n.PassThrough,o.MP3ToMP4];t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=n.helpers.Promise;t.PassThrough={getInputFormat:function(){return{}},getOutputFormat:function(){return{}},transmux:function(e){return o.resolve({data:e})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(33);t.TransmuxerFactory={retrieveTransmuxers:function(e,t){return n.default.filter(function(r){var n=r.getInputFormat(),o=r.getOutputFormat();return!(e&&(n.mimeType&&e.mimeType&&e.mimeType!==n.mimeType||n.audioCodec&&e.audioCodec&&e.audioCodec.id!==n.audioCodec.id||n.videoCodec&&e.videoCodec&&e.videoCodec.id!==n.videoCodec.id)||t&&(o.mimeType&&t.mimeType&&t.mimeType!==o.mimeType||o.audioCodec&&t.audioCodec&&t.audioCodec.id!==o.audioCodec.id||o.videoCodec&&t.videoCodec&&t.videoCodec.id!==o.videoCodec.id))})},retrieveTransmuxer:function(e,r){return t.TransmuxerFactory.retrieveTransmuxers(e,r)[0]||null}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.4.1",t.buildNumber=844;var n=r(16);t.HLSMSEPlayer=n.HLSMSEPlayer;var o=r(15);t.errors=o.errors;var i=r(17);t.retrievalErrors=i.retrievalErrors}])})},function(e,t,r){!function(t,n){e.exports=n(r(2))}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(t,r){t.exports=e},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"An unrecoverable error occurred whilst decoding.")||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.DECODE_ERROR"},t}(o.errors.PlayerFatalError);t.DecodeError=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return e.call(this,"An unrecoverable network error occurred.")||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.NETWORK_ERROR"},t}(o.errors.PlayerFatalError);t.NetworkError=i},function(e,t,r){"use strict";function n(e){return e.slice(0).sort(function(e,t){return e.start-t.start}).reduce(function(e,t,r){var n=e.length-1;return r>0&&e[n].end>=t.start?e[n].end=t.end:e.push(t),e},[])}function o(e){for(var t=[],r=e.length,o=0;or&&(r=e.end)}),new u.TimeRange(t,r-t)}Object.defineProperty(t,"__esModule",{value:!0});var u=r(0);t.normalizeRawTimeRanges=n,t.buildTimeRanges=o,t.containsTime=i,t.normalizeTimeRanges=a,t.getCoverage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(1),i=r(2);!function(e){e.DecodeError=o.DecodeError,e.NetworkError=i.NetworkError}(n=t.errors||(t.errors={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(3);!function(e){var t;!function(e){e.buildTimeRanges=o.buildTimeRanges,e.containsTime=o.containsTime,e.getCoverage=o.getCoverage,e.normalizeTimeRanges=o.normalizeTimeRanges}(t=e.timeRanges||(e.timeRanges={}))}(n=t.helpers||(t.helpers={}))},function(e,t,r){"use strict";function n(e){e.load()}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=r(1),s=r(2),u=r(3),l=r(7),d=i.helpers.deferred.buildDeferred,c=i.helpers.url.getExtension,h=i.helpers.Promise,p=i.logger.prefixLogger,f=i.errors.NotSupportedError,_=i.errors.PlayerFatalError,g=new Error("Media element was revoked."),y=function(e){function t(t,r){var n=this.constructor,o=e.call(this,r)||this;o._duration=null,o._stallDetected=!1,o._initialized=!1,o._deferredProvideMediaElementCallback=null,o._playInProgress={inProgress:!1},o._lastStallCheckPos=null,o._stallCheckTimerId=null,o._endedOverride=!1,o._volume=1,o._muted=!1,o._positionWhenMediaElementRevoked=0,o._playingWhenMediaElementRevoked=!1,o._provideMediaElementDeferred=null,o._mediaElementAndState=null,o._listeners=[],o._currentSeekCallback=null,o._logger=p(o._logger,"HTML5Player"),o._descriptor=t,o._playerDependencies=r,o._mimeType=t.getFormat().mimeType||n.inferMimeType(t.getUrl());var a=void 0!==r.mediaElement?r.mediaElement:o._createDefaultMediaElement();return a&&o.provideMediaElement(a).catch(function(e){return e===g?void o._logger.debug("Initial provideMediaElement() call was aborted."):void o._triggerError(new l.InitializeError(e))}),o._logger.info("Checking if the player can play the provided descriptor."),o._canPlayTimer=window.setTimeout(function(){o._canPlay().then(function(e){if(!o.isDead())return e instanceof i.errors.NotSupportedError?(o._logger.info("Player not supported.",e),void o._triggerError(e)):e?(o._logger.info("Player supported."),void o._initialize()):(o._logger.info("Player not supported."),void o._triggerError(new f))}).catch(function(e){o._logger.error("Unexpected error during can play check.",e),o._triggerError(new _("An unexpected error occured during initialization.",e))})},0),o}return o(t,e),t.inferMimeType=function(e){var t=c(e);switch(t){case"mp3":return"audio/mpeg";case"mp4":return"video/mp4";case"m3u8":return"application/x-mpegURL";default:return null}},t.prototype.getMediaElement=function(){return this._mediaElementAndState&&this._mediaElementAndState.element},t.prototype.provideMediaElement=function(e){var t=this;if(this._ensureNotDead(),this._mediaElementAndState)throw new Error("Already have a media element.");this._logger.debug("provideMediaElement() called.",e),this._initMediaElementLocal(e,null);var r=this._provideMediaElementDeferred=d(),n=this._mediaElementAndState={element:e,state:"INITIALIZING"},o=function(){t._logger.debug("Initializing media element."),t._initMediaElement(e,t._descriptor.getUrl()),t._attachListeners();var o=t._listenToOnce("error",function(){t._provideMediaElementDeferred=null;var n=e.error.code+" = "+(e.error.message||"[unknown]");t._logger.error("Error whilst initializing media element.",n),t.revokeMediaElement(),r.reject(new Error("Error when initializing media element. Error: "+n))},{earlyAttach:!0});t._listenToOnce("loadeddata",function(){t._logger.debug("Got loadeddata event from media element."),i()},{earlyAttach:!0});var i=function(){t._logger.debug("Putting media element in the state that is expected..."),a()},a=function(){null===t._getQueuedSeekPosition()&&t._positionWhenMediaElementRevoked>0?(t._logger.debug("Seeking to expected position..."),t._performSeek(t._positionWhenMediaElementRevoked,function(e){return void 0!==e?(t._provideMediaElementDeferred=null,t._logger.error("An error occurred when trying to seek to the expected position."),t.revokeMediaElement(),void r.reject(new Error("An error occurred when trying to restore the position."))):(t._logger.debug("Seeked to expected position."),void s())})):s()},s=function(){t.isPlaying()===t.isActuallyPlaying()&&t._playingWhenMediaElementRevoked?(t._logger.debug("Calling play to match previous state..."),t._play().catch(function(){t._provideMediaElementDeferred=null,t._logger.error("An error occurred when trying to play."),n===t._mediaElementAndState&&t.revokeMediaElement(),r.reject(new Error("Browser refused play() request on media element."))}),t._listenToOnce("play",function(){t._logger.debug("Play succeeded."),u()},{earlyAttach:!0})):u()},u=function(){return t._mediaElementAndState!==n?void t._triggerError(new _("Media element switched unexpectedly.")):(t._provideMediaElementDeferred=null,o.remove(),r.resolve(void 0),t._mediaElementAndState.state="STABLE",t._logger.debug("Finished putting element in expected state."),void(null!==t._duration&&t._atomic(function(){t.isReady()||t._signalReady(),t._handleDefferredPauseAndSeek()})))}};return this._initialized?o():this._deferredProvideMediaElementCallback=o,this._provideMediaElementDeferred.promise},t.prototype.revokeMediaElement=function(){if(!this._mediaElementAndState)throw new Error("There is no media element to revoke.");this._deferredProvideMediaElementCallback=null,this._provideMediaElementDeferred&&(this._provideMediaElementDeferred.reject(g),this._provideMediaElementDeferred=null),this._logger.debug("revokeMediaElement() called."),this._detachListeners();var e=this._mediaElementAndState.element;this.isDead()||(this._positionWhenMediaElementRevoked=this.getPosition(),this._playingWhenMediaElementRevoked=this.isPlaying()),this._mediaElementAndState=null,this._initMediaElement(e,null),this.isDead()||this._handleStalled()},t.prototype.getVolume=function(){return this._volume},t.prototype.getMuted=function(){return this._muted},t.prototype.setMuted=function(e){this._muted=e,this._mediaElementAndState&&(this._mediaElementAndState.element.muted=e)},t.prototype.getBufferedTimeRanges=function(){return this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state?u.buildTimeRanges(this._mediaElementAndState.element.buffered):[]},t.prototype.getMaxBufferLength=function(){return null},t.prototype._setVolume=function(e){this._volume=e,this._mediaElementAndState&&(this._mediaElementAndState.element.volume=e)},t.prototype._getResolvedMimeType=function(){return this._mimeType},t.prototype._canPlay=function(){return this._mimeType&&this._canPlayProtocol(this._descriptor.getProtocol())&&this._canPlayType(this._mimeType)?h.resolve(!0):h.resolve(!1)},t.prototype._canPlayProtocol=function(e){return["http","hls"].indexOf(e.name)>=0},t.prototype._canPlayType=function(e){try{var t=document.createElement("audio");return!!t.canPlayType(e)}catch(e){return!1}},t.prototype._initialize=function(){var e=this;this._initialized=!0,this._listenTo("error",function(){if("INITIALIZING"===e._mediaElementAndState.state)return void e._logger.debug("An error occurred, but the media element is initializing, so ignoring...");var t=e._mediaElementAndState.element.error;switch(t.code){case 2:e._triggerError(new s.NetworkError);break;case 3:e._triggerError(new a.DecodeError);break;default:e._triggerError(new i.errors.PlayerFatalError("An unexpected error occurred."))}},{earlyAttach:!0}),this._listenTo("playing",function(){e._logger.debug("Media element playing event."),e._mediaElementAndState&&!e._mediaElementAndState.element.paused?e._handlePlayingEvent():e._logger.debug("Ignoring playing event because media element is reporting it is paused.")}),this._listenTo("pause",function(){e._logger.debug("Media element pause event."),e._mediaElementAndState&&e._mediaElementAndState.element.paused?e._handlePauseEvent():e._logger.debug("Ignoring pause event because media element is reporting it is not paused.")}),this._listenTo("ended",function(){e._logger.debug("Media element ended event."),e._mediaElementAndState&&!e._mediaElementAndState.element.ended?e._handleEndedEvent():e._logger.debug("Ignoring ended event because media element is reporting it is not ended.")}),this._listenTo("stalled",function(){e._logger.debug("Media element stalled event."),e._checkIfStalled()}),this._stallCheckTimerId=window.setInterval(function(){return e._checkIfStalled()},400),this._retrieveDuration().then(function(t){e._logger.debug("Duration retrieved.",t),e._duration=t,e._atomic(function(){e._provideDuration(t),e._mediaElementAndState&&"STABLE"===e._mediaElementAndState.state&&(e._signalReady(),e._handleDefferredPauseAndSeek())})}).catch(function(t){e._triggerError(new i.errors.PlayerFatalError("An unexpected error occurred when attempting to retrieve the duration.",t))}),this._deferredProvideMediaElementCallback&&this._deferredProvideMediaElementCallback()},t.prototype._createDefaultMediaElement=function(){return document.createElement(this._playerDependencies.mediaElementType||"audio")},t.prototype._handlePauseEvent=function(){var e=this;this._atomic(function(){e._shouldBeEnded()?e._signalEnded():(e._notifyNotStalled(),e._notifyPlaying(!1))})},t.prototype._handlePlayingEvent=function(){var e=this,t=this._duration;if(null===t)throw new Error("Expecting duration to exist.");var r=this._getTruePosition();return r>=t?void this._logger.warn("Got a media element playing event and the positon was >= the duration.",r,t):this.isEnded()||this._shouldBeEnded()?void this._logger.warn("Got a media element playing event when the player is/should be ended."):void this._atomic(function(){e._endedOverride=!1,e._notifyNotStalled(),e._signalNotEnded(),e._notifyPlaying(!0)})},t.prototype._handleEndedEvent=function(){var e=this;return null!==this._getQueuedSeekPosition()?void this._logger.warn("Got a media element ended event but ignoring because a seek is in progress."):void this._atomic(function(){e._endedOverride=!0,e._signalEnded()})},t.prototype._shouldBeEnded=function(){return this._endedOverride||this._mediaElementReportingEnded()},t.prototype._mediaElementReportingEnded=function(){return!(!this._mediaElementAndState||!this._mediaElementAndState.element.ended)},t.prototype._signalNotEnded=function(){if(this._shouldBeEnded())throw new Error("Attempt to signal not ended when it should be.");e.prototype._signalNotEnded.call(this)},t.prototype._retrieveDuration=function(){var e=this;return new h(function(t){e._listenToOnce("loadedmetadata",function(){var r=e._mediaElementAndState;r&&t(1e3*r.element.duration)},{reattach:!0,earlyAttach:!0})})},t.prototype._handlePlayPauseChange=function(e){var t=this;if(this.isEnded())return void this._notifyPlaying(e);if(this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state){var r=this._mediaElementAndState.element,n=this._playInProgress.inProgress||!r.paused;if(n!==e)if(e){var o={inProgress:!0};this._playInProgress=o,this._play().then(function(){return o.inProgress=!1}).catch(function(e){o.inProgress=!1,t._notifyPlayRejection(e)})}else this._playInProgress={inProgress:!1},r.pause(),this._notifyPlaying(!1);else this._playInProgress.inProgress||this._notifyPlaying(e)}},t.prototype._handleSeekChange=function(e){var t=this,r=this._mediaElementAndState;r&&"USABLE"===r.state&&(this._endedOverride=!1,this._performSeek(e,function(r){return void 0!==r?void t._triggerError(new i.errors.PlayerFatalError("An error occurred when trying to seek.",r)):(e===t._duration&&(t._endedOverride=!0),void t._atomic(function(){t._signalSeekComplete(),t.isEnded()||t._handlePlayPauseChange(t.isPlaying())}))}))},t.prototype._performSeek=function(e,t){var r=this,n=this._mediaElementAndState;if(!n)throw new Error("Media element does not exist.");var o=this._currentSeekCallback;if(o&&(this._currentSeekCallback=null,o.listenerHandle.remove()),n.element.currentTime===e/1e3)return void t();n.element.currentTime=e/1e3;var i=this._listenToOnce("seeked",function(){r._currentSeekCallback=null,t()},{earlyAttach:!0});this._currentSeekCallback={listenerHandle:i,callback:t}},t.prototype._getPosition=function(){var e=null!==this._duration?this._duration:1/0;if(!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)return this._positionWhenMediaElementRevoked;var t=Math.min(this._getTruePosition(),e);return this._shouldBeEnded()?e:t},t.prototype._getTruePosition=function(){if(!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)throw new Error("Media element does not exist or is in invalid state.");var e=this._mediaElementAndState.element;return 1e3*e.currentTime},t.prototype._kill=function(){window.clearTimeout(this._canPlayTimer),this._mediaElementAndState&&this.revokeMediaElement(),this._stallCheckTimerId&&window.clearInterval(this._stallCheckTimerId),this._listeners=[]},t.prototype._listenToOnce=function(e,t,r){void 0===r&&(r={});var n=r.reattach,o=r.earlyAttach;void 0===n&&(n=!1),void 0===o&&(o=!1);var i=function(e){a.remove(),t(e)},a=this._listenTo(e,i,{reattach:n,earlyAttach:o});return a},t.prototype._listenTo=function(e,t,r){var n=this;void 0===r&&(r={});var o=r.reattach,i=r.earlyAttach;void 0===o&&(o=!0),void 0===i&&(i=!1);var a=function(e){s.attached?t(e):n._logger.warn("Got media element event after handler was removed. Ignoring.",e)},s={attached:!1,handler:a,eventType:e,once:!1,reattach:o,earlyAttach:i};if(this._listeners.push(s),!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state&&!i)return{remove:function(){var e=n._listeners.indexOf(s);e>=0&&n._listeners.splice(e,1)}};var u=this._mediaElementAndState.element;return u.addEventListener(e,a,!1),s.attached=!0,{remove:function(){var t=n._listeners.indexOf(s);t>=0&&(n._listeners.splice(t,1),s.attached=!1,u.removeEventListener(e,a,!1))}}},t.prototype._notifyNotStalled=function(){this._stallDetected=!1,this._lastStallCheckPos=null,this._handleStalled()},t.prototype._initMediaElement=function(e,t){this._initMediaElementLocal(e,t)},t.prototype._initMediaElementLocal=function(e,t){e.setAttribute("msAudioCategory","BackgroundCapableMedia"),e.mozAudioChannelType="content",e.removeAttribute("src"),n(e),t&&(this._logger.debug("Setting media element src.",t),e.src=t),e.volume=this._volume,e.muted=this._muted,e.playbackRate=1,e.setAttribute("preload","metadata"),e.load()},t.prototype._checkIfStalled=function(){if(this._mediaElementAndState&&"USABLE"===this._mediaElementAndState.state){var e=this._mediaElementAndState.element;if(!e.paused&&this.isActuallyPlaying()){var t=e.currentTime;this._stallDetected=e.readyState<=2||this._lastStallCheckPos===t,this._lastStallCheckPos=t,this._handleStalled()}}},t.prototype._handleStalled=function(){this._shouldBeEnded()&&null===this._getQueuedSeekPosition()?this.isEnded()||(this._logger.debug("Signalling ended because stalled near end."),this._signalEnded()):this._notifyStalled(this._stallDetected||!this._mediaElementAndState||"USABLE"!==this._mediaElementAndState.state)},t.prototype._play=function(){var e=this;if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");if(this._mediaElementAndState.element.ended)return this._logger.debug("Not calling play() because we are at the end. It will be called after a seek."),h.resolve();var t=this._mediaElementAndState.element.play();return new h(function(r,n){t?t.then(function(){r()}).catch(function(t){"AbortError"===t.name?(e._logger.debug("Media element play() promise rejected with AbortError."),r()):n(t)}):r()})},t.prototype._handleDefferredPauseAndSeek=function(){var e=this;if(!this._mediaElementAndState||"STABLE"!==this._mediaElementAndState.state)throw new Error("Media element must be in the STABLE state.");this._logger.debug("Handling deferred pause and seek..."),this._mediaElementAndState.state="USABLE",this._attachListeners(),this._atomic(function(){e._handleStalled();var t=e._getQueuedSeekPosition();null!==t&&e._handleSeekChange(t),e.isPlaying()!==e.isActuallyPlaying()&&e._handlePlayPauseChange(e.isPlaying())})},t.prototype._detachListeners=function(){if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");var e=this._mediaElementAndState.element;this._listeners.forEach(function(t){t.attached&&(t.attached=!1,e.removeEventListener(t.eventType,t.handler,!1))}),this._listeners=this._listeners.filter(function(e){return e.reattach})},t.prototype._attachListeners=function(){if(!this._mediaElementAndState)throw new Error("Media element doesn't exist.");this._logger.debug("Attaching listeners...");var e=this._mediaElementAndState,t=e.element,r=e.state;this._listeners.forEach(function(e){e.attached||!e.reattach||"USABLE"!==r&&!e.earlyAttach||(t.addEventListener(e.eventType,e.handler,!1),e.attached=!0)}),this._logger.debug("Attached listeners.")},t}(i.BasePlayer);t.HTML5Player=y},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(t){return e.call(this,"An error occurred when initializing the media element.",t)||this}return n(t,e),t.prototype.getCode=function(){return"HTML5_PLAYER.INITIALIZE_ERROR"},t}(o.errors.PlayerFatalError);t.InitializeError=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.4.1",t.buildNumber=844;var n=r(6);t.HTML5Player=n.HTML5Player;var o=r(4);t.errors=o.errors;var i=r(5);t.helpers=i.helpers}])})},function(e,t,r){!function(t,n){e.exports=n(r(2))}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(5),i=function(e){function t(t,r,n){void 0===r&&(r={}),void 0===n&&(n=2e4);var o=e.call(this)||this;o.__aborted=!1;var i=new XMLHttpRequest;return o.xhr=i,i.addEventListener("load",function(){return o._onLoad()}),i.addEventListener("error",function(){return o._onError()}),i.addEventListener("timeout",function(){return o._onTimeout()}),i.open("GET",t,!0),i.timeout=n,i.responseType=o._getResponseType(),Object.keys(r).forEach(function(e){return i.setRequestHeader(e,r[e])}),o._signalRequestStart(),i.send(),o}return n(t,e),t.prototype._abort=function(){this.__aborted=!0,this.xhr.abort()},t.prototype._onTimeout=function(){this.__aborted||this._provideResponse(null)},t.prototype._onLoad=function(){if(!this.__aborted){var e=this.xhr;this._provideResponse({statusCode:e.status,data:this.xhr.response,headers:this._parseHeaders(e.getAllResponseHeaders()||"")})}},t.prototype._onError=function(){this.__aborted||(0===this.xhr.status?this._provideResponse({statusCode:0,data:null,headers:{}}):this._provideResponse(new Error("An error occurred.")))},t.prototype._parseHeaders=function(e){var t={};if(!e)return t;for(var r=e.split("\r\n"),n=0,o=r.length;n0){var s=i.substring(0,a).trim(),u=i.substring(a+2);t[s]=u}}return t},t}(o.loader.LoaderRequest);t.LoaderRequest=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.arrayBufferLoader={request:function(e){var t=e.url,r=e.headers,o=e.timeout;return new n.ArrayBufferLoaderRequest(t,r,o)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);t.stringLoader={request:function(e){var t=e.url,r=e.headers,o=e.timeout;return new n.StringLoaderRequest(t,r,o)}}},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._getResponseType=function(){return"arraybuffer"},t}(o.LoaderRequest);t.ArrayBufferLoaderRequest=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._getResponseType=function(){return"text"},t}(o.LoaderRequest);t.StringLoaderRequest=i},function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="7.4.1",t.buildNumber=844;var n=r(2);t.stringLoader=n.stringLoader;var o=r(1);t.arrayBufferLoader=o.arrayBufferLoader}])})},function(e,t,r){!function(t,n){e.exports=n(r(2),r(1))}(this,function(e,t){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),i=r(3),a=r(1),s=o.helpers.abortableJob.AbortableJob,u=o.helpers.find,l=o.helpers.time,d=300,c=new a.Limiter(d,3e5),h=5e3,p=[i.renditions.encryptedHlsMp3,i.renditions.hlsMp3,i.renditions.httpMp3],f=function(e){function t(t){var r=t.loader,n=t.clientId,o=t.trackId,i=t.secretToken,a=void 0===i?null:i,s=t.requestAuthorization,u=void 0===s?null:s,l=t.excludedRenditions,d=void 0===l?[]:l,c=t.maxBitrate,h=void 0===c?1/0:c,p=t.endpointBaseUrl,f=void 0===p?"https://api.soundcloud.com/":p,_=t.encryptedStreamsEnabled,g=void 0!==_&&_,y=e.call(this)||this;if(y._getUrlsJob=null,y._clearResponseTimer=null,!r)throw new Error("loader required.");if("string"!=typeof n)throw new Error("clientId invalid.");if("number"!=typeof o)throw new Error("trackId invalid.");if(null!==a&&"string"!=typeof a)throw new Error("secretToken invalid.");if(null!==u&&"string"!=typeof u)throw new Error("requestAuthorizaton invalid.");if("number"!=typeof h||h<=0)throw new Error("maxBitrate must be > 0.");if("string"!=typeof f)throw new Error("endpointBaseUrl must be > 0.");if("boolean"!=typeof g)throw new Error("encryptedStreamsEnabled invalid.");return y._loader=r,y._clientId=n,y._requestAuthorization=u,y._trackId=o,y._secretToken=a,y._endpointBaseUrl=f,y._encryptedStreamsEnabled=g,y._excludedRenditions=d,y._excludedRenditionsOnLastURLRequest=d.slice(),y._maxBitrate=h,y}return n(t,e),t.prototype.getTrackId=function(){return this._trackId},t.prototype.excludeRendition=function(e){this._excludedRenditions.indexOf(e)<0&&this._excludedRenditions.push(e)},t.prototype.updateRequestAuthorization=function(e){if(null!==e&&"string"!=typeof e)throw new Error("requestAuthorizaton invalid.");this._requestAuthorization=e},t.prototype.clearCache=function(){this._clearResponseTimer&&(window.clearTimeout(this._clearResponseTimer),this._clearResponseTimer=null),this._getUrlsJob=null},t.prototype.getMaxBitrate=function(){return this._maxBitrate},t.prototype.setMaxBitrate=function(e){if("number"!=typeof e||e<=0)throw new Error("maxBitrate must be > 0.");this._maxBitrate=e},t.prototype.getUrl=function(){var e=this,t=this._maxBitrate,r=this._excludedRenditions,n=new s(function(){e._excludedRenditionsOnLastURLRequest.length===e._excludedRenditions.length?e.clearCache():e._excludedRenditionsOnLastURLRequest=e._excludedRenditions.slice();var n=e._getUrls(),o=n.whenComplete().then(function(e){var n=e.urls,o=e.timeRetrieved,i=null;return p.filter(function(e){return r.indexOf(e)<0}).some(function(e){var r=n.filter(function(t){ +return t.rendition===e}).map(function(e){return{url:e.url,bitrate:e.bitrate}}),a=u(r.sort(function(e,t){return t.bitrate-e.bitrate}),function(e){return e.bitrate<=t});return!!a&&(i={url:a.url,rendition:e,bitrate:a.bitrate,timeRetrieved:o},!0)}),i});return{result:o,abort:function(){return n.abort()}}});return n.run()},t.prototype._getUrls=function(){var e=this;return this._getUrlsJob||(this._getUrlsJob=new s(function(){var t=o.helpers.deferred.buildDeferred(),r=null,n=c.execute(function(){var n=e._requestAuthorization?{Authorization:e._requestAuthorization}:{},o=e._endpointBaseUrl+"i1/tracks/"+encodeURI(e._trackId+"")+"/streams?client_id="+encodeURIComponent(e._clientId);e._encryptedStreamsEnabled&&(o+="&with_encrypted_streams=true"),e._secretToken&&(o+="&secret_token="+encodeURI(e._secretToken)),r=e._loader.request({url:o,headers:n});var a=r.getResponse().then(function(e){if(!e)throw new i.RequestError(null);if(200!==e.statusCode)throw new i.RequestError(e.statusCode);if(!e.data)throw new Error("Response contained no data.");var t=l.now(),r=JSON.parse(e.data),n=[];return Object.keys(r).map(function(e){var t=e.split("_"),o=t[0],i=t[1],a=t[2],s=parseInt(a,10);if(o&&i&&!isNaN(s)){var l=u(p,function(e){return e.scProtocol===o&&e.scFormat===i});l&&n.push({rendition:l,bitrate:s,url:r[e]})}}),{urls:n,timeRetrieved:t}});a.then(t.resolve,t.reject)});return{result:t.promise,abort:function(){n.abort(),r&&r.abort()}}}),this._clearResponseTimer=window.setTimeout(function(){e._clearResponseTimer=null,e._getUrlsJob=null},h)),this._getUrlsJob.run()},t}(i.BaseStreamUrlRetriever);t.StreamUrlRetriever=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){if(void 0===t&&(t=6e4),this._limit=e,this._period=t,this._jobs=[],this._jobsRunInPeriod=0,e<=0)throw new Error("limit must be > 0.");if(t<=0)throw new Error("period must be > 0.")}return e.prototype.execute=function(e){var t=this,r={job:e};return this._jobs.push(r),this._executeNextJob(),{abort:function(){var e=t._jobs.indexOf(r);e>=0&&t._jobs.splice(e,1)}}},e.prototype._executeNextJob=function(){var e=this;if(this._jobsRunInPeriod