UNPKG

bitmovin-player

Version:

The Bitmovin HTML5 Adaptive Streaming Player for MPEG-DASH and HLS

12 lines • 69.3 kB
/**************************************************************************** * 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(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.hls=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.hls=e())}(this,function(){return webpackJsonpbitmovin_player__name_([7],{123:function(t,e,i){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var n,a=i(32),s=i(34),o=i(35),u=i(23),d=i(19),l=i(9),c=i(43),p=i(324),f=i(326);!function(t){t.Mp4="mp4"}(n=e.ContainerFormat||(e.ContainerFormat={}));var h=function(){function t(t){this.adaptationsetId=0,this.context=t,this.representationFactory=new f.M3u8RepresentationFactory(t)}return t.prototype.createCeaCaptionObjects=function(t,e){var i={},r={_schemeIdUri:"urn:scte:dash:cc:cea-"+e+":2015",_value:""},n="=";"708"===e&&(n+="lang:");for(var a=0;a<t.length;a++){var s=t[a]["INSTREAM-ID"];i[s]={lang:t[a].LANGUAGE||t[a].NAME||s,label:t[a].NAME||t[a].LANGUAGE||s},r._value.length>0&&(r._value+=";"),"708"===e?r._value+=s.substr(7)+"=lang:":r._value+=s+"=",r._value+=t[a].LANGUAGE}return{closedCaptionLabel:i,accessibility:r}},t.prototype.createCaptionElements=function(t){if(!t)return{closedCaptionLabel:null,accessibility:[]};var e=this.createCeaCaptionObjects(t.cea608,"608"),i=this.createCeaCaptionObjects(t.cea708,"708"),r=[],n=null;return e.accessibility._value&&(r.push(e.accessibility),n=e.closedCaptionLabel),i.accessibility._value&&r.push(i.accessibility),{closedCaptionLabel:n,accessibility:r}},t.prototype.createAdaptationSetWithUnknownCodecs=function(t,e){var i={_id:String(this.adaptationsetId),_mimeType:"unknown",_internalId:new c.AdaptationSetId(e,String(this.adaptationsetId++)),Representation:[{Uri:l.URLHelper.concatBaseUrlWithPartial(this.baseURL,t.uri),BaseURL:[{url:f.M3u8RepresentationFactory.getBaseUrl(this.baseURL,t.uri)}],_bandwidth:Number(t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH)}],isTransmuxingRequired:!0};return i},t.prototype.createVideoAdaptationSet=function(t,e,i,r,n){for(var s=[],o=1/0,u=0,d=1/0,l=0,p=1/0,f=0,h=null,m="video/"+n,g=0,y=t;g<y.length;g++){var v=y[g];if(v.uri){var T=this.representationFactory.create(v,a.RepresentationType.VIDEO,n,this.baseURL,this.assumeAudioMuxedIntoVideoTs);s.push(T),o=Math.min(o,T._height),u=Math.max(u,T._height),d=Math.min(d,T._width),l=Math.max(l,T._width),p=Math.min(p,T._bandwidth),f=Math.max(f,T._bandwidth)}}s.sort(function(t,e){return t._bandwidth-e._bandwidth});var b={_id:"video",_contentType:"video"},S={Representation:s,ContentComponent:[b],_id:String(this.adaptationsetId),_group:h,_mimeType:m,_internalId:new c.AdaptationSetId(i,String(this.adaptationsetId++)),_minBandwidth:p,_maxBandwidth:f,_minHeight:o,_maxHeight:u,_minWidth:d,_maxWidth:l,_codecs:this.getVideoCodecForPlaylist(t[0],!0),isTransmuxingRequired:!0};r&&Object.keys(r).forEach(function(t){r[t].entries.filter(function(t){return!t.URI}).forEach(function(t){S.ContentComponent.push({_id:t.NAME,_contentType:"audio",_lang:t.LANGUAGE})})});var _=this.createCaptionElements(e);_.closedCaptionLabel&&(S.ClosedCaptionLabels=_.closedCaptionLabel),_.accessibility.length>0&&(S.Accessibility=_.accessibility);var E=this.getLabelForAdaptationSet(S);return E&&"string"==typeof E&&(S._label=E),S},t.prototype.createAudioAdaptationSet=function(t,e,i,r,n){for(var s=[],o=1/0,u=0,d=null,l=0,p=t;l<p.length;l++){var f=p[l];if(f.uri){var h=this.representationFactory.create(f,a.RepresentationType.AUDIO,n,this.baseURL,this.assumeAudioMuxedIntoVideoTs);s.push(h)}}s.sort(function(t,e){return t._bandwidth-e._bandwidth});var m={Representation:s,_id:String(this.adaptationsetId),_group:d,_mimeType:"audio/"+n,_internalId:new c.AdaptationSetId(i,String(this.adaptationsetId++)),_minBandwidth:o,_maxBandwidth:u,_codecs:this.getAudioCodecForPlaylist(t[0],!0),isTransmuxingRequired:!0},g=this.createCaptionElements(e);g.closedCaptionLabel&&(m.ClosedCaptionLabels=g.closedCaptionLabel),g.accessibility.length>0&&(m.Accessibility=g.accessibility);var y=this.getLabelForAdaptationSet(m);return y&&"string"==typeof y&&(m._label=y),m},t.prototype.createAudioAdaptationSets=function(t,e,i){var r=this,n=this.context.settings.IGNORE_HLS_AUDIO_GROUPS,s=0,o=[],u=function(e){return{Representation:[],_id:String(r.adaptationsetId),_internalId:new c.AdaptationSetId(t,String(r.adaptationsetId++)),_mimeType:"audio/"+i,_minBandwidth:1/0,_maxBandwidth:-1,_lang:e,_group:String(s++),_codecs:"",isTransmuxingRequired:!0}};return Object.keys(e).forEach(function(t){var s,d=e[t],l=d.entries.find(function(t){return t.LANGUAGE&&"und"!==t.LANGUAGE});l&&(s=l.LANGUAGE);var c;n||(c=u(s));for(var p in d.entries)if(d.entries.hasOwnProperty(p)&&d.entries[p].URI){n&&(c=u(s));var f=r.representationFactory.create(d.entries[p],a.RepresentationType.AUDIO,i,r.baseURL,r.assumeAudioMuxedIntoVideoTs);c.Representation.push(f),c._minBandwidth=Math.min(c._minBandwidth,f._bandwidth),c._maxBandwidth=Math.max(c._maxBandwidth,f._bandwidth);var h=d.entries[p].CHARACTERISTICS;if(h&&0===h.indexOf(r.context.settings.HLS_VR_CHARACTERISTICS_UTI)&&(c.Role=[{_schemeIdUri:r.context.settings.VR_SCHEME_ID_URI,_value:h.substring(r.context.settings.HLS_VR_CHARACTERISTICS_UTI.length)}]),!c._label){var m=r.getLabelForAdaptationSet(c);m&&"string"==typeof m?c._label=m:f._name?c._label=f._name:c._label=t}n&&c.Representation.length>0&&o.push(c),c.Representation.sort(function(t,e){return t._bandwidth-e._bandwidth})}!n&&c.Representation.length>0&&o.push(c)}),o},t.prototype.createSubtitleAdaptationSets=function(t,e,i){var r=0,n=[];for(var s in e)if(e.hasOwnProperty(s)&&e[s].URI){var o={Representation:[],_id:String(this.adaptationsetId),_internalId:new c.AdaptationSetId(t,String(this.adaptationsetId++)),_mimeType:"application/mp4",_lang:s,_group:""+r++,_isFragmented:!0,_codecs:""},u=this.representationFactory.create(e[s],a.RepresentationType.SUBTITLE,i,this.baseURL,this.assumeAudioMuxedIntoVideoTs);o.Representation.push(u);var d=this.getLabelForAdaptationSet(o);d&&"string"==typeof d?o._label=d:u._name?o._label=u._name:o._label=s,n.push(o)}return n},t.prototype.getLabelForAdaptationSet=function(t){var e={mimeType:t._mimeType,lang:t._lang};t._label&&(e.label=t._label);var i=this.getLabelingFunctionForAdaptationSet();return i(e)},t.prototype.getLabelingFunctionForAdaptationSet=function(){var t=this.context.sourceContext,e=t&&t.source&&t.source.labeling;return e&&e.hls&&e.hls.tracks?"function"!=typeof e.hls.tracks?this.getDefaultLabelForAdaptationSet:e.hls.tracks:this.getDefaultLabelForAdaptationSet},t.prototype.getDefaultLabelForAdaptationSet=function(){return null},t.prototype.handleBackupStreams=function(t){for(var e=0;e<t.length;e++){var i=t[e];i.backupStreamUris=i.backupStreamUris||[];for(var r=e+1;r<t.length;r++){var n=t[r],a=i.attributes.BANDWIDTH===n.attributes.BANDWIDTH,s=i.attributes.RESOLUTION&&n.attributes.RESOLUTION,o=!s||s&&i.attributes.RESOLUTION.height===n.attributes.RESOLUTION.height&&i.attributes.RESOLUTION.width===n.attributes.RESOLUTION.width;a&&o&&(this.context.settings.DISABLE_HLS_BACKUP_STREAM_FAILOVER||i.backupStreamUris.push(n.uri),t.splice(r,1),r--)}}},t.prototype.getDefaultLanguages=function(t){var e=new d.ObjectMap;return t.media.forEach(function(t){var i=Boolean(t.attributes),r=i&&"YES"===t.attributes.DEFAULT,n=i&&Boolean(t.attributes.LANGUAGE),a=t.attributes,s=a.TYPE,o=a.LANGUAGE;r&&n&&!e.get(s)&&e.set(s,o)}),e},t.prototype.createDashManifestSkeleton=function(t,e){var i=e;this.handleBackupStreams(i.playlists),this.playlistPreprocessing(i),this.assumeAudioMuxedIntoVideoTs=!this.hasAudioRenditionsWithUri(i),this.baseURL=l.URLHelper.removeLastPathPart(t);var r={BaseURL:[{url:this.baseURL}],Period:[this.createPeriod(i,"0")],_hls:{defaultLanguages:this.getDefaultLanguages(i),playlist:{master:null},tags:e.tags,hasInitializedExpectedPlaybackTimes:!1}};return r},t.prototype.isVariantOfMimeType=function(t,e){var i=u.CodecStringHelper.getMimeTypeForCodecString(t.attributes.CODECS);return i===e},t.prototype.removeUnsupportedAudioOnlyVariants=function(t){var e=this,i=t.playlists.some(function(t){return e.isVariantOfMimeType(t,"video")}),r=t.playlists.some(function(t){return e.isVariantOfMimeType(t,"audio")});i&&r&&(t.playlists=t.playlists.filter(function(t){return e.isVariantOfMimeType(t,"video")}))},t.prototype.playlistPreprocessing=function(t){this.removeUnsupportedAudioOnlyVariants(t)},t.prototype.getVideoCodecForPlaylist=function(t,e){void 0===e&&(e=!1);var i=u.CodecStringHelper.extractCodecStrings(t.attributes.CODECS);return i.video?(u.CodecStringHelper.hasOldAvc1CodecFormat(i.video)&&(i.video=u.CodecStringHelper.convertAvc1ToAvcotiCodecFormat(i.video)),e?i.video:i.video.split(".")[0]):null},t.prototype.getAudioCodecForPlaylist=function(t,e){void 0===e&&(e=!1);var i=u.CodecStringHelper.extractCodecStrings(t.attributes.CODECS);return i.audio?e?i.audio:i.audio.split(".")[0]:null},t.prototype.getAllVideoCodecs=function(t){var e=this;return t.map(function(t){return e.getVideoCodecForPlaylist(t)}).filter(function(t,e,i){return t&&i.indexOf(t)===e})},t.prototype.getAllAudioCodecs=function(t){var e=this;return t.map(function(t){return e.getAudioCodecForPlaylist(t)}).filter(function(t,e,i){return t&&i.indexOf(t)===e})},t.prototype.groupPlaylistsByCodec=function(t){var e=this.getAllVideoCodecs(t),i=this.getAllAudioCodecs(t);if(0===e.length&&0===i.length)return{unknown:t};if(0===e.length){var r={};return i.forEach(function(e){r[e]=t.filter(function(t){return t.attributes.CODECS&&t.attributes.CODECS.includes(e)})}),r}var n={};return e.forEach(function(e){n[e]=t.filter(function(t){return t.attributes.CODECS&&t.attributes.CODECS.includes(e)})}),n},t.prototype.createPeriod=function(e,i){var r=this,a={_id:i,_duration:"PT0S",duration:0,AdaptationSet:[]},s=m.extractMediaRenditions(e,this.context.settings.IGNORE_HLS_AUDIO_GROUPS),o=this.groupPlaylistsByCodec(e.playlists),d=Object.keys(o),l=d.filter(function(t){return u.CodecStringHelper.isVideoCodec(t)}).map(function(t){return r.createVideoAdaptationSet(o[t],s.captions,a._id,s.audio,n.Mp4)}).filter(function(e){return e.Representation=e.Representation.reduce(function(e,i){var n=t.isRepresentationSupported(i,r.context.renderer),a=Boolean(e.find(function(t){return t.Uri===i.Uri}));return n&&!a&&e.push(i),e},[]),e.Representation.length>0}),c=d.filter(function(t){return"unknown"===t}).flatMap(function(t){return o[t]}).map(function(t){return r.createAdaptationSetWithUnknownCodecs(t,a._id)}),p=this.createAudioAdaptationSets(a._id,s.audio,n.Mp4).filter(function(e){return e.Representation=e.Representation.filter(function(e){return t.isRepresentationSupported(e,r.context.renderer)}),e.Representation.length>0}).concat(d.filter(function(t){return u.CodecStringHelper.isAudioCodec(t)}).map(function(t){return r.createAudioAdaptationSet(o[t],s.captions,a._id,s.audio,n.Mp4)})),f=this.createSubtitleAdaptationSets(a._id,s.subtitles,n.Mp4);return a.AdaptationSet=[].concat(l,p,f,c),a},t.isRepresentationSupported=function(t,e){var i=!t._mimeType.includes("audio")&&!t._mimeType.includes("video");if(!t._codecs||i)return!0;var r=u.CodecStringHelper.extractCodecStrings(t._codecs);return Object.keys(r).every(function(t){return u.CodecStringHelper.isSupportedByRenderer(e,t+"/mp4",r[t])})},t.prototype.hasAudioRenditionsWithUri=function(t){return t.media.some(function(t){return"AUDIO"===t.attributes.TYPE&&Boolean(t.attributes.URI)})},t.prototype.parseContentProtection=function(t,e){var i=t.keyformat,r=Object.keys(o.KeySystemMap).find(function(t){return o.KeySystemMap[t].indexOf(i)>-1});r&&(i=Object.keys(s.DRMSchemeIDURIs).find(function(t){return s.DRMSchemeIDURIs[t]===r}));var n=s.DRMSchemeIDURIs.hasOwnProperty(i);if(n){p.ContentProtectionHelper.isValidPsshBox(e)||(e=p.ContentProtectionHelper.wrapInPsshBox(e,i));var a={schemeIdUri:i,pssh:e};return t.keyid&&(a.defaultKid=t.keyid),a}return null},t.parseBase64DataUrl=function(t){var e=new RegExp(/^data:text\/plain.*;base64.*,(.+)/),i=e.exec(t);return null!==i&&2===i.length?i[1]:null},t.prototype.translateSegmentList=function(e,i,n){var a=this,s=[],o=l.URLHelper.getDomainUrl(e.BaseURL[0].url),u=null,d=[];return n.forEach(function(i,n){i.uri=l.URLHelper.buildAbsoluteUrl(e.BaseURL[0].url,o,i.uri),(i.keys||[]).forEach(function(i){var s=t.parseBase64DataUrl(i.uri);if(null!==s){var c=a.parseContentProtection(i,s),p=Boolean(c)&&void 0!==d.find(function(t){return!Object.keys(c).some(function(e){return c[e]!==t[e]})});c&&!p&&d.push(c),d.length>0&&(u=null)}else{var f=new ArrayBuffer(16);new DataView(f).setInt32(12,e._hls.mediaSequence+n),u=r({iv:f},i,{uri:l.URLHelper.buildAbsoluteUrl(e.BaseURL[0].url,o,i.uri)})}}),i.init&&(i.init.url=l.URLHelper.buildAbsoluteUrl(e.BaseURL[0].url,o,i.init.url),u&&(i.init.key=u));var c={_media:i.uri,_duration:i.duration,_key:u,_metadata:[],_init:i.init};["cueTag","scte35","customTags"].filter(function(t){return i.hasOwnProperty(t)}).forEach(function(t){return c._metadata=c._metadata.concat(i[t])}),i.dateTime&&(c._dateTime=i.dateTime),i.byterange&&(c._byteRange={start:i.byterange.offset,end:i.byterange.offset+i.byterange.length-1}),s.push(c)}),{segments:s,contentProtectionInfos:d}},t.prototype.dispose=function(){this.baseURL=null},t}();e.M3u8Translator=h;var m;!function(t){function e(t,e){var i={};return t.forEach(function(t){var r=e[t["GROUP-ID"]]||e[Object.keys(e)[0]];t.BANDWIDTH=r[0].BANDWIDTH,t.CODECS=r[0].CODECS;var n=t["AVERAGE-BANDWIDTH"]||t.BANDWIDTH,a=i[t.NAME];void 0!==a?(a.entries.push(t),a.MIN_BANDWIDTH=Math.min(a.MIN_BANDWIDTH,n),a.MAX_BANDWIDTH=Math.max(a.MAX_BANDWIDTH,n)):i[t.NAME]={entries:[t],MIN_BANDWIDTH:n,MAX_BANDWIDTH:n}}),i}function i(t){var e={};return t.forEach(function(t){var i=t.LANGUAGE||t.NAME;void 0===e[i]&&(e[i]=t)}),e}function r(t){var e={cea608:[],cea708:[]};return t.forEach(function(t){t["INSTREAM-ID"]&&0===t["INSTREAM-ID"].indexOf("CC")?e.cea608.push(t):t["INSTREAM-ID"]&&0===t["INSTREAM-ID"].indexOf("SERVICE")&&e.cea708.push(t)}),e}function n(t,n){var a=t.playlists,s=t.media.map(function(t){return t.attributes}),u=o(a),d=s.filter(function(t){var e="AUDIO"===t.TYPE,i=u[t["GROUP-ID"]];return e&&(n||i)}),l=s.filter(function(t){return"SUBTITLES"===t.TYPE}),c=s.filter(function(t){return"CLOSED-CAPTIONS"===t.TYPE});return{audio:e(d,u),subtitles:i(l),captions:r(c)}}function a(t){var e={};return t.forEach(function(t){var i=t.attributes.AUDIO;e[i]||(e[i]=[]);var r={BANDWIDTH:t.attributes.BANDWIDTH,CODECS:void 0};t.attributes.CODECS&&t.attributes.CODECS.indexOf(",")>-1&&(r.CODECS=d(t)),e[i].push(r)}),e}function s(t){Object.values(t).forEach(function(t){t.sort(function(t,e){return t.BANDWIDTH-e.BANDWIDTH})})}function o(t){var e=a(t);return s(e),e}function d(t){var e=t.attributes.CODECS.split(",");return e.find(function(t){return u.CodecStringHelper.isAudioCodec(t)})}t.extractMediaRenditions=n,t.getPropertiesForAudioGroups=o}(m=e.HlsParsing||(e.HlsParsing={}))},159:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){this.context=t,this.playbackTimeNextSegment=null,this.allowedGapSizeSec=e}return t.prototype.reset=function(){this.playbackTimeNextSegment=null},t.prototype.trackPlaybackTime=function(t){this.playbackTimeNextSegment=t.getPlaybackTime()+t.getDuration()},t.prototype.checkForTimelineGap=function(t,e,i){return this.calculateGapCheckResult(t,e,i)},t.prototype.calculateGapCheckResult=function(t,e,i){var r,n={hasGap:!1,expectedPlaybackTime:this.playbackTimeNextSegment,actualPlaybackTime:t.getPlaybackTime(),couldHandle:!0};if(null==this.playbackTimeNextSegment);else{r=t.getPlaybackTime()-this.playbackTimeNextSegment;var a=r,s=e.SegmentList[0].SegmentURL,o=i,u=s.some(function(t){return t.downloaded});if(r>this.allowedGapSizeSec&&u){for(;s[o]&&!s[o].downloaded&&o>=0;)o--;n.hasGap=!0,n.couldHandle=!1,n.correctedIndex=o+1,n.gapSizeSec=a}else if(r>this.allowedGapSizeSec){for(;r>this.allowedGapSizeSec;)if(r-=s[o]._duration,o--,o<0){o=0,n.couldHandle=!1;break}n.hasGap=!0,n.gapSizeSec=a,n.correctedIndex=o}else if(r+t.getDuration()<-this.allowedGapSizeSec){for(;r+s[o]._duration<-this.allowedGapSizeSec;)if(r+=s[o]._duration,o++,o>=s.length){o=s.length;break}n.hasGap=!0,n.gapSizeSec=a,n.correctedIndex=o}}return n},t}();e.HlsTimelineTracker=r},160:function(t,e,i){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var n,a=i(85),s=i(50),o=i(1),u=i(111),d=i(17),l=i(8),c=i(3),p=i(4),f=i(5),h=i(6),m=i(15),g=i(12),y=i(323),v=i(325),T=i(123),b=i(327),S=i(328),_=i(59);!function(t){t[t.NoBackupStreams=0]="NoBackupStreams",t[t.LoadingFailed=1]="LoadingFailed"}(n=e.BackupStreamErrors||(e.BackupStreamErrors={}));var E=function(t){return t.playlists.length>0},M=function(t){return t.segments.length>0},I=function(t){return _.isMasterPlaylist(t)&&E(t)||_.isMediaPlaylist(t)&&M(t)},A=function(t,e){var i=t.MINIMUM_ALLOWED_UPDATE_PERIOD,r=e.segments[e.segments.length-1];return void 0!==r&&(i=Math.max(i,r.duration)),i};e.parseHlsManifest=function(t,e){var i=a.HlsUtils.parsePlaylist(e,t.logger);if("playlists"in i){var r=i.playlists.filter(function(e){return e.attributes.BANDWIDTH>=t.settings.HLS_AUDIO_ONLY_THRESHOLD_BITRATE});i.playlists=r.length?r:i.playlists}return i},e.ensureMasterPlaylist=function(t,i,r){if(_.isMasterPlaylist(i))return i;var n=["#EXTM3U","#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0",r].join("\n"),a=e.parseHlsManifest(t,n);if(!_.isMasterPlaylist(a))throw new Error("Template is not of type HLS MasterPlaylist");return a};var R=function(){function t(t){var e=this;this.updateLoaders={},this.onFirstPlaylistsLoaded=function(t){e.hasLoadedFirstPlaylists=!0,e.analyzeFirstVariants(t),e.translatedManifest.isLive()&&e.registerReloadControlHandlers();var i=e.translatedManifest.getManifest();return e.context.eventHandler.dispatchEvent(h.InternalEvent.MPDAvailable,{manifest:i},!0),i},this.onMasterLoaded=function(t,i){return e.isCancelled?Promise.reject():e.verifyMissingCodecs(t,i).then(function(t){return e.cachedVariantPlaylists=t.loadedVariantPlaylists,e.handleMasterPlaylist(t.masterPlaylist,i),e.loadFirstVariants().then(e.onFirstPlaylistsLoaded)["catch"](function(){return e.context.eventHandler.fireError(new p.PlayerError(c.ErrorCode.SOURCE_HLS_STREAM_ERROR)),Promise.reject({code:c.ErrorCode.SOURCE_HLS_STREAM_ERROR})})})["catch"](function(t){var i=t instanceof p.PlayerError?t:new p.PlayerError(c.ErrorCode.SOURCE_MANIFEST_INVALID);return e.context.eventHandler.fireError(i),Promise.reject(i)})},this.context=t,this.registeredOnPlayEventHandlers=[],this.registeredOnPausedEventHandlers=[],this.cachedVariantPlaylists=[],this.discontinuitySequences=[],this.isFirstPlaylist=!0,this.isCancelled=!1,this.areReloadTimersSetup=!1,this.hasLoadedFirstPlaylists=!1,this.updateInterval=1/0,this.variantUpdaters={},this.manifestService=t.serviceManager.get(f.ServiceName.ManifestService),this.translatedManifest=new v.M3u8DashManifest(t),this.loaders={master:this.createLoader(l.HttpRequestType.MANIFEST_HLS_MASTER),video:this.createLoader(l.HttpRequestType.MANIFEST_HLS_VARIANT),audio:this.createLoader(l.HttpRequestType.MANIFEST_HLS_VARIANT),subs:this.createLoader(l.HttpRequestType.MEDIA_SUBTITLES)}}return t.prototype.loadFirstVariants=function(){var t=[],e=this.translatedManifest.getFirstVideoAdaptationSet(),i=this.translatedManifest.getFirstAudioAdaptationSet();return e&&t.push(this.loadFirstPlaylist(e)),i&&t.push(this.loadFirstPlaylist(i)),this.translatedManifest.removeInitialPeriod(),Promise.all(t)},t.prototype.loadFirstPlaylist=function(t){var e=this,i=g.MimeTypeHelper.extractContentType(t._mimeType),r=this.getStartRepresentation(t.Representation,i);return r?this.updateRepresentation(r).then(function(){return r})["catch"](function(){return t.Representation=t.Representation.filter(function(t){return t!==r}),e.loadFirstPlaylist(t)}):Promise.reject("all failed")},t.prototype.getStartRepresentation=function(t,e){var i,r;switch(e){case"audio":i=this.context.settings.MIN_SELECTABLE_AUDIO_BITRATE,r=this.context.settings.MAX_SELECTABLE_AUDIO_BITRATE;break;case"video":i=this.context.settings.MIN_SELECTABLE_VIDEO_BITRATE,r=this.context.settings.MAX_SELECTABLE_VIDEO_BITRATE}var n=t.find(function(t){return t._bandwidth>=i&&t._bandwidth<=r}),a=n||t[t.length-1];return a},t.prototype.updateAdaptationSet=function(t){var e=this,i=this.translatedManifest.findAdaptationSet(t);return i?Promise.all(i.Representation.map(function(t){var i=e.createLoader(l.HttpRequestType.MANIFEST_HLS_VARIANT);return e.loadPlaylist(i,t.Uri).then(function(i){e.onMediaLoaded(i.body,t.Uri,t._mimeType)})})):Promise.reject("Could not find data")},t.prototype.analyzeFirstVariants=function(t){var e=this;t.forEach(function(t){g.MimeTypeHelper.isAudio(t._mimeType)?(e.variantUpdaters.audio&&e.variantUpdaters.audio.stop(),e.variantUpdaters.audio=new b.M3u8Updater(e,t,e.updateInterval)):g.MimeTypeHelper.isVideo(t._mimeType)&&(e.variantUpdaters.video&&e.variantUpdaters.video.stop(),e.variantUpdaters.video=new b.M3u8Updater(e,t,e.updateInterval))})},t.prototype.verifyMissingCodecs=function(t,i){var n=e.parseHlsManifest(this.context,t);if(!I(n))return Promise.reject("invalid playlist");var a=r({},e.ensureMasterPlaylist(this.context,n,i),{rawString:t}),s=new T.M3u8Translator(this.context),o=s.createDashManifestSkeleton(i,a),u=o.Period.flatMap(function(t){return t.AdaptationSet.filter(function(t){return g.MimeTypeHelper.isUnknown(t._mimeType)})});if(0===u.length)return Promise.resolve({masterPlaylist:a,loadedVariantPlaylists:[]});var d=_.isMasterPlaylist(n)?[]:[{uri:i,playlistText:t,requestTimestamp:Date.now()}],l=this.parseMissingCodecs(a,u,d,s);return l},t.prototype.parseMissingCodecs=function(t,i,r,n){var a=this,s=i.map(function(t){var e=t.Representation;return e[0]}).filter(function(t){return!!t});i.forEach(function(t){t.Representation=t.Representation.slice(1)});var o=this.getStartRepresentation(s,"video");if(!o)return Promise.reject("all failed");var u=o.Uri,d=r.find(function(t){return t.uri===u}),l=d?Promise.resolve(d.playlistText):this.loadPlaylist(new m.DefaultContentLoader(this.context),u).then(function(t){return t.body});return l.then(function(t){d||r.push({uri:u,playlistText:t,requestTimestamp:Date.now()});var i=e.parseHlsManifest(a.context,t);o._hls={mediaSequence:i.mediaSequence};var s=n.translateSegmentList(o,i,i.segments),l=!i.endList;return new y.CodecDetector(a.context).probeCodecs(s.segments,l)}).then(function(e){return t.playlists.filter(function(t){return!t.attributes.hasOwnProperty("CODECS")}).forEach(function(t){t.attributes.CODECS=e}),{masterPlaylist:t,loadedVariantPlaylists:r}})},t.prototype.handleMasterPlaylist=function(t,e){var i=this;void 0===this.masterPlaylist&&(this.masterPlaylist=t),this.translatedManifest.onMasterPlaylistAvailable(t,e);var r=this.translatedManifest.getAllVariantRepresentions();r.video.forEach(function(t){i.updateLoaders[t._id]=i.createLoader(l.HttpRequestType.MANIFEST_HLS_VARIANT,{resetRetriesWhenOffline:!0})});var n=r.audio.concat(r.subtitles);n.forEach(function(t){i.updateLoaders[t._id]=i.createLoader(l.HttpRequestType.MANIFEST_HLS_VARIANT)})},t.prototype.onMediaLoaded=function(t,i,r,n){var a=this;if(void 0===n&&(n=Date.now()),!this.isCancelled){var s=e.parseHlsManifest(this.context,t),o=S.M3u8Validator.checkForError(s);if(o)return u.M3u8Error.INAVLID;s.mediaSequence=s.mediaSequence||0,this.isFirstPlaylist&&(this.isFirstPlaylist=!1),s.endList||this.signalLiveStream(),s.start=s.start||this.masterPlaylist.start,this.discontinuitySequences=_.PlaylistUtils.createDiscontinuitySequences(s,this.discontinuitySequences),this.discontinuitySequences.forEach(function(t){return _.PlaylistUtils.extrapolateProgramDateTime(t.segments)}),this.discontinuitySequences.forEach(function(t,e){t.indexOfFirstSegment=0===e?0:a.discontinuitySequences[e-1].indexOfLastSegment+1,t.indexOfLastSegment=t.indexOfFirstSegment+t.segments.length-1});var d=this.filterTooSmallPeriods(this.discontinuitySequences,Boolean(s.endList));this.translatedManifest.onMediaLoaded(t,i,r,s,d,n,this.hasLoadedFirstPlaylists),this.translatedManifest.isLive()&&this.setUpdateInterval(s)}},t.prototype.filterTooSmallPeriods=function(t,e){return t.filter(function(i,r){var n=!e&&r===t.length-1,a=i.segments.reduce(function(t,e){return t+e.duration},0);return!!(0===r&&a>0||n)||a>0})},t.prototype.registerReloadControlHandlers=function(){var t=this;this.startReloadTimers(!1);var e=function(){t.startReloadTimers()},i=function(){t.context.settings.STOP_DOWNLOAD_ON_PAUSE&&t.cancelReloadTimers()};this.context.eventHandler.on(o.PlayerEvent.Play,e),this.context.eventHandler.on(o.PlayerEvent.Paused,i),this.registeredOnPlayEventHandlers.push(e),this.registeredOnPausedEventHandlers.push(i)},t.prototype.cancelReloadTimers=function(){this.areReloadTimersSetup&&(this.areReloadTimersSetup=!1,this.getVariantUpdaters().forEach(function(t){return t.stop()}))},t.prototype.setUpdateInterval=function(t){var e=A(this.context.settings,t);this.updateInterval=e,this.getVariantUpdaters().forEach(function(t){return t.setUpdateInterval(e)})},t.prototype.getVariantUpdaters=function(){var t=this;return Object.keys(this.variantUpdaters).map(function(e){return t.variantUpdaters[e]}).filter(function(t){return!!t})},t.prototype.startReloadTimers=function(t){void 0===t&&(t=!0),this.areReloadTimersSetup||(this.areReloadTimersSetup=!0,this.getVariantUpdaters().forEach(function(e){return t?e.start():e.delayedStart()}))},t.prototype.signalLiveStream=function(){var t;for(t in this.loaders)this.loaders.hasOwnProperty(t)&&this.loaders[t].setMaxRetries(1/0)},t.prototype.stop=function(){var t=this;for(var e in this.loaders)this.loaders.hasOwnProperty(e)&&this.loaders[e].cancel();this.registeredOnPlayEventHandlers.forEach(function(e){return t.context.eventHandler.off(o.PlayerEvent.Play,e)}),this.registeredOnPausedEventHandlers.forEach(function(e){return t.context.eventHandler.off(o.PlayerEvent.Paused,e)}),this.registeredOnPlayEventHandlers=[],this.registeredOnPausedEventHandlers=[],this.cancelReloadTimers(),this.isCancelled=!0},t.prototype.load=function(t){var e=this;return this.loadPlaylist(this.loaders.master,t).then(function(t){return e.onMasterLoaded(t.body,t.url)})["catch"](function(t){if(t){var i=e.getErrorFromRequest(t);e.context.eventHandler.fireError(i)}return Promise.reject(null)})},t.prototype.setCurrentRepresentationForLive=function(t){g.MimeTypeHelper.isAudio(t._mimeType)&&this.variantUpdaters.audio?this.variantUpdaters.audio.setRepresentation(t):g.MimeTypeHelper.isVideo(t._mimeType)&&this.variantUpdaters.video&&this.variantUpdaters.video.setRepresentation(t)},t.prototype.addSubtitleVariantUpdater=function(t){return this.variantUpdaters.subtitle&&this.variantUpdaters.subtitle.stop(),this.variantUpdaters.subtitle=new b.M3u8Updater(this,t,this.updateInterval),this.variantUpdaters.subtitle.start()},t.prototype.removeSubtitleVariantUpdater=function(t){this.variantUpdaters.subtitle&&(this.variantUpdaters.subtitle.stop(),this.variantUpdaters.subtitle=void 0)},t.prototype.updateRepresentation=function(t,e,i){var r=this;void 0===e&&(e=this.translatedManifest.isLive()),void 0===i&&(i=!1);var n=this.getVariantUpdaters()[0],a=n&&n.getUpdateInterval()||1/0;if(e){var s=(Date.now()-t._requestTimestamp)/1e3;if(s<=a)return i?Promise.reject(null):Promise.resolve(t._id)}var o,d=this.cachedVariantPlaylists.find(function(e){return e.uri===t.Uri}),l=d?(Date.now()-d.requestTimestamp)/1e3:1/0;if(d&&l<=a)o=Promise.resolve(d.playlistText),this.cachedVariantPlaylists.splice(this.cachedVariantPlaylists.indexOf(d),1);else{var c=this.updateLoaders[t._id];o=this.loadPlaylist(c,t.Uri).then(function(t){return t.body})}return o.then(function(e){var i=d&&d.requestTimestamp,n=r.onMediaLoaded(e,t.Uri,t._mimeType,i);if(n)throw n;return t._id})["catch"](function(){return r.switchToBackupStream(t)["catch"](function(){throw u.M3u8Error.COULD_NOT_LOAD})})},t.prototype.loadPlaylist=function(t,e){if(e){this.isCancelled=!1;var i=this.context.sourceContext,r=i.source&&i.source.hasOwnProperty("options"),n=r&&i.source.options.hasOwnProperty("manifestWithCredentials");return n=n&&Boolean(i.source.options.manifestWithCredentials),t.load(e,l.HttpRequestMethod.GET,null,null,null,n)}return this.context.eventHandler.fireError(new p.PlayerError(c.ErrorCode.SOURCE_INVALID)),Promise.reject(c.ErrorCode[c.ErrorCode.SOURCE_INVALID])},t.prototype.createLoader=function(t,e){var i=this;void 0===e&&(e={});var n=new m.DefaultContentLoader(this.context,r({onSuccess:function(t,e){t.length&&i.context.metrics["default"].set(d.Metrics.DOWNLOAD_INFORMATION,{bytes:t.length,time:t.elapsedTime,timeToFirstByte:t.timeToFirstByte})},maxRetries:this.context.settings.MAX_MPD_RETRIES,requestType:t},e));return n},t.prototype.getManifestType=function(){return"m3u8"},t.prototype.getErrorFromRequest=function(t){var e=new p.PlayerError(c.ErrorCode.SOURCE_COULD_NOT_LOAD_MANIFEST,{statusCode:t.status});return t.status===XMLHttpRequest.UNSENT&&(e=new p.PlayerError(c.ErrorCode.NETWORK_ERROR)),e},t.prototype.hasBackupStreams=function(t){return t.backupUris&&t.backupUris.length>0},t.prototype.switchToBackupStream=function(t){return this.hasBackupStreams(t)?this.rotatePlaylistUrl(t)["catch"](function(){return Promise.reject(n.LoadingFailed)}):Promise.reject(n.NoBackupStreams)},t.prototype.rotatePlaylistUrl=function(t,e){var i=this;if(void 0===e&&(e=[]),!this.hasBackupStreams(t))return Promise.reject(n.NoBackupStreams);var r=t.Uri,a=t.backupUris.shift();return e.push(r),t.Uri=a,this.updateRepresentation(t)["catch"](function(){return i.rotatePlaylistUrl(t,e)["catch"](function(i){throw t.backupUris.push(e.shift()),i})}).then(function(){t.backupUris.push(e.shift())})},t.prototype.dispose=function(){var t=this;this.cancelReloadTimers(),this.variantUpdaters={},this.translatedManifest=s.dispose(this.translatedManifest),this.masterPlaylist=null,this.manifestService=null,Object.keys(this.loaders).forEach(function(e){return t.loaders[e].dispose()}),this.loaders=null,Object.keys(this.updateLoaders).forEach(function(e){return t.updateLoaders[e].dispose()}),this.updateLoaders=null},t}();e.M3u8Loader=R},323:function(t,e,i){"use strict";function r(t){for(var e="",i=0,r=t;i<r.length;i++){var n=r[i];if(!n.getCodec())return null;e+=(""===e?"":",")+n.getCodec()}return e}function n(t){for(var e=t.getData(),i=new DataView(e,0,e.byteLength),r=[],n=0;n+8<i.byteLength;){var a=i.getUint32(n);if(0===a)break;var s=c.ArrayHelper.extractAsciiString(i,n+4,4);r.push(s),n+=a}return t.isInit()?["ftyp","moov"].every(function(t){return r.includes(t)}):["moof","mdat"].every(function(t){return r.includes(t)})}function a(t,e){var i=e&&e._byteRange?e._byteRange:void 0,r=e&&e._key?e._key:void 0;return{url:t,key:r,byteRange:i,downloaded:!1,mimeType:"unknown/mp4",internalRepresentationId:null,isInitSegment:Boolean(e._init)}}Object.defineProperty(e,"__esModule",{value:!0});var s=i(2),o=i(0),u=i(48),d=i(4),l=i(15),c=i(10),p=function(){function t(t){this.ContainerMp4Module=s.ModuleManager.get(o.ModuleName.ContainerMP4,!1),this.context=t,this.loader=new l.DefaultContentLoader(this.context),this.defaultMetrics=this.context.metrics["default"],this.ContainerMp4Module&&(this.mp4Parser=new this.ContainerMp4Module.MP4Parser(this.context)),this.initTransmuxer(),this.CryptoApiModule=s.ModuleManager.get(o.ModuleName.Crypto,!1)}return t.prototype.initTransmuxer=function(){var t=s.ModuleManager.get(o.ModuleName.ContainerTS,!1);t&&(this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new t.WebWorkerTransmuxer(this.context))},t.prototype.fetchSegment=function(t){if(!this.context.segmentPrefetchingService)return Promise.reject(); var e=this.context.segmentPrefetchingService.hasPrefetchedSegment(t)?this.context.segmentPrefetchingService.getPrefetchedSegment(t):this.context.segmentPrefetchingService.fetch(t);return e?e:Promise.reject()},t.prototype.probeCodecs=function(t,e){var i=this,r=t.slice();if(0===r.length)throw"could not load any segment";var n=e?r.pop():r.shift(),s=Boolean(n._init)?n._init.url:n._media,o=a(s,n);return this.fetchSegment(o).then(function(t){return i.extractCodecsFromSegment(t)})["catch"](function(t){if(t instanceof d.PlayerError)throw t;return i.initTransmuxer(),i.probeCodecs(r,e)}).then(function(t){return i.transmuxer&&i.transmuxer.dispose(),t})},t.prototype.extractCodecsFromSegment=function(t){return n(t)?this.extractCodecFromMp4Parser(t):this.extractCodecFromTransmuxer(t)},t.prototype.extractCodecFromTransmuxer=function(t){return s.ModuleManager.has(o.ModuleName.ContainerTS)?this.transmuxer.transmuxSegment(t).then(function(e){var i=r(e.transmuxedSegments);if(!i)throw"couldn't detect codec for "+t.getMimeType();return i}):Promise.reject(new u.PlayerModuleMissingError(o.ModuleName.ContainerTS))},t.prototype.extractCodecFromMp4Parser=function(t){if(!s.ModuleManager.has(o.ModuleName.ContainerMP4))return Promise.reject(new u.PlayerModuleMissingError(o.ModuleName.ContainerMP4));this.mp4Parser.parseSegment(t);var e=this.ContainerMp4Module.MP4Parser.getVideoCodec(t.getParsedData());return e?Promise.resolve(e):Promise.reject("couldn't detect codec for "+t.getMimeType())},t}();e.CodecDetector=p,e.mergeSegmentCodecs=r,e.isFmp4Segment=n},324:function(t,e,i){"use strict";function r(t){var e=n.ModuleManager.get(a.ModuleName.DRM).PlayReady,i=u.ArrayHelper.stringToArrayWithoutEncoding(atob(t));return e.kidToCENC(i),u.ArrayHelper.arrayBufferToAsciiString(i.buffer)}Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),a=i(0),s=i(34),o=i(41),u=i(10),d=function(){function t(){}return t.extractUint32FromString=function(t,e){return(t.charCodeAt(e)<<24)+(t.charCodeAt(e+1)<<16)+(t.charCodeAt(e+2)<<8)+t.charCodeAt(e+3)},t.parseKeyIds=function(e,i){if("playready"!==s.DRMSchemeIDURIs[i]||!n.ModuleManager.has(a.ModuleName.DRM))return[];var o=n.ModuleManager.get(a.ModuleName.DRM).PlayReady,u=o.parseWrmHeader(e,4);if(!u||0===u.length)return[];var d=o.extractKeyIdsFromPlayReadyHeaders(u);return d&&0!==d.length?d.map(function(t){return r(t)}).map(function(e){return[t.extractUint32FromString(e,0),t.extractUint32FromString(e,4),t.extractUint32FromString(e,8),t.extractUint32FromString(e,12)]}):[]},t.writeKeySystemId=function(t,e,i){return t.setUint32(e,parseInt(i.substring(0,8),16)),e+=4,t.setUint32(e,parseInt(i.substring(8,16),16)),e+=4,t.setUint32(e,parseInt(i.substring(16,24),16)),e+=4,t.setUint32(e,parseInt(i.substring(24,32),16)),e+=4},t.writeKeyIds=function(t,e,i){t.setUint32(e,i.length),e+=4;for(var r=0;r<i.length;r++)t.setUint32(e,i[r][0]),e+=4,t.setUint32(e,i[r][1]),e+=4,t.setUint32(e,i[r][2]),e+=4,t.setUint32(e,i[r][3]),e+=4;return e},t.extractKeySystemIdFromUri=function(t){return t.replace(/-/g,"").split(":")[2]},t.wrapInPsshBox=function(t,e){var i=u.ArrayHelper.stringToArrayWithoutEncoding(atob(t)),r=this.parseKeyIds(i,e),n=r.length>0,a=o.ISOBMFFConstants.BOX_SIZE_LENGTH+o.ISOBMFFConstants.BOX_TYPE_LENGTH+o.ISOBMFFConstants.FULL_BOX_VERSION_LENGTH+o.ISOBMFFConstants.FULL_BOX_FLAGS_LENGTH+o.ISOBMFFConstants.PSSH_SYSTEM_ID_LENGTH+o.ISOBMFFConstants.PSSH_DATA_SIZE;n&&(a+=o.ISOBMFFConstants.PSSH_KID_COUNT_LENGTH+r.length*o.ISOBMFFConstants.PSSH_KID_LEN);var s=this.extractKeySystemIdFromUri(e),d=a+i.byteLength,l=new Uint8Array(d),c=new DataView(l.buffer),p=0;if(c.setUint32(p,d),p+=4,c.setUint32(p,1886614376),p+=4,c.setUint8(p,n?1:0),p+=1,p+=3,!s||32!==s.length)return String.fromCharCode.apply(null,i);p=this.writeKeySystemId(c,p,s),n&&(p=this.writeKeyIds(c,p,r)),c.setUint32(p,i.length),p+=4;for(var f=0;f<i.byteLength;f++)c.setUint8(p+f,i[f]);return btoa(String.fromCharCode.apply(null,l))},t.parseBoxSize=function(t){var e=new DataView(t.buffer,0);return e.getUint32(0)},t.parseBoxType=function(t){var e=new DataView(t.buffer,4);return String.fromCharCode(e.getUint8(0))+String.fromCharCode(e.getUint8(1))+String.fromCharCode(e.getUint8(2))+String.fromCharCode(e.getUint8(3))},t.isValidPsshBox=function(t){var e=u.ArrayHelper.stringToArrayWithoutEncoding(atob(t)),i=this.parseBoxSize(e),r=this.parseBoxType(e);return i===e.byteLength&&"pssh"===r},t}();e.ContentProtectionHelper=d},325:function(t,e,i){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var n=i(50),a=i(9),s=i(77),o=i(5),u=i(6),d=i(12),l=i(19),c=i(123),p=i(59),f=function(){function t(t){this.context=t,this.m3u8Translator=new c.M3u8Translator(t)}return t.prototype.getFirstVideoAdaptationSet=function(){return this.dashManifest.Period[0].AdaptationSet.find(function(t){var e=t._mimeType;return d.MimeTypeHelper.isVideo(e)})},t.prototype.getFirstAudioAdaptationSet=function(){var t=this.dashManifest._hls.defaultLanguages.get("AUDIO");return this.dashManifest.Period[0].AdaptationSet.find(function(e){var i=e._mimeType,r=e._lang;return d.MimeTypeHelper.isAudio(i)&&(!t||r===t)})},t.prototype.findAdaptationSet=function(t){return this.dashManifest.Period.flatMap(function(t){return t.AdaptationSet}).find(function(e){return e._internalId.adaptationSetId===t})},t.prototype.onMasterPlaylistAvailable=function(t,e){void 0===this.dashManifest&&(this.m3u8Translator=new c.M3u8Translator(this.context),this.dashManifest=r({},this.m3u8Translator.createDashManifestSkeleton(e,t),{_hasIndependentSegments:t.independentSegments}),this.dashManifest._hls=r({},this.dashManifest._hls,{playlist:r({},this.dashManifest._hls.playlist,{master:t.rawString}),playlists:{},timeSync:new l.ObjectMap,discontinuitySequenceTiming:{}})),this.masterPlaylist=t},t.prototype.getManifest=function(){return this.dashManifest},t.prototype.getAllVariantRepresentions=function(){var t={video:[],audio:[],subtitles:[]};return this.dashManifest.Period[0].AdaptationSet.forEach(function(e){var i,r,n;d.MimeTypeHelper.isVideo(e._mimeType)?(i=t.video).push.apply(i,e.Representation):d.MimeTypeHelper.isAudio(e._mimeType)?(r=t.audio).push.apply(r,e.Representation):d.MimeTypeHelper.isSubtitle(e._mimeType)&&(n=t.subtitles).push.apply(n,e.Representation)}),t},t.prototype.removeInitialPeriod=function(){this.dashManifest.Period=[]},t.prototype.onMediaLoaded=function(t,e,i,r,n,a,s){var l=this;this.dashManifest._hls.playlist.master||(this.dashManifest._hls.playlist.master=t),r.hasOwnProperty("playlistType")&&!this.dashManifest._hls.hasOwnProperty("playlistType")&&(this.dashManifest._hls.playlistType=r.playlistType),this.dashManifest._requestTimestamp=Date.now(),this.dashManifest._hasIndependentSegments=this.dashManifest._hasIndependentSegments||r.independentSegments;var c=r.totalDuration;d.MimeTypeHelper.isAV(i)&&this.initDashManifestProperties(r),r.start&&(this.dashManifest._startOffset=p.PlaylistUtils.getStartOffset(r)),this.dashManifest.Period.forEach(function(t){return t.droppedOut=Number(t._id)<n[0].id});var f,h=[];if(n.forEach(function(t){var i=l.dashManifest.Period.find(function(e){return Number(e._id)===t.id});i||(i=l.m3u8Translator.createPeriod(l.masterPlaylist,String(t.id)),l.dashManifest.Period.push(i));var n=l.getRepresentationsFromUrl(e,i);n.forEach(function(e){e._requestTimestamp=a,e._hls.requestTimestamp=a,e._hls.mediaSequence=r.mediaSequence,l.updateSegmentList(e,r,t),h.push(e._id),f=f||e.BaseURL[0].url})}),h.forEach(function(t){l.calculatePlaylistStartTime(r,a),l.savePlaylistInMpd(r,t,f);var e=l.dashManifest._hls.playlists[t].segments;l.trackDiscontinuityStartAndEndTimes(n,e),l.updateAllPeriodStartAndDuration(l.dashManifest,r.startTime,n);var i=e.length>0&&null==e[0].expectedPlaybackTime;i&&l.initExpectedPlaybackTimesFromDiscoSequenceStartTime(t,n)}),this.dashManifest.Period[0]&&!this.dashManifest.Period[0].DateRange&&(this.dashManifest.Period[0].DateRange=[]),r.segments.filter(function(t){return t.dateRange}).forEach(function(t){l.isDateRangeAlreadyPresent(t.dateRange)?l.updateDateRange(t.dateRange):l.dashManifest.Period[0].DateRange.push(t.dateRange)}),this.dashManifest._hls.endlist=Boolean(r.endList),r.endList||this.updateTimeShiftBufferDepth(c,this.dashManifest),this.isLive()&&this.dashManifest.hasOwnProperty("_minimumUpdatePeriod")&&(this.dashManifest.Period[this.dashManifest.Period.length-1].duration=1/0),s){var m=this.context.serviceManager.get(o.ServiceName.ManifestService);this.dashManifest=m.preProcessManifest(this.dashManifest),this.context.eventHandler.dispatchEvent(u.InternalEvent.MPDAvailable,{manifest:this.dashManifest},!0)}},t.prototype.setPeriodStartAndDuration=function(t,e,i){t.start=e,t._start="PT"+e+"S",t.duration=i,t._duration="PT"+i+"S"},t.prototype.updateAllPeriodStartAndDuration=function(t,e,i){var r=this;t.Period.forEach(function(n){var a=t._hls.discontinuitySequenceTiming[n._id];if(0===a.startTime&&0===a.endTime){for(var s=void 0,o=0,u=0,d=i;u<d.length;u++){var l=d[u];if(l.id===Number(n._id)){s=l.duration;break}o+=l.duration}var c=e+o;r.setPeriodStartAndDuration(n,c,s)}else if(null!=a.startTime&&null!=a.endTime){var s=a.endTime-a.startTime;r.setPeriodStartAndDuration(n,a.startTime,s)}})},t.prototype.initDashManifestProperties=function(t){var e=t.totalDuration;this.totalDurationSec&&e>this.totalDurationSec||(this.totalDurationSec=e,t.endList?(this.dashManifest._type="static",this.dashManifest._mediaPresentationDuration="PT"+e+"S"):(this.dashManifest._type="dynamic",this.dashManifest._mediaPresentationDuration=1/0,this.dashManifest._minimumUpdatePeriod="PT"+t.targetDuration+"S",this.dashManifest._availabilityStartTime=this.dashManifest._availabilityStartTime||this.dashManifest._requestTimestamp-1e3*e,this.dashManifest._timeShiftBufferDepth=-e),this.dashManifest._maxSegmentDuration="PT"+t.targetDuration+"S")},t.prototype.updateTimeShiftBufferDepth=function(t,e){e._timeShiftBufferDepth=-t},t.prototype.getRepresentationsFromUrl=function(t,e){return e.AdaptationSet.flatMap(function(e){return e.Representation.filter(function(e){return a.URLHelper.isSubUrl(t,e.Uri)})})},t.prototype.savePlaylistInMpd=function(t,e,i){this.dashManifest._hls.playlists[e]||(this.dashManifest._hls.playlists[e]={segments:[],startTime:t.startTime});var r=this.dashManifest._hls.playlists[e].segments;p.PlaylistUtils.updateList(r,t.segments,i),p.PlaylistUtils.extrapolateExpectedPlaybackTimeFromLastKnown(r)},t.prototype.updateSegmentList=function(e,i,r){if(0===r.segments.length);else if(e.hasOwnProperty("SegmentList")){var n=this.m3u8Translator.translateSegmentList(e,i,r.segments);n&&(n.contentProtectionInfos.length>0&&(e.ContentProtection=t.contentProtectionToXmlJson(n.contentProtectionInfos)),e.SegmentList[0].SegmentURL=n.segments),e.SegmentList[0]._duration=i.targetDuration,e.SegmentList[0]._timescale=1}},t.prototype.trackDiscontinuityStartAndEndTimes=function(t,e){var i=this;t.forEach(function(t){i.dashManifest._hls.discontinuitySequenceTiming[String(t.id)]||(i.dashManifest._hls.discontinuitySequenceTiming[String(t.id)]={startTime:0,endTime:0});var r=i.dashManifest._hls.discontinuitySequenceTiming[String(t.id)],n=e[t.indexOfFirstSegment].expectedPlaybackTime,a=e[t.indexOfLastSegment].expectedPlaybackTime+e[t.indexOfLastSegment].duration;null!=n&&null!=a&&(r.startTime=Math.max(r.startTime,n),i.isLive()?r.endTime=Math.max(r.endTime,a):r.endTime=Math.min(r.endTime||1/0,a))})},t.prototype.initExpectedPlaybackTimesFromDiscoSequenceStartTime=function(t,e){var i=this.dashManifest._hls.discontinuitySequenceTiming,r=Object.keys(i),n=r[r.length-1],a=i[n],o=0!==a.startTime&&0!==a.startTime;if(o){var u=e.find(function(t){return String(t.id)===n}),d=this.dashManifest._hls.discontinuitySequenceTiming[n].startTime;u&&u.segments[0].discontinuity&&s.ManifestService.extrapolateExpectedPlaybackTime(this.dashManifest._hls.playlists[t].segments,u.indexOfFirstSegment,d)}},t.prototype.calculatePlaylistStartTime=function(t,e){var i=t.segments[0];if(t.endList)t.startTime=0,t.segments[0].expectedPlaybackTime=t.startTime;else if(i&&i.dateTime)t.startTime=i.dateTime.getTime()/1e3,t.segments[0].expectedPlaybackTime=t.startTime;else{var r=e/1e3-t.totalDuration;t.startTime=r}},t.prototype.updateDateRange=function(t){var e=this.dashManifest.Period[0].DateRange.findIndex(function(e){return e.id===t.id});this.dashManifest.Period[0].DateRange.splice(e,1,t)},t.prototype.isDateRangeAlreadyPresent=function(t){return this.dashManifest.Period[0].DateRange.find(function(e){return e.id===t.id})},t.prototype.isLive=function(){return"dynamic"===this.dashManifest._type},t.contentProtectionToXmlJson=function(t){return t.map(function(t){var e={_schemeIdUri:t.schemeIdUri};return t.defaultKid&&(e["_cenc:default_KID"]=t.defaultKid),t.pssh&&(e.pssh=[{__text:t.pssh}]),e})},t.prototype.dispose=function(){this.m3u8Translator=n.dispose(this.m3u8Translator)},t}();e.M3u8DashManifest=f},326:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(32),n=i(23),a=i(9),s=function(){function t(t){this.context=t}return t.prototype.create=function(t,e,i,n,a){if(void 0===a&&(a=!0),!t)return null;var s=this.createBaseRepresentation(t,n);if(e===r.RepresentationType.AUDIO)s=this.extendToAudioRepresentation(t,s,i,n);else if(e===r.RepresentationType.VIDEO)s=this.extendToVideoRepresentation(t,s,i,n,a);else{if(e!==r.RepresentationType.SUBTITLE)return null;s=this.extendToSubtitleRepresentation(t,s,i,n)}var o=this.getLabelForRepresentation(s);return o&&"string"==typeof o&&(s._label=o),s},t.prototype.createBaseRepresentation=function(t,e){var i=t.uri||t.URI;i&&!a.URLHelper.isUrlAbsolute(i)&&(i=a.URLHelper.concatBaseUrlWithPartial(e,i));var r={_id:"",_mimeType:"",_bandwidth:0,_codecs:"",_hls:{requestTimestamp:0},BaseURL:null,SegmentList:[{SegmentURL:[]}],Uri:i,backupUris:[]};return t.backupStreamUris&&t.backupStreamUris.forEach(function(t){a.URLHelper.isUrlAbsolute(t)?r.backupUris.push(t):r.backupUris.push(a.URLHelper.concatBaseUrlWithPartial(e,t))}),t.NAME&&(r._label=t.NAME),r},t.prototype.extendToVideoRepresentation=function(e,i,r,a,s){var o=i;if(o._mimeType="video/"+r,o._width=0,o._height=0,o.BaseURL=[{url:t.getBaseUrl(a,e.uri)}],o._bandwidth=e.attributes["AVERAGE-BANDWIDTH"]||e.attributes.BANDWIDTH,o._bandwidth||(o._bandwidth=this.context.settings.MIN_SELECTABLE_VIDEO_BITRATE),o._bandwidth=Number(o._bandwidth),e.attributes.CODECS){var u=n.CodecStringHelper.extractCodecStrings(e.attributes.CODECS);n.CodecStringHelper.hasOldAvc1CodecFormat(u.video)&&(u.video=n.CodecStringHelper.convertAvc1ToAvcotiCodecFormat(u.video)),s?u.video&&u.audio?o._codecs=u.video+","+u.audio:u.video&&!u.audio?o._codecs=u.video:!u.video&&u.audio&&(o._codecs=u.audio):o._codecs=u.video}return e.attributes.RESOLUTION&&(o._width=e.attributes.RESOLUTION.width,o._height=e.attributes.RESOLUTION.height,o._id+=e.attributes.RESOLUTION.height+"_"),o._id+=e.attributes.BANDWIDTH,o},t.prototype.extendToAudioRepresentation=function(e,i,r,n){var a=i;return a._id=e.NAME+" "+e["GROUP-ID"]||"",a._mimeType="audio/"+r,a._codecs=e.CODECS,a._name=e.NAME||"",a._groupId=e["GROUP-ID"]||"",a._label=a._name+" "+a._groupId,a.BaseURL=[{url:t.getBaseUrl(n,e.URI||e.uri)}],a},t.prototype.extendToSubtitleRepresentation=function(e,i,r,n){var a=i;return a._id=e.NAME,a._mimeType="application/"+r,a._codecs="wvtt",a._name=e.NAME||"",a.BaseURL=[{url:t.getBaseUrl(n,e.URI)}],a},t.prototype.getLabelForRepresentation=function(t){var e={id:t._id,mimeType:t._mimeType,width:t._width,height:t._height,bitrate:t._bandwidth},i=this.getLabelingFunctionForRepresentation();return i(e)},t.prototype.getLabelingFunctionForRepresentation=function(){var e=this.context.sourceContext,i=e&&e.source&&e.source.labeling;return i&&i.hls&&i.hls.qualities?"function"!=typeof i.hls.qualities?t.getDefaultLabelForRepresentation:i.hls.qualities:t.getDefaultLabelForRepresentation},t.getDefaultLabelForRepresentation=function(){return null},t.getBaseUrl=function(t,e){var i=t;return i=a.URLHelper.removeUrlParameters(i),e=a.URLHelper.removeLastPathPart(e),!e||e.indexOf("/")<0?t:a.URLHelper.concatUrlParts(i,e)},t}();e.M3u8RepresentationFactory=s},327:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(t,e){if(e===1/0)return 1/0;var i=(Date.now()-t)/1e3;return i>=e?100:1e3*(e-i)},n=function(){function t(t,e,i){void 0===i&&(i=1/0),this.m3u8Loader=t,this.updateInterval=i,this.representation=e,this.timeoutId=null,this.lastReloadTimestamp=Date.now(),this.scheduleUpdate()}return t.prototype.getRepresentation=function(){return this.representation},t.prototype.setRepresentation=function(t){this.representation=t},t.prototype.getUpdateInterval=function(){return this.updateInterval},t.prototype.setUpdateInterval=function(t){t!==this.updateInterval&&(this.updateInterval=t,null!==this.timeoutId&&this.delayedStart())},t.prototype.delayedStart=function(){this.stop(),this.lastReloadTimestamp=Date.now(),this.scheduleUpdate()},t.prototype.start=function(){var t=this;return this.stop(),this.timeoutId=NaN,this.update().then(function(){t.scheduleUpdate()})},t.prototype.stop=function(){null!==this.timeoutId&&(Number.isNaN(this.timeoutId)||window.clearTimeout(this.timeoutId),this.timeoutId=null)},t.prototype.scheduleUpdate=function(){var t=this,e=r(this.lastReloadTimestamp,this.updateInterval),i=1*Math.pow(2,31)-1;e>i||(this.timeoutId=window.setTimeout(