bitmovin-player
Version:
The Bitmovin HTML5 Adaptive Streaming Player for MPEG-DASH and HLS
12 lines • 243 kB
JavaScript
/****************************************************************************
* Copyright (C) 2019, Bitmovin, Inc., All Rights Reserved
*
* This source code and its use and distribution, is subject to the terms
* and conditions of the applicable license agreement.
*
* Bitmovin Player Version 8.16.2
*
****************************************************************************/
(function() {
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["engine-bitmovin"]=t():(e.bitmovin=e.bitmovin||{},e.bitmovin.player=e.bitmovin.player||{},e.bitmovin.player["engine-bitmovin"]=t())}(this,function(){return webpackJsonpbitmovin_player__name_([1],{124:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.PERIOD_COMPLETE={code:"PERIOD_COMPLETE"},e.PERIOD_DROPPED_OUT={code:"PERIOD_DROPPED_OUT"},e}();t.SegmentInfoErrors=n},125:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=i(9),r=function(){function e(){}return e.findSegmentInfoOfRepresentation=function(t,i){if(i.SegmentList){var n=i.SegmentList[0].SegmentURL,r=t.getUrl(),o=n.find(function(t){var n=e.getSegmentInfoUrl(t,i);return n===r});if(o)return o}return null},e.findHlsRepresentationForSegment=function(t,i){for(var n=!1,r=0;r<i.Representation.length;r++){var o=i.Representation[r],a=o.SegmentList[0].SegmentURL,s=void 0;for(s=0;s<a.length;s++){var d=a[s],u=e.getSegmentInfoUrl(d,o);if(u===t.getUrl()){n=!0;break}}if(n)return{representation:o,index:s}}return null},e.getSegmentInfoUrl=function(e,t){var i=e._media;return n.URLHelper.isUrlAbsolute(i)||(i=n.URLHelper.concatUrlParts(t.BaseURL[0],i)),i},e}();t.SegmentInfoProvider=r},126:function(e,t,i){"use strict";function n(e,t,i){return!e&&!t||!(e&&!t||!e&&t)&&(i||Object.keys(e)).every(function(i){return e[i]===t[i]})}Object.defineProperty(t,"__esModule",{value:!0}),t.compareValues=n},163:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=i(2),o=i(0),a=i(27),s=i(1),d=i(31),u=i(17),l=i(7),h=i(67),c=i(3),p=i(4),f=i(115),m=i(5),g=i(6),y=i(23),S=i(12),v=i(14),T=i(332),P=i(334),I=i(77),E=i(341);!function(e){e.Unloaded="unloaded",e.Loading="loading",e.Loaded="loaded"}(n||(n={}));var M=function(){function e(e){var t=this;this.timeShiftJumpStart=-1,this.timeShiftEstimatedLiveEdge=-1,this.thumbnailPreviewer=null,this.ignoreNextVideoError=!1,this.ended=!1,this.isDvrWindowExceeded=!1,this.controlPermitted=!0,this.lastPlayIssuer="api",this.lastPauseIssuer="api",this.isInitialSeek=!1,this.onPeriodSwitched=function(e,i){t.finishPeriodSwitch();var n={periodId:e},r={periodId:i};t.fireAudioTracksAdded(t.getCurrentTime()),t.context.eventHandler.dispatchEvent(s.PlayerEvent.PeriodSwitched,{sourcePeriod:n,targetPeriod:r})},this.onPlaying=function(){t.isLive()&&t.canResumeLatencyControl()&&t.resumeLatencyControl()},this.videoErrorHandler=function(e){var i=t.isPlaying(),n=function(){i?t.play():t.preload(),t.eventHandler.off(s.PlayerEvent.Error,n)},r=e&&e.code&&6e3===e.code;if(t.ignoreNextVideoError)t.ignoreNextVideoError=!1;else if(r)t.eventHandler.on(s.PlayerEvent.Error,n,!0),t.load(t.currentSource).then(function(){return n()});else if(t.isLive())t.playerStateService.isPlaying()&&(t.eventHandler.on(s.PlayerEvent.Error,n,!0),t.load(t.currentSource));else{t.unload();var o=t.createPlayerError(e);t.eventHandler.fireError(o)}},this.controlLiveLatency=function(){var e=t.liveLatencyService.getStatus(t.liveLatencyMode,t.getCommonBufferLevel());t.liveLatencyMode!==e.mode&&(t.context.eventHandler.dispatchEvent(s.PlayerEvent.LatencyModeChanged,{from:t.liveLatencyMode,to:e.mode}),t.liveLatencyMode=e.mode);var i=t.playerStateService.isSeeking()||t.playerStateService.isTimeShifting();e.mode===s.LatencyMode.Suspended||i||(e.requiredAction===t.lowLatencyModule.LiveLatencyControlAction.Seek?t.goToLiveEdge():e.requiredAction===t.lowLatencyModule.LiveLatencyControlAction.PlaybackRate&&t.playbackSpeedTracker.setPlaybackSpeed(e.actionParam,!0))},this.onPlaybackStarted=function(){t.playerStateService.stallExit(),t.playerStateService.transitionToPlayingState(t.lastPlayIssuer),t.ended=!1},this.onRendererStallStarted=function(){t.playerStateService.stallEnter(),t.playerStateService.isPlaying()&&(t.ignoreNextVideoElementPauseEvent=!0,t.renderer.pause())},this.onRendererStallEnded=function(e){e.wasPlaying&&t.renderer.play()["catch"](function(e){}),t.playerStateService.stallExit()},this.finishPeriodSwitch=function(){(t.playerController&&t.playerController.hasStreamEnded()||t.isReady()&&!t.isPlaying())&&t.playerController.start()},this.onVideoElementPlay=function(){t.playerStateService.transitionToPlayState(!0,t.lastPlayIssuer),t.playerController&&t.playerController.onPlay()},this.onVideoElementPaused=function(){t.ignoreNextVideoElementPauseEvent&&!t.playerStateService.hasPendingTransitionToState(h.State.Paused)||(t.playerStateService.transitionToPausedState(!0,t.lastPauseIssuer),t.playerController&&t.playerController.onPaused()),t.ignoreNextVideoElementPauseEvent=!1},this.onSeeked=function(){t.playerStateService.transitionToSeekedState(),t.isInitialSeek=!1},this.onTimeChanged=function(e){t.lastCurrentTimeUpdate=e.time,t.isLive()&&t.liveLatencyService&&t.liveLatencyService.isConfigured()&&t.controlLiveLatency()},this.onTimeShifted=function(){t.playerStateService.isTimeShifting()&&(t.playerStateService.transitionToTimeShiftedState(),t.timeShiftEstimatedLiveEdge=-1,t.timeShiftJumpStart=-1),t.isLive()&&(t.canResumeLatencyControl()?t.resumeLatencyControl():t.suspendLatencyControl())},this.mapLangObjectToAudioTrack=function(e){return{id:e.id,lang:e.lang,label:e.label,role:e.role,getQualities:function(){return E.MediaPlayerManifestApiFactory.getAudioQualities(t.manifestService,t.playerController.getPeriodId(),e.id)}}},this.onVideoTimeupdate=function(e){var i=e.time;if("number"==typeof t.streamEndTime){if(i>=t.streamEndTime)return;t.streamEndTime=null}var n=0===t.renderer.getCurrentTime(!0);!t.isPlaying()||t.playerStateService.isSeeking()||t.isStalled()||n||t.context.eventHandler.dispatchEvent(s.PlayerEvent.TimeChanged,{time:t.getCurrentTime()})},this.onContentPlaybackFinished=function(){t.streamEndTime=t.lastCurrentTimeUpdate,t.ended=!0,t.playerStateService.state=h.State.Stopped},this.onDvrWindowExceeded=function(){t.playerStateService.isPlaying()?t.timeShift(0):t.isDvrWindowExceeded=!0},this.onError=function(e){3001===e.code&&t.unload()},this.onInternalError=function(e){6e3===e.code&&t.load(t.currentSource)},this.fireAudioTracksAdded=function(e){for(var i=0,n=t.getAvailableAudio();i<n.length;i++){var r=n[i];t.context.eventHandler.dispatchEvent(s.PlayerEvent.AudioAdded,{track:r,time:e})}},this.fireAudioTracksRemoved=function(e){for(var i=0,n=t.getAvailableAudio();i<n.length;i++){var r=n[i];t.context.eventHandler.dispatchEvent(s.PlayerEvent.AudioRemoved,{track:r,time:e})}},this.onPeriodSwitch=function(){t.fireAudioTracksRemoved(t.getCurrentTime())},this.onPlaybackSpeedChanged=function(e){t.isLive()&&(t.canResumeLatencyControl()?t.resumeLatencyControl():t.suspendLatencyControl(!1))},this.context=e,this.logger=e.logger,this.config=e.config,this.settings=e.settings,this.renderer=e.renderer,this.eventHandler=e.eventHandler,this.loadState=n.Unloaded,this.playbackSpeedTracker=new P.PlaybackSpeedTracker(e),this.context.metrics["default"]=new u.Metrics(this.context,"default"),this.playerController=new T.MediaPlayerController(e,this.onPeriodSwitched),r.ModuleManager.has(o.ModuleName.LowLatency)&&(this.lowLatencyModule=r.ModuleManager.get(o.ModuleName.LowLatency)),this.eventHandler.on(s.PlayerEvent.PeriodSwitch,this.onPeriodSwitch),this.eventHandler.on(s.PlayerEvent.Playing,this.onPlaying),this.eventHandler.on(s.PlayerEvent.PlaybackSpeedChanged,this.onPlaybackSpeedChanged),this.eventHandler.on(g.InternalEvent.RendererStalled,this.onRendererStallStarted,!0),this.eventHandler.on(g.InternalEvent.RendererUnstalled,this.onRendererStallEnded,!0)}return e.prototype.createServices=function(e){var t=e.serviceManager;if(t.set(m.ServiceName.ManifestService,new I.ManifestService(e)),this.manifestService=t.get(m.ServiceName.ManifestService),r.ModuleManager.has(o.ModuleName.DASH)){var i=r.ModuleManager.get(o.ModuleName.DASH);t.set(m.ServiceName.SynchronizedTimeService,new i.SynchronizedTimeService(e))}if(r.ModuleManager.has(o.ModuleName.Subtitles)){var n=r.ModuleManager.get(o.ModuleName.Subtitles).SubtitleService;t.set(m.ServiceName.SubtitleService,new n(e)),this.subtitleService=t.get(m.ServiceName.SubtitleService)}r.ModuleManager.has(o.ModuleName.LowLatency)&&(t.set(m.ServiceName.LiveLatencyService,new this.lowLatencyModule.LiveLatencyService(e)),this.liveLatencyService=t.get(m.ServiceName.LiveLatencyService))},e.prototype.disposeServices=function(){var e=this.context.serviceManager;[m.ServiceName.LiveLatencyService,m.ServiceName.SynchronizedTimeService,m.ServiceName.SubtitleService,m.ServiceName.ManifestService].forEach(function(t){return f.disposeService(e,t)})},e.prototype.createPlayerError=function(e){var t=c.ErrorCode.UNKNOWN;return e.errorObject?(e.errorObject.code===MediaError.MEDIA_ERR_DECODE&&(t=c.ErrorCode.PLAYBACK_VIDEO_DECODING_ERROR),new p.PlayerError(t,e.errorObject)):new p.PlayerError(t,{errorMessage:JSON.stringify(e)})},e.prototype.play=function(e){return this.lastPlayIssuer=e,this.controlPermitted?this.currentSource?this.playerStateService.state===h.State.Playing?Promise.resolve():(this.ended=!1,this.isLive()&&(this.isDvrWindowExceeded||this.getMaxTimeShift()>=0)&&(this.goToLiveEdge(),this.isDvrWindowExceeded=!1),this.playerController.start(),this.playerStateService.transitionToPendingPlayState(!1,e),this.renderer.play()):Promise.resolve():Promise.reject("Play control not permitted")},e.prototype.goToLiveEdge=function(){this.settings.ENABLE_SEEK_FOR_LIVE?this.playerStateService.isSeeking()||this.playerController.seek(this.getSeekableRange().end,!0,null,!0):this.playerController.timeShift(0)},e.prototype.canResumeLatencyControl=function(){return Boolean(this.liveLatencyService)&&!this.isPaused()&&0===this.getTimeShift()&&1===this.getPlaybackSpeed()&&!this.playerStateService.isTimeShifting()&&!this.playerStateService.isSeeking()},e.prototype.resumeLatencyControl=function(){this.liveLatencyService.resumeControl()},e.prototype.suspendLatencyControl=function(e){void 0===e&&(e=!0);var t=this.liveLatencyMode===s.LatencyMode.Suspended;this.liveLatencyService&&!t&&(this.liveLatencyService.suspendControl(),e&&this.playbackSpeedTracker.setPlaybackSpeed(1,!0))},e.prototype.getCommonBufferLevel=function(){var e=[this.getBufferLevel(l.BufferType.ForwardDuration,l.MediaType.Audio),this.getBufferLevel(l.BufferType.ForwardDuration,l.MediaType.Video)].map(function(e){return e.level}).filter(function(e){return null!==e});return 0===e.length?0:Math.min.apply(Math,e)},e.prototype.preload=function(){this.loadState!==n.Unloaded&&this.playerController&&this.playerController.start()},e.prototype.pause=function(e){this.controlPermitted&&this.playerStateService.state!==h.State.None&&(this.lastPauseIssuer=e,this.isLive()&&this.liveLatencyService&&this.liveLatencyService.isConfigured()&&(this.suspendLatencyControl(),this.controlLiveLatency()),this.playerStateService.state!==h.State.Paused&&this.playerStateService.state!==h.State.Stopped&&(this.renderer.pause(),this.playerController.onPaused()),this.playerStateService.transitionToPausedState(this.renderer.isPaused(),e))},e.prototype.mute=function(e){this.isMuted()||(this.renderer.mute(),this.context.eventHandler.dispatchEvent(s.PlayerEvent.Muted,{issuer:e||"api"}))},e.prototype.unmute=function(e){this.isMuted()&&(this.renderer.unmute(),this.context.eventHandler.dispatchEvent(s.PlayerEvent.Unmuted,{issuer:e||"api"}))},e.prototype.seek=function(e,t){var i=this.config&&this.config.hasOwnProperty("playback"),n=i?this.config.playback:{},r=n.hasOwnProperty("seeking"),o=!r||n.seeking,a=this.isInitialSeek||!this.settings.GLOBAL_DISABLE_SEEKING&&o;if(!a||!this.controlPermitted)return!1;var s=this.getCurrentTime();return this.playerStateService.transitionToSeekingState(s,e,t),this.playerStateService.state===h.State.Stopped||t===d.STARTUP_ISSUER_NAME?this.playerController.seek(e,!0,this.onSeeked,!0):this.playerController.seek(e,!1,this.onSeeked),!0},e.prototype.setVolume=function(e,t){var i=this.renderer.getVolume();this.renderer.setVolume(e),i!==e&&this.context.eventHandler.dispatchEvent(s.PlayerEvent.VolumeChanged,{targetVolume:e,sourceVolume:i,issuer:t||"api"})},e.prototype.setAudioQuality=function(e){var t,i=this.getAvailableAudioQualities(),n=this.getAudioQuality();t="auto"===e?{id:"auto",bitrate:null}:i.find(function(t){return t.id===e}),t&&n.id!==t.id&&(this.context.eventHandler.dispatchEvent(s.PlayerEvent.AudioQualityChanged,{sourceQuality:n,sourceQualityId:n.id,targetQuality:t,targetQualityId:t.id}),this.playerController.setAudioRepresentation(e))},e.prototype.getAudioQuality=function(){var e=this.getMimeTypeFromMediaType("audio"),t=this.playerController.isRepresentationAutoSelected(e),i=this.playerController.getCurrentAudioRepresentation();return t||null===i?{id:"auto",bitrate:null}:this.getAvailableAudioQualities().find(function(e){return e.id===i.representationId})},e.prototype.setVideoQuality=function(e){var t,i=this.getAvailableVideoQualities(),n=this.getVideoQuality();t="auto"===e?{id:"auto",bitrate:null,width:null,height:null}:i.find(function(t){return t.id===e}),t&&n.id!==t.id&&(this.context.eventHandler.dispatchEvent(s.PlayerEvent.VideoQualityChanged,{sourceQuality:n,sourceQualityId:n.id,targetQuality:t,targetQualityId:t.id}),this.playerController.setVideoRepresentation(e))},e.prototype.getVideoQuality=function(){var e=this.getMimeTypeFromMediaType("video"),t=this.playerController.isRepresentationAutoSelected(e),i=this.playerController.getCurrentVideoRepresentation();return t||null===i?{id:"auto",bitrate:null,width:null,height:null}:this.getAvailableVideoQualities().find(function(e){return e.id===i.representationId})},e.prototype.processSourceContext=function(){var e=this.context.sourceContext;e.source&&e.source.options&&e.source.options.headers&&(this.settings.HTTP_HEADERS=e.source.options.headers)},e.prototype.load=function(e,t,i){var a=this;if("dash"!==e.type&&"hls"!==e.type&&"smooth"!==e.type)return Promise.reject("invalid source");this.playerStateService=this.context.serviceManager.get(m.ServiceName.PlayerStateService),this.processSourceContext();var d=function(){a.createServices(a.context),a.context.sourceContext.source=e.config,a.context.videoElement.eventHandler&&a.context.videoElement.eventHandler.reset(),a.currentSource=e,a.ended=!1,a.isDvrWindowExceeded=!1,a.isInitialSeek=!0,a.streamEndTime=null,a.liveLatencyService&&(a.liveLatencyMode=s.LatencyMode.Suspended,a.liveLatencyService.reset()),a.renderer.on(v.MediaElementEvent.error,a.videoErrorHandler),a.renderer.on(v.MediaElementEvent.timeupdate,a.onVideoTimeupdate),a.renderer.on(v.MediaElementEvent.playing,a.onPlaybackStarted),a.renderer.on(v.MediaElementEvent.play,a.onVideoElementPlay),a.renderer.on(v.MediaElementEvent.pause,a.onVideoElementPaused),i?a.settings.GLOBAL_DISABLE_SEEKING=i:a.settings.GLOBAL_DISABLE_SEEKING=!1,a.loadState=n.Loading;var t=a.playerController.init(e),d=a.context.sourceContext.source&&a.context.sourceContext.source.thumbnailTrack;if(d&&r.ModuleManager.has(o.ModuleName.Thumbnail)){var u=r.ModuleManager.get(o.ModuleName.Thumbnail);a.thumbnailPreviewer=new u.ThumbnailPreviewManager(a.context),a.thumbnailPreviewer.update(a.context.sourceContext.source.thumbnailTrack.url)}else a.thumbnailPreviewer=null;return t.then(function(){a.loadState=n.Loaded})},u=Promise.resolve();return this.loadState===n.Loading&&(u=this.unload()),this.playerStateService.reset(),this.eventHandler.on(g.InternalEvent.ContentPlaybackFinished,this.onContentPlaybackFinished,!0),this.eventHandler.on(s.PlayerEvent.DVRWindowExceeded,this.onDvrWindowExceeded,!0),this.eventHandler.on(s.PlayerEvent.Error,this.onError,!0),this.eventHandler.on(s.PlayerEvent.TimeChanged,this.onTimeChanged,!0),this.eventHandler.on(g.InternalEvent.InternalError,this.onInternalError,!0),u.then(function(){return a.renderer.ready()}).then(d)},e.prototype.unload=function(){var e,t=this;if(this.loadState===n.Unloaded)return Promise.resolve();var i=this.loadState===n.Loaded;this.ended=!1,this.loadState=n.Unloaded,this.ignoreNextVideoError=!0,this.renderer.off(v.MediaElementEvent.error,this.videoErrorHandler),this.renderer.off(v.MediaElementEvent.timeupdate,this.onVideoTimeupdate),this.renderer.off(v.MediaElementEvent.playing,this.onPlaybackStarted),this.renderer.off(v.MediaElementEvent.play,this.onVideoElementPlay),this.renderer.off(v.MediaElementEvent.pause,this.onVideoElementPaused),this.eventHandler.off(g.InternalEvent.ContentPlaybackFinished,this.onContentPlaybackFinished),this.eventHandler.off(s.PlayerEvent.TimeChanged,this.onTimeChanged),this.eventHandler.off(s.PlayerEvent.DVRWindowExceeded,this.onDvrWindowExceeded),this.eventHandler.off(s.PlayerEvent.Error,this.onError),this.eventHandler.off(g.InternalEvent.InternalError,this.onInternalError),this.playerStateService.isPlaying()&&this.renderer.pause(),this.playerStateService.reset(),this.context.serviceManager.get(m.ServiceName.SynchronizedTimeService)&&this.context.serviceManager.get(m.ServiceName.SynchronizedTimeService).reset();var r,o=Promise.resolve();return this.playerController&&(e=this.playerController.terminate(),r=e[0],o=e[1]),o.then(function(){t.currentSource=void 0,t.disposeServices(),i&&t.eventHandler.dispatchEvent(s.PlayerEvent.SourceUnloaded)})},e.prototype.isReady=function(){return this.playerController.isInitialized()},e.prototype.isPlaying=function(){return this.playerStateService.isPlaying()},e.prototype.isPaused=function(){return this.playerStateService.isPaused()},e.prototype.hasEnded=function(){return this.ended},e.prototype.isMuted=function(){return this.renderer.isMuted()},e.prototype.isStalled=function(){return this.playerStateService.isStalled},e.prototype.isLive=function(){return this.manifestService.isLive()},e.prototype.getVolume=function(){return this.renderer.getVolume()},e.prototype.getCurrentTime=function(){return!this.isLive()&&this.hasEnded()?this.getDuration():this.playerController.getCurrentTime()},e.prototype.getDuration=function(){return this.manifestService.getDuration()},e.prototype.getAvailableVideoQualities=function(){return this.isReady()?this.manifestService.getVideoRepresentations(this.playerController.getPeriodId()):[]},e.prototype.getAvailableSegments=function(){return this.isReady()?this.playerController.getAvailableSegments():{}},e.prototype.getAvailableAudioQualities=function(){var e=this.getAudio();if(!this.isReady()||!e)return[];var t=this.manifestService.getAudioRepresentations(this.playerController.getPeriodId());return t[e.id]?t[e.id]:[]},e.prototype.getDroppedVideoFrames=function(){return this.renderer.getDroppedVideoFrames()},e.prototype.setTargetBufferLevel=function(e,t,i){this.context.bufferSettings.setTargetLevel(e,t,i)},e.prototype.getBufferLevel=function(e,t){var i=this.context.bufferSettings.getTargetLevel(e,t),n={level:null,targetLevel:i,type:e,media:t},r=this.renderer.getCurrentTime(),o=Object.keys(this.context.metrics).find(function(e){return S.MimeTypeHelper.isVideo(e)}),a=Object.keys(this.context.metrics).find(function(e){return S.MimeTypeHelper.isAudio(e)});return t===l.MediaType.Video&&o?n.level=this.playerController.getBufferLevel(o,r,e):t===l.MediaType.Audio&&a&&(n.level=this.playerController.getBufferLevel(a,r,e)),n},e.prototype.getTotalStalledTime=function(){for(var e in this.context.metrics)if(this.context.metrics.hasOwnProperty(e)){var t=this.context.metrics[e].get(u.Metrics.STALLED_SECONDS);if(t&&t.hasOwnProperty("value")&&!isNaN(t.value))return Math.round(100*t.value)/100}return 0},e.prototype.getMimeTypeFromMediaType=function(e){for(var t in this.context.metrics)if(this.context.metrics.hasOwnProperty(t)&&t.indexOf(e)>-1)return t;return null},e.prototype.getDownloadedData=function(e){var t=this.getMimeTypeFromMediaType(e),i=this.getCurrentAdaptationSet(t)||{},n=this.getCurrentRepresentation(t)||{};return n.id&&(n.id=""+n.id),void 0===n.width&&void 0!==i.width&&(n.width=i.width),n.width=parseInt(""+n.width),void 0===n.height&&void 0!==i.height&&(n.height=i.height),n.height=parseInt(""+n.height),void 0===n.bitrate&&void 0!==i.bitrate&&(n.bitrate=i.bitrate),n.bitrate=parseInt(""+n.bitrate),n.isAuto=this.playerController.isRepresentationAutoSelected(t),n},e.prototype.getCurrentRepresentation=function(e){if(this.playerController.hasStarted()){if(this.context.metrics.hasOwnProperty(e)){var t=this.context.metrics[e].get(u.Metrics.DOWNLOADED_REPRESENTATION);return t.value}return{}}return{}},e.prototype.getCurrentAdaptationSet=function(e){if(this.playerController.hasStarted()){if(this.context.metrics.hasOwnProperty(e)){var t=this.context.metrics[e].get(u.Metrics.DOWNLOADED_ADAPTATIONSET);return t.value}return{}}return{}},e.prototype.getDownloadedVideoData=function(){var e=this.getDownloadedData("video"),t=!0;return e.hasOwnProperty("isAuto")&&(t=e.isAuto),e&&(e.bitrate||e.id)?{id:e.id,bitrate:e.bitrate,height:e.height,width:e.width,isAuto:t}:{id:"",bitrate:0,height:0,width:0,isAuto:!0}},e.prototype.getDownloadedAudioData=function(){var e=this.getDownloadedData("audio"),t=!0;return e.hasOwnProperty("isAuto")&&(t=e.isAuto),e&&(e.bitrate||e.id)?{id:e.id,bitrate:e.bitrate,isAuto:t}:{id:"",bitrate:0,isAuto:!0}},e.prototype.getPlaybackVideoData=function(){var e,t,i=this.playerController.getPlaybackRepresentation("video");i&&(i._bandwidth||i._id)||(i={_id:"",_bandwidth:0}),e=i.hasOwnProperty("_height")&&!isNaN(i._height)?parseInt(i._height):i.videoHeight||0,t=i.hasOwnProperty("_width")&&!isNaN(i._width)?parseInt(i._width):i.videoWidth||0;var n={id:i._id+"",bitrate:parseInt(i._bandwidth),height:e,width:t,uid:i.uid};return i.hasOwnProperty("_codecs")&&(n.codec=y.CodecStringHelper.extractCodecStrings(i._codecs).video),n},e.prototype.getPlaybackAudioData=function(){var e=this.playerController.getPlaybackRepresentation("audio");e&&(e._bandwidth||e._id)||(e={_id:"",_bandwidth:0});var t={id:e._id+"",bitrate:Number(e._bandwidth)};return e.hasOwnProperty("_codecs")&&(t.codec=y.CodecStringHelper.extractCodecStrings(e._codecs).audio),t},e.prototype.getThumbnail=function(e){return this.thumbnailPreviewer?this.thumbnailPreviewer.getThumbnail(e):null},e.prototype.setQueryParameters=function(e){this.settings.QUERY_PARAMETERS=e},e.prototype.clearQueryParameters=function(){this.settings.QUERY_PARAMETERS=void 0},e.prototype.getMaxTimeShift=function(){if(this.isLive()&&this.isReady()){var e=this.config.playback&&this.config.playback.timeShift===!1;return e?0:this.playerController.getMaxTimeShift()}},e.prototype.timeShift=function(e,t){this.isReady()&&this.getMaxTimeShift()<0&&(this.playerController.timeShift(e,this.onTimeShifted),this.timeShiftJumpStart===-1&&(this.timeShiftJumpStart=this.getCurrentTime(),0===this.timeShiftJumpStart&&(this.timeShiftJumpStart=this.playerController.getTimeShiftLiveEdge())),this.timeShiftEstimatedLiveEdge===-1&&(this.timeShiftEstimatedLiveEdge=this.playerController.getTimeShiftLiveEdge()),this.playerStateService.transitionToTimeShiftingState(this.timeShiftJumpStart,this.timeShiftEstimatedLiveEdge+e,t||"api"))},e.prototype.getTimeShift=function(){return this.isReady()?this.playerController.getTimeShift():0},e.prototype.addSubtitle=function(e){var t=this;return this.isReady()&&this.subtitleService?Promise.resolve(void 0).then(function(){t.subtitleService.addExternalSubtitle(e)}):Promise.reject(void 0)},e.prototype.removeSubtitle=function(e){this.isReady()&&this.subtitleService&&this.subtitleService.removeSubtitle(e)},e.prototype.enableSubtitle=function(e){return this.isReady()&&this.subtitleService?this.subtitleService.enableSubtitle(e):Promise.resolve(!1)},e.prototype.disableSubtitle=function(e){return this.isReady()&&this.subtitleService?this.subtitleService.disableSubtitle(e):Promise.resolve(!1)},e.prototype.listSubtitles=function(){return this.isReady()&&this.subtitleService&&this.playerController?this.subtitleService.getAvailableSubtitles(this.playerController.getPeriodId()):[]},e.prototype.setAudio=function(e){var t=this;if(this.isReady()&&this.playerController&&"string"==typeof e){var i=this.getAudio();if(i&&i.id===String(e))return;this.playerController.setAudio(e,this.renderer.getCurrentTime()).then(function(){var e=t.getAudio();e.id!==i.id&&t.context.eventHandler.dispatchEvent(s.PlayerEvent.AudioChanged,{targetAudio:e,sourceAudio:i,time:t.renderer.getCurrentTime()})})["catch"](function(e){})}},e.prototype.getAvailableAudio=function(){return this.isReady()&&this.playerController?this.playerController.getAvailableAudio(this.playerController.getPeriodId()).map(this.mapLangObjectToAudioTrack):[]},e.prototype.getAudio=function(){if(this.isReady()&&this.playerController){var e=this.playerController.getAudio();if(e)return this.mapLangObjectToAudioTrack(e)}return null},e.prototype.getManifest=function(){var e=this.manifestService.getManifest();if(e)return e._hls?e._hls.playlist.master:e.originalDashManifest},e.prototype.getBufferedRanges=function(){var e=this.playerController.getBufferedRanges(!0),t=a.BufferRangeHelper.getCommonBufferedRanges(e);return t.map(function(e){return{start:e.getStart(),end:e.getEnd()}})},e.prototype.getSnapshot=function(e,t){if(this.isPlaying()||this.isPaused())return this.renderer.getSnapshotData(e,t)},e.prototype.setPlaybackSpeed=function(e){this.playbackSpeedTracker.setPlaybackSpeed(e)},e.prototype.getPlaybackSpeed=function(){return this.playbackSpeedTracker.getPlaybackSpeed()},e.prototype.permitControl=function(e){this.controlPermitted=e},e.prototype.setLogLevel=function(e){},e.prototype.getSeekableRange=function(){return this.isLive()&&!this.settings.ENABLE_SEEK_FOR_LIVE||!this.playerController?{start:-1,end:-1}:this.playerController.getSeekableRange()},e.prototype.createManifestApi=function(){return E.MediaPlayerManifestApiFactory.create(this,this.context)},e.prototype.getLatency=function(){return this.liveLatencyService.getLatency()},e.prototype.setTargetLatency=function(e){var t=Math.abs(this.manifestService.getTimeShiftBufferDepthSeconds());e>t&&(e=t),this.context.eventHandler.dispatchEvent(s.PlayerEvent.TargetLatencyChanged,{from:this.liveLatencyService.getTargetLatency(),to:e}),this.liveLatencyService.setTargetLatency(e)},e.prototype.getTargetLatency=function(){return this.liveLatencyService.getTargetLatency()},e.prototype.setCatchupConfig=function(e){this.liveLatencyService.setCatchupConfig(e)},e.prototype.getCatchupConfig=function(){return this.liveLatencyService.getCatchupConfig()},e.prototype.setFallbackConfig=function(e){this.liveLatencyService.setFallbackConfig(e)},e.prototype.getFallbackConfig=function(){return this.liveLatencyService.getFallbackConfig()},e.prototype.release=function(){var e=this;return this.eventHandler.off(s.PlayerEvent.PeriodSwitch,this.onPeriodSwitch),this.eventHandler.off(s.PlayerEvent.Playing,this.onPlaying),this.eventHandler.off(s.PlayerEvent.PlaybackSpeedChanged,this.onPlaybackSpeedChanged),this.eventHandler.off(g.InternalEvent.RendererStalled,this.onRendererStallStarted),this.eventHandler.off(g.InternalEvent.RendererUnstalled,this.onRendererStallEnded),this.playbackSpeedTracker.dispose(),this.unload().then(function(){return e.playerStateService=null,e.playerController.dispose(),e.playerController=null,e.disposeServices(),e.renderer.release().then(function(){return e.renderer=null})})},e.prototype.updateCallback=function(e){},e.prototype.onFullscreenEnter=function(){},e.prototype.onFullscreenExit=function(){},e.prototype.isAirplayAvailable=function(){return!1},e.prototype.isAirplayActive=function(){return!1},e.prototype.showAirplayTargetPicker=function(){},e}();t.MediaPlayer=M},164:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=i(2),r=i(0),o=function(){function e(){}return e.prototype.getSupportedTechnologies=function(){var e=n.ModuleManager.has(r.ModuleName.RendererFlash)?n.ModuleManager.get(r.ModuleName.RendererFlash).technologyChecker.getSupportedTechnologies():[],t=n.ModuleManager.has(r.ModuleName.RendererMse)?n.ModuleManager.get(r.ModuleName.RendererMse).technologyChecker.getSupportedTechnologies():[];return[].concat(e,t)},e}();t.TechnologyChecker=o},165:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=i(1),r=i(17),o=i(5),a=function(){function e(){var e=this;this.startOptimization=function(){e.context&&e.context.eventHandler.off(n.PlayerEvent.AdStarted,e.startOptimization),e.prefetchContentSegments(e.segmentInfosToPrefetch),e.segmentInfosToPrefetch=[]}}return e.prototype.updatePlayerContext=function(e){this.mimeTypes=[],this.context=e,this.segmentInfoService=e.segmentInfoService,this.segmentPrefetchingService=e.segmentPrefetchingService},e.prototype.optimizeRestorationAfterUpcomingAdBreak=function(e){var t=this;return this.segmentInfoService.getSegmentInfos(e,this.context.settings.AD_RESTORATION_SEGMENT_PREFETCHING_DURATION).then(function(e){t.addCodecInfo(e),t.segmentInfosToPrefetch=e,t.context&&t.context.eventHandler&&t.context.eventHandler.on(n.PlayerEvent.AdStarted,t.startOptimization)})},e.prototype.addCodecInfo=function(e){var t=this.context&&this.context.serviceManager;if(t&&this.context.serviceManager.get(o.ServiceName.ManifestService)){var i=this.context.serviceManager.get(o.ServiceName.ManifestService);e.forEach(function(e){var t=i.getAdaptationSet(e.internalRepresentationId);t&&(e.codec=i.getCodecsFromAdaptationSet(t))})}},e.prototype.prefetchContentSegments=function(e){this.mimeTypes=e.reduce(function(e,t){return e.includes(t.mimeType)||e.push(t.mimeType),e},[]),this.maybeCreateMetrics(),this.segmentPrefetchingService.fetchAll(e)},e.prototype.findMatchingSegmentInfo=function(e,t){var i=this.segmentPrefetchingService.getPrefetchedSegments().get(e);return i?i.values.map(function(e){return e.segmentInfo}).find(function(e){if(!Boolean(t))return!0;var i=t.segmentNumber+1,n=Math.round(t.startTime+t.duration),r=e.segmentNumber===i,o=Math.round(e.startTime)===n;return r||o}):null},e.prototype.hasPrefetchedSegment=function(e,t){return"string"==typeof e&&(e=this.findMatchingSegmentInfo(e,t)),!!e&&Boolean(this.segmentPrefetchingService.getPrefetchedSegment(e))},e.prototype.getPrefetchedSegment=function(e,t){var i=this,n=this.segmentPrefetchingService.getPrefetchedSegment(e);return this.segmentPrefetchingService.clearPrefetchingQueue(e.mimeType),n&&(this.segmentPrefetchingService.removePrefetchedSegment(e),this.segmentPrefetchingService.setShouldDownloadBeCancelledCallback(e.mimeType,t),n["catch"](function(){}).then(function(){i.segmentPrefetchingService.removeShouldDownloadBeCancelledCallback(e.mimeType)})),n},e.prototype.getRepresentationForPrefetchedSegment=function(e){var t=this.segmentPrefetchingService.getPrefetchedSegments().get(e);return t?t.values.map(function(e){return e.segmentInfo.internalRepresentationId}).find(Boolean)||null:null},e.prototype.maybeCreateMetrics=function(){var e=this;0!==this.mimeTypes.length&&this.context&&this.mimeTypes.forEach(function(t){e.context.metrics[t]||(e.context.metrics[t]=new r.Metrics(e.context,t))})},e.prototype.dispose=function(){this.context&&this.context.eventHandler.off(n.PlayerEvent.AdStarted,this.startOptimization),this.segmentInfosToPrefetch=[],this.context=null,this.segmentInfoService=null,this.segmentPrefetchingService=null},e}();t.AdRestorationOptimizationService=a},166:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=i(8),o=i(28),a=i(70),s=i(11),d=i(60);!function(e){e.User="user",e.Timeout="timeout"}(n||(n={}));var u=function(){function e(e,t,i){var n=this;this.setProgressListener=function(e){n.progressListener=e},this.onProgress=function(e,t){n.progressListener&&(n.timing.progressTimestamp=a.TimingUtil.getHiResTimestamp(),n.progressListener({totalBytes:e,loadedBytes:t,responseTiming:n.timing}))},this.onSuccess=function(){clearTimeout(n.cancelTimeout)},this.logger=e.logger,this.timeout=i,this.request=t,this.fetching=new s.Deferred,this.bytesReceivedCount=0,this.timing={},this.abortController=new AbortController}return e.prototype.getResponse=function(){return this.load(this.request),this.fetching.promise;
},e.prototype.cancel=function(e){void 0===e&&(e=n.User),clearTimeout(this.cancelTimeout),this.cancellationReason=e,this.abortController.abort()},e.prototype.load=function(e){var t=this,i={method:e.method,headers:new Headers(e.headers),credentials:e.credentials,signal:this.abortController?this.abortController.signal:void 0};fetch(e.url,i).then(function(e){if(t.timing.headersReceivedTimestamp=a.TimingUtil.getHiResTimestamp(),!e.ok)return void t.onError({error:o.RequestError.Failed,response:t.createHttpResponse(e)});var i=t.createHttpResponse(e);i.body=t.readResponse(e),t.fetching.resolve(i)})["catch"](function(e){t.onError({error:t.getRequestError(e),response:null})}),this.timing.openedTimestamp=a.TimingUtil.getHiResTimestamp(),this.cancelTimeout=setTimeout(function(){return t.cancel(n.Timeout)},this.timeout)},e.prototype.getResponseHeaders=function(e){var t={};return e.headers.forEach(function(e,i){return t[i]=e}),t},e.prototype.createHttpResponse=function(e){return{request:this.request,url:e.url,headers:this.getResponseHeaders(e),status:e.status,statusText:e.statusText}},e.prototype.getRequestError=function(e){return e instanceof DOMException&&e.code===e.ABORT_ERR?this.cancellationReason===n.User?o.RequestError.Canceled:o.RequestError.TimedOut:o.RequestError.Failed},e.prototype.readResponse=function(e){var t=this,i=new d.Stream(this.request.responseType);if(e.body){var n=e.body.getReader(),o=function(){return n.read().then(function(e){var n=e.done,r=e.value;if(n)return t.timing.doneTimestamp=a.TimingUtil.getHiResTimestamp(),void t.onProgress(t.bytesReceivedCount,0);t.bytesReceivedCount+=r.length,t.onProgress(t.bytesReceivedCount,r.length);var s;return s=r instanceof Uint8Array?r.buffer:r,i.add(s),o()})};o().then(function(){i.end(),t.onSuccess()})["catch"](function(e){i.abort(t.getRequestError(e))})}else this.request.responseType===r.HttpResponseType.ARRAYBUFFER&&e.arrayBuffer().then(function(e){i.add(e),i.end(),t.onSuccess()});return i},e.prototype.onError=function(e){clearTimeout(this.cancelTimeout),this.fetching.reject(e)},e}();t.FetchController=u},167:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=i(19),r=i(96),o=i(348),a=function(){function e(){this.segmentPrefetcher=new o.SegmentPrefetcher(this),this.prefetchedSegments=new n.ObjectMap}return e.prototype.updatePlayerContext=function(e){this.context=e,this.segmentPrefetcher.updateContext(this.context)},e.prototype.setMp4Decrypter=function(e,t){this.segmentPrefetcher.setMp4Decrypter(e,t)},e.prototype.removeMp4Decrypter=function(e){this.segmentPrefetcher.removeMp4Decrypter(e)},e.prototype.getMp4Decrypter=function(e){return this.segmentPrefetcher.getMp4Decrypter(e)},e.prototype.hasMp4Decrypter=function(e){return Boolean(this.getMp4Decrypter(e))},e.prototype.setShouldDownloadBeCancelledCallback=function(e,t){this.segmentPrefetcher.setShouldDownloadBeCancelledCallback(e,t)},e.prototype.removeShouldDownloadBeCancelledCallback=function(e){this.segmentPrefetcher.removeShouldDownloadBeCancelledCallback(e)},e.prototype.fetch=function(e){var t=this;return this.segmentPrefetcher.prefetchSegment(e).then(function(){var i=t.prefetchedSegments.get(e.mimeType).get(r.getSegmentInfoId(e));return i?Promise.resolve(i.loadingPromise):Promise.reject()})},e.prototype.fetchAll=function(e){this.segmentPrefetcher.prefetchSegments(e)},e.prototype.onPrefetch=function(e){var t=e.segmentInfo.mimeType;this.prefetchedSegments.has(t)||this.prefetchedSegments.set(t,new n.ObjectMap),this.prefetchedSegments.get(t).set(r.getSegmentInfoId(e.segmentInfo),e)},e.prototype.hasPrefetchedSegment=function(e){return Boolean(this.findPrefetchedSegment(e))},e.prototype.getPrefetchedSegment=function(e){var t=this.findPrefetchedSegment(e);return t?t.loadingPromise:null},e.prototype.findPrefetchedSegment=function(e){return this.prefetchedSegments.has(e.mimeType)?this.prefetchedSegments.get(e.mimeType).get(r.getSegmentInfoId(e))||null:null},e.prototype.getPrefetchedSegments=function(){return this.prefetchedSegments},e.prototype.removePrefetchedSegment=function(e){this.prefetchedSegments.has(e.mimeType)&&this.prefetchedSegments.get(e.mimeType)["delete"](r.getSegmentInfoId(e))},e.prototype.clearPrefetchingQueue=function(e){this.segmentPrefetcher.clearPrefetchingQueue(e)},e.prototype.reset=function(){this.segmentPrefetcher.reset(),this.prefetchedSegments.clear()},e.prototype.dispose=function(){this.reset(),this.segmentPrefetcher.dispose(),this.segmentPrefetcher=null,this.prefetchedSegments=null},e}();t.SegmentPrefetchingService=a},332:function(e,t,i){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var r=i(2),o=i(0),a=i(1),s=i(17),d=i(7),u=i(5),l=i(6),h=i(23),c=i(11),p=i(12),f=i(19),m=i(14),g=i(335),y=i(336),S=i(337),v=i(44),T=i(95),P=function(){function e(e,t){var i=this;this.onSegmentAvailable=function(e){if(!i.clearBuffersPromise){var t=i.manifestService.getDuration(),n=e.getDuration(),r=i.context.sourceContext.streamType===d.StreamType.Hls,o=e.getMimeType();if(p.MimeTypeHelper.isSubtitle(e.getMimeType())||r||!(i.eosSignaled||i.isVod()&&e.getPlaybackTime()>=t)){if(i.bufferController.areMediaTypesFinal(e.getPeriodId())||i.tryToFinalizeMediaTypes(e),isFinite(n)){var a=i.segmentDurations.get(o)||0;i.segmentDurations.set(o,Math.max(a,n))}if(!e.isInit()){var s=i.segmentController[e.getMimeType()],u=0;s&&(u=s.getMPDHandler().getTimestampOffset()),i.bufferController.updateMediaType(e.getPeriodId(),{mimeType:e.getMimeType(),timestampOffset:u,codec:e.getCodec()})}i.bufferController.addSegment(e),e.getSegmentInfo().wasPrefetched&&i.onTimerTick()}}},this.onDrmKidError=function(e){var t=i.manifestService.getAllRepresentations().filter(function(t){return e.affectedKid&&t.associatedKid===e.affectedKid}).map(function(e){return e._internalId});i.manifestService.blacklistRepresentations(t),i.mustBuffersBeCleared(t)&&(i.getAllSegmentControllers().forEach(function(e){return e.resetLastChosenRepresentation()}),i.context.metrics["default"].clear(s.Metrics.REQUESTED_REPRESENTATIONS),i.manifestUpdateDeferred&&i.manifestUpdateDeferred.reject(),i.manifestUpdateDeferred=new c.Deferred,i.manifestUpdateDeferred.promise.then(function(){i.manifestService.isLive()?i.timeShift(i.getTimeShift()):i.seek(i.renderer.getCurrentTime(),!1,null,!1,!1,!0)})["catch"](function(){}))},this.finishPeriodSwitch=function(e){var t=Object.keys(n({},i.segmentController));i.previousPlayingPeriodId=i._currentPlayingPeriodId,i._currentPlayingPeriodId=e.targetPeriodId,i.segmentDurations.clear();var r=i.manifestService.getPeriod(new v.PeriodId(i._currentPlayingPeriodId));if(r){if(!i.context.settings.DISABLE_SUBTITLE_PERIOD_SWITCH){var o=r.AdaptationSet.filter(function(e){var t=i.manifestService.getMimeTypeForAdaptationSet(e);return!i.segmentController.hasOwnProperty(t)&&p.MimeTypeHelper.isSubtitle(t)});o.forEach(function(e){return i.setupControllerForAdaptationSet(e)})}r.AdaptationSet.forEach(function(e){return i.storeDrmInitDataFromManifest(e)})}i.getAllSegmentControllers().filter(function(e){return i.manifestService.isMimeTypePartOfPeriod(e.getMimeType(),i._currentPlayingPeriodId)}).forEach(function(e){p.MimeTypeHelper.isAV(e.getMimeType())||e.getCurrentPeriodId()!==i._currentPlayingPeriodId&&e.switchPeriod(i._currentPlayingPeriodId)}),i.updateCallback(i.previousPlayingPeriodId,i._currentPlayingPeriodId),t[0]&&i.segmentController[t[0]].parseEventStream(),i.playerStateService.playingPeriodId=e.targetPeriodId},this.mpdUpdateHandler=function(e){var t=e.manifest;i.manifestService.updateManifest(t).then(i.mpdUpdateHandlerInternal)},this.endStallAtGapHandler=function(){var e=i.bufferController.getBufferedRangesMap(),t=Math.max.apply(Math,Object.keys(e).map(function(t){var i=e[t];return i.length>0?i[i.length-1].start:0}));i.seek(t,!1,null,!1,!0)},this.mpdUpdateHandlerInternal=function(){var e=i.manifestService.isLive(),t=i.context.serviceManager.get(u.ServiceName.StartOffsetService);if(i.manifestService.hasSuggestedStartPosition()&&(e?t.manifestStartOffset=i.manifestService.getLiveStartOffset():t.manifestStartOffset=i.manifestService.getVodStartOffset()),e){var r=i.manifestService.getTimeShiftBufferDepthSeconds();if(0!==r&&(i.metadataParsedService.expirationTimeInSeconds=r),i.manifestService.hasSuggestedStartPosition()){var o=Math.abs(i.manifestService.getLiveStartOffset(!1));o=o>0?o:i.manifestService.getMaxSegmentDuration();var a=Math.min(o,i.bufferSettings.getForwardTargetLevel(d.MediaType.Video)),s=Math.min(o,i.bufferSettings.getForwardTargetLevel(d.MediaType.Audio));i.bufferSettings.setMaximumBufferLevel(d.BufferType.ForwardDuration,a,d.MediaType.Video),i.bufferSettings.setMaximumBufferLevel(d.BufferType.ForwardDuration,s,d.MediaType.Audio)}}i.initialized&&i.updatePeriodBuffers(),i.handleDroppedOutPeriods(),i.initialized?i.getAllSegmentControllers().forEach(function(e){return e.updateMpd()}):i.finishInit();var l=Object.keys(n({},i.segmentController))[0];l&&(i.segmentController[l].parseEventStream(),i.segmentController[l].handleDateRangeMetadata()),i.manifestUpdateDeferred&&(i.manifestUpdateDeferred.resolve(),i.manifestUpdateDeferred=null)},this.onTimerTick=function(){if(i.isOneLoaderReady()&&!i.shouldStopDownloadWhenPaused()&&!i.clearBuffersPromise){var e=i.getAllSegmentControllers().filter(function(e){var t=i.shouldWaitForOtherMimeTypeDownload(e.getMimeType());return e.hasFreeLoader()&&!t&&!i.isLoadingPeriodFinished(e)});if(e.forEach(function(e){return i.getNextSegment(e)}),i.areAllLoadersReady()){if(0===e.length&&i.shouldSwitchLoadingPeriod)return void i.switchLoadingPeriod();if(0===e.length&&i.bufferController.areMediaTypesFinal(i._currentPlayingPeriodId)){var t=i.manifestService.isManifestFinalized(),n=i.manifestService.isLastPeriod(i.currentLoadingPeriodId);t&&n&&(i.bufferController.stop(!1),i.shouldEndOfStreamBeSignaled()&&(i.signalEndOfStream(),i.stop()))}else i.isAVCompletelyLoaded(e)&&i.signalEndOfStream();i.subtitleService&&!i.playerStateService.seekingOrTimeshifting&&i.subtitleService.clearBuffersUntil(i.renderer.getCurrentTime()-10)}}},this.onSegmentRequestFinished=function(e){if(e&&(e.success||408===e.httpStatus)){var t=i.segmentController[e.mimeType];t&&i.updateAdaptationLogicData(e,t),i.onTimerTick()}},this.onPeriodSwitchHandler=function(){i.isPeriodSwitchHappeningNow=!0},this.onPeriodSwitchedHandler=function(){i.isPeriodSwitchHappeningNow=!1},this.eventHandlerFunctionTimeChanged=function(e){if(i.initialized){var t=i.manifestService.getDuration(),n=i.context.sourceContext.playerType===d.PlayerType.Flash,r=!isNaN(t)&&e.time>=t-1.1;!i.eosSignaled&&r&&n&&i.signalEndOfStream()}},this.firePlaybackFinishedEvent=function(){i.manifestService.isLastPeriod(i._currentPlayingPeriodId)&&(i.stop(),i.bufferController.stop(!0),i.eventHandler.dispatchEvent(l.InternalEvent.ContentPlaybackFinished))},this.onPaused=function(){i.bufferController?i.bufferController.onPaused():i.initialWasPlayingBeforeStall=!1},this.onPlay=function(){i.bufferController?i.bufferController.onPlay():i.initialWasPlayingBeforeStall=!0},this.onSeekedHandler=function(){i.lastSeekTarget=i.renderer.getCurrentTime()},this.context=e,this.logger=e.logger,this.settings=e.settings,this.bufferSettings=e.bufferSettings,this.eventHandler=e.eventHandler,this.renderer=e.renderer,this.updateCallback=t,this.initialized=!1,this.initPromise=null,this.started=!1,this.isPeriodSwitchHappeningNow=!1,this.shouldSwitchLoadingPeriod=!1,this.mimeTypes={},this.queuedMediaTypeInfo={},this.segmentDurations=new f.ObjectMap,this.mainTimerID=-1,this.lastCurrentTime=0,this.initialWasPlayingBeforeStall=!1,this.eosSignaled=!1}return e.prototype.areAllCodecsKnown=function(){for(var e in this.mimeTypes)if(this.segmentController.hasOwnProperty(e)&&p.MimeTypeHelper.isAV(e)&&(this.mimeTypes[e]=this.segmentController[e].getCodecs(),!this.mimeTypes[e]))return!1;return!0},e.prototype.areMimeTypesValid=function(){for(var e in this.mimeTypes)if(this.segmentController.hasOwnProperty(e)&&p.MimeTypeHelper.isAV(e)&&!this.mimeTypes[e])return;return!0},e.prototype.tryToFinalizeMediaTypes=function(e){var t=this;this.areAllCodecsKnown()&&this.areMimeTypesValid()?(this.queuedMediaTypeInfo[e.getMimeType()]={periodId:e.getPeriodId(),codec:e.getCodec()},Object.keys(this.queuedMediaTypeInfo).forEach(function(e){var i=t.queuedMediaTypeInfo[e].periodId,n=t.queuedMediaTypeInfo[e].codec;t.finalizeMediaType(i,e,n),delete t.queuedMediaTypeInfo[e]})):this.queuedMediaTypeInfo[e.getMimeType()]={periodId:e.getPeriodId(),codec:e.getCodec()}},e.prototype.finalizeMediaType=function(e,t,i){var n=this;this.getAllSegmentControllers().forEach(function(t){n.isAVMultiplexed(t)&&(n.bufferController.addRequiredMediaType(e,"video/mp4"),n.bufferController.addRequiredMediaType(e,"audio/mp4"),n.bufferController.updateMediaType(e,{mimeType:"audio/mp4",timestampOffset:t.getMPDHandler().getTimestampOffset()}))}),this.segmentController.hasOwnProperty(t)?this.bufferController.updateMediaType(e,{mimeType:t,codec:i}):this.bufferController.updateMediaType(e,{mimeType:t,codec:i})},e.prototype.isAVMultiplexed=function(e){var t=h.CodecStringHelper.extractCodecStrings(e.getCodecs());return Boolean(t.video&&t.audio)},e.prototype.getMaxTimeShift=function(){return this.getTimeShiftHandler().getMaxTimeShift()},e.prototype.storeDrmInitDataFromManifest=function(e){var t=this;if(e){for(var i=this.manifestService.getContentProtectionForAdaptationSet(e),n=[],r=0;r<i.length;r++){var o=i[r];if(o.pssh&&o.pssh.length>0)for(var a=0;a<o.pssh.length;a++)n.push({initData:o.psshData[a],initDataStr:o.pssh[a],systemID:o.schemeIdUri,systemIDraw:o.schemeIdUri.replace("urn:uuid:","").replace(/-/g,""),systemName:o.name})}n.length>0&&n.forEach(function(e){t.renderer.addDrmInitData(e)})}},e.prototype.mustBuffersBeCleared=function(e){var t=this.context.metrics["default"].getHistory(s.Metrics.REQUESTED_REPRESENTATIONS);if(t&&0!==t.length){var i=t.map(function(e){return e.value});return e.some(function(e){return i.some(function(t){return t.equals(e)})})}},e.prototype.setupEventHandlers=function(){this.eventHandler.on(a.PlayerEvent.PeriodSwitch,this.onPeriodSwitchHandler),this.eventHandler.on(a.PlayerEvent.PeriodSwitched,this.onPeriodSwitchedHandler),this.eventHandler.on(a.PlayerEvent.Seeked,this.onSeekedHandler,!0),this.eventHandler.on(l.InternalEvent.EndStallAtGap,this.endStallAtGapHandler,!0),this.eventHandler.on(l.InternalEvent.DrmKidInternalError,this.onDrmKidError,!0)},e.prototype.removeEventHandlers=function(){this.eventHandler.off(a.PlayerEvent.PeriodSwitch,this.onPeriodSwitchHandler),this.eventHandler.off(a.PlayerEvent.PeriodSwitched,this.onPeriodSwitchedHandler),this.eventHandler.off(a.PlayerEvent.Seeked,this.onSeekedHandler),this.eventHandler.off(l.InternalEvent.MPDAvailable,this.mpdUpdateHandler),this.eventHandler.off(a.PlayerEvent.SegmentRequestFinished,this.onSegmentRequestFinished),this.eventHandler.off(a.PlayerEvent.TimeChanged,this.eventHandlerFunctionTimeChanged),this.eventHandler.off(l.InternalEvent.EndStallAtGap,this.endStallAtGapHandler,!0),this.eventHandler.off(l.InternalEvent.FinishPeriodSwitch,this.finishPeriodSwitch,!0),this.eventHandler.off(l.InternalEvent.DrmKidInternalError,this.onDrmKidError,!0)},e.prototype.setupControllerForAdaptationSet=function(e){var t=this.manifestService.getMimeTypeForAdaptationSet(e),i=e.isTransmuxingRequired;if((t.includes("text")||t.includes("ttml+xml"))&&"hls"!==this.sourceType){if(r.ModuleManager.has(o.ModuleName.DASH)&&this.subtitleService){var n=r.ModuleManager.get(o.ModuleName.DASH),a=new n.SegmentTemplateMPDHandler(this.context),d=this.manifestService.getLangObjectFromAdaptationSet(e,t);a.setAdaptationSetId(e._internalId),d.url=a.getSubtitleUrl().toString(),this.subtitleService.addExternalSubtitle(d)}}else if(this.context.metrics[t]=new s.Metrics(this.context,t),this.context.metrics[t].setBufferController(this.bufferController),t.includes("application")){if(this.subtitleService){var u={mimeType:t,codec:this.manifestService.getCodecsFromAdaptationSet(e),isTransmuxingRequired:"hls"===this.sourceType,manifestLoader:this.manifestLoader,periodId:this._currentPlayingPeriodId};this.subtitleService.addFragmentSubtitle(u,e)}}else this.mimeTypes[t]=this.manifestService.getCodecsFromAdaptationSet(e),this.segmentController[t]=new T.SegmentController(this.context,this.onSegmentAvailable,t,this.mimeTypes[t],i,this.manifestLoader,this._currentPlayingPeriodId),this._currentPlayingPeriodId&&this.storeDrmInitDataFromManifest(e);this.context.segmentInfoService&&this.context.segmentInfoService.setSegmentControllers(Object.values(this.segmentController))},e.prototype.setInitialPeriod=function(){this.manifestService.isLive()?this.setInitialPeriodForLive():(this.currentLoadingPeriodId=this.manifestService.getFirstPeriod()._id,this._currentPlayingPeriodId=this.currentLoadingPeriodId)},e.prototype.setInitialPeriodForLive=function(){if(this.manifestService.isLive()){var e=Date.now()/1e3-this.manifestService.getDesiredDistanceToLiveEdge();this.currentLoadingPeriodId=this.manifestService.getPeriodIdForTime(e),this._currentPlayingPeriodId=this.currentLoadingPeriodId}},e.prototype.getCurrentPlayingPeriod=function(){return this.manifestService.findPeriod(this._currentPlayingPeriodId)},e.prototype.getCurrentLoadingPeriodId=function(){return this.currentLoadingPeriodId},e.prototype.updateVideoAndAudioMediaTypes=function(e){var t=e.Adap