-1},t.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n>7))^e]=e;for(t=i=0;!h[t];t^=n||1,i=m[i]||1)for(a=(a=i^i<<1^i<<2^i<<3^i<<4)>>8^255&a^99,h[t]=a,c[a]=t,o=16843009*f[r=f[n=f[t]]]^65537*r^257*n^16843008*t,s=257*f[a]^16843008*a,e=0;e<4;e++)d[e][t]=s=s<<24^s>>>8,l[e][a]=o=o<<24^o>>>8;for(e=0;e<5;e++)d[e]=d[e].slice(0),l[e]=l[e].slice(0);return u}()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];var a=this._tables[0][4],s=this._tables[1],o=e.length,u=1;if(4!==o&&6!==o&&8!==o)throw new Error("Invalid aes key size");var d=e.slice(0),l=[];for(this._key=[d,l],t=o;t<4*o+28;t++)r=d[t-1],(t%o==0||8===o&&t%o==4)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],t%o==0&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),d[t]=d[t-o]^r;for(i=0;t;i++,t--)r=d[3&i?t:t-4],l[i]=t<=4||i<4?r:s[0][a[r>>>24]]^s[1][a[r>>16&255]]^s[2][a[r>>8&255]]^s[3][a[255&r]];}return e.prototype.decrypt=function(e,t,i,n,r,a){var s,o,u,d,l=this._key[1],h=e^l[0],c=n^l[1],f=i^l[2],m=t^l[3],p=l.length/4-2,g=4,y=this._tables[1],_=y[0],v=y[1],b=y[2],T=y[3],S=y[4];for(d=0;d>>24]^v[c>>16&255]^b[f>>8&255]^T[255&m]^l[g],o=_[c>>>24]^v[f>>16&255]^b[m>>8&255]^T[255&h]^l[g+1],u=_[f>>>24]^v[m>>16&255]^b[h>>8&255]^T[255&c]^l[g+2],m=_[m>>>24]^v[h>>16&255]^b[c>>8&255]^T[255&f]^l[g+3],g+=4,h=s,c=o,f=u;for(d=0;d<4;d++)r[(3&-d)+a]=S[h>>>24]<<24^S[c>>16&255]<<16^S[f>>8&255]<<8^S[255&m]^l[g++],s=h,h=c,c=f,f=m,m=s;},e}(),a=function(e){function i(){var i;return (i=e.call(this,t)||this).jobs=[],i.delay=1,i.timeout_=null,i}var n,r;r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r;var a=i.prototype;return a.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null;},a.push=function(e){this.jobs.push(e),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay));},i}(t),s=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},o=function(){function t(e,i,n,r){var o=t.STEP,u=new Int32Array(e.buffer),d=new Uint8Array(e.byteLength),l=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(u.subarray(l,l+o),i,n,d)),l=o;l>2),p=new r(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),y=new Int32Array(g.buffer);for(n=i[0],a=i[1],o=i[2],u=i[3],f=0;f=0&&(t="main-desc"),t},fn=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null);},mn=function(e,t){t.activePlaylistLoader=e,e.load();},pn={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e],a=t.blacklistCurrentPlaylist;fn(i,r);var s=r.activeTrack(),o=r.activeGroup(),u=(o.filter((function(e){return e.default}))[0]||o[0]).id,d=r.tracks[u];if(s!==d){for(var l in n.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),r.tracks)r.tracks[l].enabled=r.tracks[l]===d;r.onTrackChanged();}else a({message:"Problem encountered loading the default audio track."});}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],r=t.mediaTypes[e];n.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),fn(i,r);var a=r.activeTrack();a&&(a.mode="disabled"),r.onTrackChanged();}}},gn={AUDIO:function(e,t,i){if(t){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load();})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load();})),t.on("error",pn[e](e,i));}},SUBTITLES:function(e,t,i){var n=i.tech,r=i.requestOptions,a=i.segmentLoaders[e],s=i.mediaTypes[e];t.on("loadedmetadata",(function(){var e=t.media();a.playlist(e,r),a.track(s.activeTrack()),(!n.paused()||e.endList&&"none"!==n.preload())&&a.load();})),t.on("loadedplaylist",(function(){a.playlist(t.media(),r),n.paused()||a.load();})),t.on("error",pn[e](e,i));}},yn={AUDIO:function(e,t){var i=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master,u=o.mediaGroups,d=o.playlists,l=t.mediaTypes[e],h=l.groups,c=l.tracks,f=t.masterPlaylistLoader;u[e]&&0!==Object.keys(u[e]).length||(u[e]={main:{default:{default:!0}}});var m=function(a){h[a]||(h[a]=[]);var o=d.filter((function(t){return t.attributes[e]===a})),l=function(d){var l=u[e][a][d];!o.filter((function(e){return e.resolvedUri!==l.resolvedUri})).length&&o.length&&delete l.resolvedUri;var m;if(m="vhs-json"===r&&l.playlists?new R(l.playlists[0],i,s):l.resolvedUri?new R(l.resolvedUri,i,s):l.playlists&&"dash"===r?new dt(l.playlists[0],i,s,f):null,l=n.mergeOptions({id:d,playlistLoader:m},l),gn[e](e,l.playlistLoader,t),h[a].push(l),void 0===c[d]){var p=new n.AudioTrack({id:d,kind:cn(l),enabled:!1,language:l.language,default:l.default,label:d});c[d]=p;}};for(var m in u[e][a])l(m);};for(var p in u[e])m(p);a.on("error",pn[e](e,t));},SUBTITLES:function(e,t){var i=t.tech,r=t.vhs,a=t.sourceType,s=t.segmentLoaders[e],o=t.requestOptions,u=t.master.mediaGroups,d=t.mediaTypes[e],l=d.groups,h=d.tracks,c=t.masterPlaylistLoader;for(var f in u[e])for(var m in l[f]||(l[f]=[]),u[e][f])if(!u[e][f][m].forced){var p=u[e][f][m],g=void 0;if("hls"===a?g=new R(p.resolvedUri,r,o):"dash"===a?g=new dt(p.playlists[0],r,o,c):"vhs-json"===a&&(g=new R(p.playlists?p.playlists[0]:p.resolvedUri,r,o)),p=n.mergeOptions({id:m,playlistLoader:g},p),gn[e](e,p.playlistLoader,t),l[f].push(p),void 0===h[m]){var y=i.addRemoteTextTrack({id:m,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:m},!1).track;h[m]=y;}}s.on("error",pn[e](e,t));},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,r=t.master.mediaGroups,a=t.mediaTypes[e],s=a.groups,o=a.tracks;for(var u in r[e])for(var d in s[u]||(s[u]=[]),r[e][u]){var l=r[e][u][d];if(l.instreamId.match(/CC\d/)&&(s[u].push(n.mergeOptions({id:d},l)),void 0===o[d])){var h=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:d},!1).track;o[d]=h;}}}},_n={AUDIO:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if(i[n].enabled)return i[n];return null}},SUBTITLES:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if("showing"===i[n].mode||"hidden"===i[n].mode)return i[n];return null}}},vn=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],bn=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Tn=function(e){function t(t){var r;r=e.call(this)||this;var s=t.src,o=t.handleManifestRedirects,u=t.withCredentials,d=t.tech,l=t.bandwidth,h=t.externVhs,c=t.useCueTags,f=t.blacklistDuration,m=t.enableLowInitialPlaylist,p=t.sourceType,g=t.cacheEncryptionKeys,y=t.handlePartialData,_=t.experimentalBufferBasedABR;if(!s)throw new Error("A non-empty playlist URL or JSON manifest string is required");Ni=h,r.experimentalBufferBasedABR=Boolean(_),r.withCredentials=u,r.tech_=d,r.vhs_=d.vhs,r.sourceType_=p,r.useCueTags_=c,r.blacklistDuration=f,r.enableLowInitialPlaylist=m,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:u,handleManifestRedirects:o,timeout:null},r.on("error",r.pauseLoading),r.mediaTypes_=function(){var e={};return ["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Fi,activeTrack:Fi,onGroupChanged:Fi,onTrackChanged:Fi};})),e}(),r.mediaSource=new i.MediaSource,r.handleDurationChange_=r.handleDurationChange_.bind(a(r)),r.handleSourceOpen_=r.handleSourceOpen_.bind(a(r)),r.handleSourceEnded_=r.handleSourceEnded_.bind(a(r)),r.mediaSource.addEventListener("durationchange",r.handleDurationChange_),r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_),r.mediaSource.addEventListener("sourceended",r.handleSourceEnded_),r.seekable_=n.createTimeRanges(),r.hasPlayed_=!1,r.syncController_=new dn(t),r.segmentMetadataTrack_=d.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new hn,r.sourceUpdater_=new nn(r.mediaSource),r.inbandTextTracks_={},r.timelineChangeController_=new ln;var v={vhs:r.vhs_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.duration()},hasPlayed:function(){return r.hasPlayed_},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:g,handlePartialData:y,sourceUpdater:r.sourceUpdater_,timelineChangeController:r.timelineChangeController_};return r.masterPlaylistLoader_="dash"===r.sourceType_?new dt(s,r.vhs_,r.requestOptions_):new R(s,r.vhs_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new Bi(n.mergeOptions(v,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),t),r.audioSegmentLoader_=new Bi(n.mergeOptions(v,{loaderType:"audio"}),t),r.subtitleSegmentLoader_=new sn(n.mergeOptions(v,{loaderType:"vtt",featuresNativeTextTracks:r.tech_.featuresNativeTextTracks}),t),r.setupSegmentLoaderListeners_(),r.experimentalBufferBasedABR&&(r.startABRTimer_(),r.tech_.on("pause",(function(){return r.stopABRTimer_()})),r.tech_.on("play",(function(){return r.startABRTimer_()}))),vn.forEach((function(e){r[e+"_"]=bn.bind(a(r),e);})),r.logger_=Ai("MPC"),r.triggeredFmp4Usage=!1,r.masterPlaylistLoader_.load(),r}s(t,e);var r=t.prototype;return r.checkABR_=function(){var e=this.selectPlaylist();this.shouldSwitchToMedia_(e)&&this.masterPlaylistLoader_.media(e);},r.startABRTimer_=function(){var e=this;this.stopABRTimer_(),this.abrTimer_=i.setInterval((function(){return e.checkABR_()}),250);},r.stopABRTimer_=function(){this.tech_.scrubbing&&this.tech_.scrubbing()||(i.clearInterval(this.abrTimer_),this.abrTimer_=null);},r.setupMasterPlaylistLoaderListeners_=function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;$(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,t.endList&&"none"!==e.tech_.preload()&&(e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load()),function(e){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){yn[t](t,e);}));var t=e.mediaTypes,i=e.masterPlaylistLoader,n=e.tech,r=e.vhs;["AUDIO","SUBTITLES"].forEach((function(i){t[i].activeGroup=function(e,t){return function(i){var n=t.masterPlaylistLoader,r=t.mediaTypes[e].groups,a=n.media();if(!a)return null;var s=null;return a.attributes[e]&&(s=r[a.attributes[e]]),s=s||r.main,void 0===i?s:null===i?null:s.filter((function(e){return e.id===i.id}))[0]||null}}(i,e),t[i].activeTrack=_n[i](i,e),t[i].onGroupChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,a=t.mediaTypes[e],s=a.activeTrack(),o=a.activeGroup(s),u=a.activePlaylistLoader;fn(n,a),o&&(o.playlistLoader?(n.resyncLoader(),mn(o.playlistLoader,a)):u&&r.resetEverything());}}(i,e),t[i].onGroupChanging=function(e,t){return function(){var i=t.segmentLoaders[e];i.abort(),i.pause();}}(i,e),t[i].onTrackChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,a=t.mediaTypes[e],s=a.activeTrack(),o=a.activeGroup(s),u=a.activePlaylistLoader;if(fn(n,a),o){if("AUDIO"===e){if(!o.playlistLoader)return r.setAudio(!0),void r.resetEverything();n.setAudio(!0),r.setAudio(!1);}u!==o.playlistLoader?(n.track&&n.track(s),n.resetEverything(),mn(o.playlistLoader,a)):mn(o.playlistLoader,a);}}}(i,e);}));var a=t.AUDIO.activeGroup();if(a){var s=(a.filter((function(e){return e.default}))[0]||a[0]).id;t.AUDIO.tracks[s].enabled=!0,t.AUDIO.onTrackChanged();}i.on("mediachange",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanged()}));})),i.on("mediachanging",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanging()}));}));var o=function(){t.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"}),n.trigger({type:"usage",name:"hls-audio-change"});};for(var u in n.audioTracks().addEventListener("change",o),n.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),r.on("dispose",(function(){n.audioTracks().removeEventListener("change",o),n.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged);})),n.clearTracks("audio"),t.AUDIO.tracks)n.audioTracks().addTrack(t.AUDIO.tracks[u]);}({sourceType:e.sourceType_,segmentLoaders:{AUDIO:e.audioSegmentLoader_,SUBTITLES:e.subtitleSegmentLoader_,main:e.mainSegmentLoader_},tech:e.tech_,requestOptions:e.requestOptions_,masterPlaylistLoader:e.masterPlaylistLoader_,vhs:e.vhs_,master:e.master(),mediaTypes:e.mediaTypes_,blacklistCurrentPlaylist:e.blacklistCurrentPlaylist.bind(e)}),e.triggerPresenceUsage_(e.master(),t),e.setupFirstPlay(),!e.mediaTypes_.AUDIO.activePlaylistLoader||e.mediaTypes_.AUDIO.activePlaylistLoader.media()?e.trigger("selectedinitialmedia"):e.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",(function(){e.trigger("selectedinitialmedia");}));})),this.masterPlaylistLoader_.on("loadedplaylist",(function(){var t=e.masterPlaylistLoader_.media();if(!t){var i;if(e.excludeUnsupportedVariants_(),e.enableLowInitialPlaylist&&(i=e.selectInitialPlaylist()),i||(i=e.selectPlaylist()),!i||!e.shouldSwitchToMedia_(i))return;if(e.initialMedia_=i,e.masterPlaylistLoader_.media(e.initialMedia_),"vhs-json"!==e.sourceType_||!e.initialMedia_.segments)return;t=e.initialMedia_;}e.handleUpdatedMediaPlaylist(t);})),this.masterPlaylistLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.masterPlaylistLoader_.error);})),this.masterPlaylistLoader_.on("mediachanging",(function(){e.mainSegmentLoader_.abort(),e.mainSegmentLoader_.pause();})),this.masterPlaylistLoader_.on("mediachange",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;$(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load(),e.tech_.trigger({type:"mediachange",bubbles:!0});})),this.masterPlaylistLoader_.on("playlistunchanged",(function(){var t=e.masterPlaylistLoader_.media();e.stuckAtPlaylistEnd_(t)&&(e.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),e.tech_.trigger("playliststuck"));})),this.masterPlaylistLoader_.on("renditiondisabled",(function(){e.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"}),e.tech_.trigger({type:"usage",name:"hls-rendition-disabled"});})),this.masterPlaylistLoader_.on("renditionenabled",(function(){e.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"}),e.tech_.trigger({type:"usage",name:"hls-rendition-enabled"});}));},r.handleUpdatedMediaPlaylist=function(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load());},r.triggerPresenceUsage_=function(e,t){var i=e.mediaGroups||{},n=!0,r=Object.keys(i.AUDIO);for(var a in i.AUDIO)for(var s in i.AUDIO[a])i.AUDIO[a][s].uri||(n=!1);n&&(this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),this.tech_.trigger({type:"usage",name:"hls-demuxed"})),Object.keys(i.SUBTITLES).length&&(this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),this.tech_.trigger({type:"usage",name:"hls-webvtt"})),Ni.Playlist.isAes(t)&&(this.tech_.trigger({type:"usage",name:"vhs-aes"}),this.tech_.trigger({type:"usage",name:"hls-aes"})),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&(this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.tech_.trigger({type:"usage",name:"hls-alternate-audio"})),this.useCueTags_&&(this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"}),this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"}));},r.shouldSwitchToMedia_=function(e){var t=this.masterPlaylistLoader_.media(),i=this.tech_.buffered();return function(e){var t=e.currentPlaylist,i=e.nextPlaylist,r=e.forwardBuffer,a=e.bufferLowWaterLine,s=e.bufferHighWaterLine,o=e.duration,u=e.experimentalBufferBasedABR,d=e.log;if(!i)return n.log.warn("We received no playlist to switch to. Please check your stream."),!1;var l="allowing switch "+(t&&t.id||"null")+" -> "+i.id;if(!t||!t.endList)return d(l+" as current playlist "+(t?"is live":"is not set")),!0;if(i.id===t.id)return !1;var h=u?lt.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:lt.MAX_BUFFER_LOW_WATER_LINE;if(of)&&r>=a){var p=l+" as forwardBuffer >= bufferLowWaterLine ("+r+" >= "+a+")";return u&&(p+=" and next bandwidth > current bandwidth ("+c+" > "+f+")"),d(p),!0}return d("not "+l+" as no switching criteria met"),!1}({currentPlaylist:t,nextPlaylist:e,forwardBuffer:i.length?i.end(i.length-1)-this.tech_.currentTime():0,bufferLowWaterLine:this.bufferLowWaterLine(),bufferHighWaterLine:this.bufferHighWaterLine(),duration:this.duration(),experimentalBufferBasedABR:this.experimentalBufferBasedABR,log:this.logger_})},r.setupSegmentLoaderListeners_=function(){var e=this;this.experimentalBufferBasedABR||(this.mainSegmentLoader_.on("bandwidthupdate",(function(){var t=e.selectPlaylist();e.shouldSwitchToMedia_(t)&&e.masterPlaylistLoader_.media(t),e.tech_.trigger("bandwidthupdate");})),this.mainSegmentLoader_.on("progress",(function(){e.trigger("progress");}))),this.mainSegmentLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.mainSegmentLoader_.error());})),this.mainSegmentLoader_.on("appenderror",(function(){e.error=e.mainSegmentLoader_.error_,e.trigger("error");})),this.mainSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_();})),this.mainSegmentLoader_.on("timestampoffset",(function(){e.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"}),e.tech_.trigger({type:"usage",name:"hls-timestamp-offset"});})),this.audioSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_();})),this.audioSegmentLoader_.on("appenderror",(function(){e.error=e.audioSegmentLoader_.error_,e.trigger("error");})),this.mainSegmentLoader_.on("ended",(function(){e.logger_("main segment loader ended"),e.onEndOfStream();})),this.mainSegmentLoader_.on("earlyabort",(function(t){e.experimentalBufferBasedABR||e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120);}));var t=function(){if(!e.sourceUpdater_.ready())return e.tryToCreateSourceBuffers_();var t=e.getCodecsOrExclude_();t&&e.sourceUpdater_.addOrChangeSourceBuffers(t);};this.mainSegmentLoader_.on("trackinfo",t),this.audioSegmentLoader_.on("trackinfo",t),this.mainSegmentLoader_.on("fmp4",(function(){e.triggeredFmp4Usage||(e.tech_.trigger({type:"usage",name:"vhs-fmp4"}),e.tech_.trigger({type:"usage",name:"hls-fmp4"}),e.triggeredFmp4Usage=!0);})),this.audioSegmentLoader_.on("fmp4",(function(){e.triggeredFmp4Usage||(e.tech_.trigger({type:"usage",name:"vhs-fmp4"}),e.tech_.trigger({type:"usage",name:"hls-fmp4"}),e.triggeredFmp4Usage=!0);})),this.audioSegmentLoader_.on("ended",(function(){e.logger_("audioSegmentLoader ended"),e.onEndOfStream();}));},r.mediaSecondsLoaded_=function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)},r.load=function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load();},r.smoothQualityChange_=function(e){void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader());},r.fastQualityChange_=function(e){var t=this;void 0===e&&(e=this.selectPlaylist()),e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything((function(){n.browser.IE_VERSION||n.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime());})));},r.play=function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();var e=this.tech_.seekable();return this.tech_.duration()===1/0&&this.tech_.currentTime()a.end(0)||a.start(0)>e.end(0)?this.seekable_=a:this.seekable_=n.createTimeRanges([[e.start(0)>a.start(0)?e.start(0):a.start(0),e.end(0)0&&(n=Math.max(n,i.end(i.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n);}},r.dispose=function(){var e=this;this.trigger("dispose"),this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach((function(t){var i=e.mediaTypes_[t].groups;for(var n in i)i[n].forEach((function(e){e.playlistLoader&&e.playlistLoader.dispose();}));})),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off();},r.master=function(){return this.masterPlaylistLoader_.master},r.media=function(){return this.masterPlaylistLoader_.media()||this.initialMedia_},r.areMediaTypesKnown_=function(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader;return !(!this.mainSegmentLoader_.currentMediaInfo_||e&&!this.audioSegmentLoader_.currentMediaInfo_)},r.getCodecsOrExclude_=function(){var e=this,t={main:this.mainSegmentLoader_.currentMediaInfo_||{},audio:this.audioSegmentLoader_.currentMediaInfo_||{}};t.video=t.main;var i=Ii(this.master(),this.media()),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(t.main.hasVideo&&(n.video=i.video||t.main.videoCodec||fi),t.main.isMuxed&&(n.video+=","+(i.audio||t.main.audioCodec||ci)),(t.main.hasAudio&&!t.main.isMuxed||t.audio.hasAudio||r)&&(n.audio=i.audio||t.main.audioCodec||t.audio.audioCodec||ci,t.audio.isFmp4=t.main.hasAudio&&!t.main.isMuxed?t.main.isFmp4:t.audio.isFmp4),n.audio||n.video){var a,s={};if(["video","audio"].forEach((function(e){if(n.hasOwnProperty(e)&&(r=t[e].isFmp4,o=n[e],!(r?mi(o):vi(o)))){var i=t[e].isFmp4?"browser":"muxer";s[i]=s[i]||[],s[i].push(n[e]),"audio"===e&&(a=i);}var r,o;})),r&&a&&this.media().attributes.AUDIO){var o=this.media().attributes.AUDIO;this.master().playlists.forEach((function(t){(t.attributes&&t.attributes.AUDIO)===o&&t!==e.media()&&(t.excludeUntil=1/0);})),this.logger_("excluding audio group "+o+" as "+a+' does not support codec(s): "'+n.audio+'"');}if(!Object.keys(s).length){if(this.sourceUpdater_.ready()&&!this.sourceUpdater_.canChangeType()){var u=[];if(["video","audio"].forEach((function(t){var i=(bi(e.sourceUpdater_.codecs[t]||"")[t]||{}).type,r=(bi(n[t]||"")[t]||{}).type;i&&r&&i.toLowerCase()!==r.toLowerCase()&&u.push('"'+e.sourceUpdater_.codecs[t]+'" -> "'+n[t]+'"');})),u.length)return void this.blacklistCurrentPlaylist({playlist:this.media(),message:"Codec switching not supported: "+u.join(", ")+".",blacklistDuration:1/0,internal:!0})}return n}var d=Object.keys(s).reduce((function(e,t){return e&&(e+=", "),e+(t+' does not support codec(s): "')+s[t].join(",")+'"'}),"")+".";this.blacklistCurrentPlaylist({playlist:this.media(),internal:!0,message:d,blacklistDuration:1/0});}else this.blacklistCurrentPlaylist({playlist:this.media(),message:"Could not determine codecs for playlist.",blacklistDuration:1/0});},r.tryToCreateSourceBuffers_=function(){if("open"===this.mediaSource.readyState&&!this.sourceUpdater_.ready()&&this.areMediaTypesKnown_()){var e=this.getCodecsOrExclude_();if(e){this.sourceUpdater_.createSourceBuffers(e);var t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t);}}},r.excludeUnsupportedVariants_=function(){var e=this;this.master().playlists.forEach((function(t){var i=Ii(e.master,t);!i.audio||vi(i.audio)||mi(i.audio)||(t.excludeUntil=1/0),!i.video||vi(i.video)||mi(i.video)||(t.excludeUntil=1/0);}));},r.excludeIncompatibleVariants_=function(e){var t=this,i=bi(e),n=Object.keys(i).length;this.master().playlists.forEach((function(e){if(e.excludeUntil!==1/0){var r={},a=2,s=[],o=Ii(t.masterPlaylistLoader_.master,e);if(o.audio||o.video){var u=[o.video,o.audio].filter(Boolean).join(",");r=bi(u),a=Object.keys(r).length;}a!==n&&(s.push('codec count "'+a+'" !== "'+n+'"'),e.excludeUntil=1/0),t.sourceUpdater_.canChangeType()||(r.video&&i.video&&r.video.type.toLowerCase()!==i.video.type.toLowerCase()&&(s.push('video codec "'+r.video.type+'" !== "'+i.video.type+'"'),e.excludeUntil=1/0),r.audio&&i.audio&&r.audio.type.toLowerCase()!==i.audio.type.toLowerCase()&&(e.excludeUntil=1/0,s.push('audio codec "'+r.audio.type+'" !== "'+i.audio.type+'"'))),s.length&&t.logger_("blacklisting "+e.id+": "+s.join(" && "));}}));},r.updateAdCues_=function(e){var t=0,n=this.seekable();n.length&&(t=n.start(0)),function(e,t,n){if(void 0===n&&(n=0),e.segments)for(var r,a=n,s=0;s0&&this.logger_("resetting possible stalled download count for "+e+" loader"),this[e+"StalledDownloads_"]=0,this[e+"Buffered_"]=t.buffered_();},t.checkSegmentDownloads_=function(e){var t=this.masterPlaylistController_,i=t[e+"SegmentLoader_"],n=i.buffered_(),r=function(e,t){if(e===t)return !1;if(!e&&t||!t&&e)return !0;if(e.length!==t.length)return !0;for(var i=0;i=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e);}},t.cancelTimer_=function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null;},t.fixesBadSeeks_=function(){if(!this.tech_.seeking())return !1;var e,t=this.seekable(),i=this.tech_.currentTime();if(this.afterSeekableWindow_(t,i,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(e=t.end(t.length-1)),this.beforeSeekableWindow_(t,i)){var n=t.start(0);e=n+(n===t.end(0)?0:.1);}if(void 0!==e)return this.logger_("Trying to seek outside of seekable at time "+i+" with seekable range "+N(t)+". Seeking to "+e+"."),this.tech_.setCurrentTime(e),!0;var r=this.tech_.buffered();return !!function(e){var t=e.buffered,i=e.targetDuration,n=e.currentTime;return !(!t.length||t.end(0)-t.start(0)<2*i||n>t.start(0)||!(t.start(0)-n "+i.end(0)+"]. Attempting to resume playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"}),void this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})):void 0}},t.techWaiting_=function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return !0;if(this.tech_.seeking()||null!==this.timer_)return !0;if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to live point (seekable end) "+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var n=this.tech_.vhs.masterPlaylistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;var a=F(r,t);if(a.length>0){var s=a.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+s+", seeking to "+a.start(0)),this.cancelTimer_(),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*s,t),!0}return !1},t.afterSeekableWindow_=function(e,t,i,n){if(void 0===n&&(n=!1),!e.length)return !1;var r=e.end(e.length-1)+.1;return !i.endList&&n&&(r=e.end(e.length-1)+3*i.targetDuration),t>r},t.beforeSeekableWindow_=function(e,t){return !!(e.length&&e.start(0)>0&&t2)return {start:a,end:s}}return null},e}(),Ln={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},En=function(e){!function e(t,i){var r=0,a=0,s=n.mergeOptions(Ln,i);t.ready((function(){t.trigger({type:"usage",name:"vhs-error-reload-initialized"}),t.trigger({type:"usage",name:"hls-error-reload-initialized"});}));var o=function(){a&&t.currentTime(a);},u=function(e){null!=e&&(a=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",o),t.src(e),t.trigger({type:"usage",name:"vhs-error-reload"}),t.trigger({type:"usage",name:"hls-error-reload"}),t.play());},d=function(){return Date.now()-r<1e3*s.errorInterval?(t.trigger({type:"usage",name:"vhs-error-reload-canceled"}),void t.trigger({type:"usage",name:"hls-error-reload-canceled"})):s.getSource&&"function"==typeof s.getSource?(r=Date.now(),s.getSource.call(t,u)):void n.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")},l=function e(){t.off("loadedmetadata",o),t.off("error",d),t.off("dispose",e);};t.on("error",d),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i);};}(this,e);},wn={PlaylistLoader:R,Playlist:J,utils:fe,STANDARD_PLAYLIST_SELECTOR:Ci,INITIAL_PLAYLIST_SELECTOR:function(){var e=this,t=this.playlists.master.playlists.filter(J.isEnabled);return ki(t,(function(e,t){return Oi(e,t)})),t.filter((function(t){return !!Ii(e.playlists.master,t).video}))[0]||null},lastBandwidthSelector:Ci,movingAverageBandwidthSelector:function(e){var t=-1;if(e<0||e>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){var n=this.useDevicePixelRatio&&i.devicePixelRatio||1;return t<0&&(t=this.systemBandwidth),t=e*this.systemBandwidth+(1-e)*t,Ui(this.playlists.master,t,parseInt(wi(this.tech_.el(),"width"),10)*n,parseInt(wi(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions)}},comparePlaylistBandwidth:Oi,comparePlaylistResolution:function(e,t){var n,r;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||i.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),n===(r=r||i.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:n-r},xhr:ie()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","BACK_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach((function(e){Object.defineProperty(wn,e,{get:function(){return n.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),lt[e]},set:function(t){n.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?n.log.warn("value of Vhs."+e+" must be greater than or equal to 0"):lt[e]=t;}});}));var kn=function(e,t){for(var i=t.media(),n=-1,r=0;r1&&r.video.split(",").forEach((function(e){e=e.trim(),yi(e)?r.audio=e:_i(e)&&(r.video=e);}));var a=r.video?'video/mp4;codecs="'+r.video+'"':null,s=r.audio?'audio/mp4;codecs="'+r.audio+'"':null,o={};for(var u in e)o[u]={audioContentType:s,videoContentType:a},t.contentProtection&&t.contentProtection[u]&&t.contentProtection[u].pssh&&(o[u].pssh=t.contentProtection[u].pssh),"string"==typeof e[u]&&(o[u].url=e[u]);return n.mergeOptions(e,o)},Un=function(e,t){return e.reduce((function(e,i){if(!i.contentProtection)return e;var n=t.reduce((function(e,t){var n=i.contentProtection[t];return n&&n.pssh&&(e[t]={pssh:n.pssh}),e}),{});return Object.keys(n).length&&e.push(n),e}),[])},Cn=function(e){var t=e.player,i=e.sourceKeySystems,r=e.media,a=e.audioMedia,s=e.mainPlaylists,o=On(i,r,a);if(o)if(t.currentSource().keySystems=o,!o||t.eme){if(11!==n.browser.IE_VERSION&&t.eme.initializeMediaKeys){var u=a?s.concat([a]):s;Un(u,Object.keys(i)).forEach((function(e){t.eme.initializeMediaKeys({keySystems:e});}));}}else n.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin");},Pn=function(){if(!i.localStorage)return null;var e=i.localStorage.getItem("videojs-vhs");if(!e)return null;try{return JSON.parse(e)}catch(e){return null}},Dn=function(e){return 0===e.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")?JSON.parse(e.substring(e.indexOf(",")+1)):e};wn.supportsNativeHls=function(){if(!t||!t.createElement)return !1;var e=t.createElement("video");return !!n.getTech("Html5").isSupported()&&["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some((function(t){return /maybe|probably/i.test(e.canPlayType(t))}))}(),wn.supportsNativeDash=!!(t&&t.createElement&&n.getTech("Html5").isSupported())&&/maybe|probably/i.test(t.createElement("video").canPlayType("application/dash+xml")),wn.supportsTypeNatively=function(e){return "hls"===e?wn.supportsNativeHls:"dash"===e&&wn.supportsNativeDash},wn.isSupported=function(){return n.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var xn=function(e){function r(i,r,s){var o;if(o=e.call(this,r,n.mergeOptions(s.hls,s.vhs))||this,s.hls&&Object.keys(s.hls).length&&n.log.warn("Using hls options is deprecated. Use vhs instead."),r.options_&&r.options_.playerId){var u=n(r.options_.playerId);u.hasOwnProperty("hls")||Object.defineProperty(u,"hls",{get:function(){return n.log.warn("player.hls is deprecated. Use player.tech().vhs instead."),r.trigger({type:"usage",name:"hls-player-access"}),a(o)},configurable:!0}),u.hasOwnProperty("vhs")||Object.defineProperty(u,"vhs",{get:function(){return n.log.warn("player.vhs is deprecated. Use player.tech().vhs instead."),r.trigger({type:"usage",name:"vhs-player-access"}),a(o)},configurable:!0}),u.hasOwnProperty("dash")||Object.defineProperty(u,"dash",{get:function(){return n.log.warn("player.dash is deprecated. Use player.tech().vhs instead."),a(o)},configurable:!0}),o.player_=u;}if(o.tech_=r,o.source_=i,o.stats={},o.ignoreNextSeekingEvent_=!1,o.setOptions_(),o.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(o.options_.overrideNative&&(r.featuresNativeVideoTracks||r.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return o.on(t,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],(function(e){var i=t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;i&&i.contains(o.tech_.el())&&o.masterPlaylistController_.smoothQualityChange_();})),o.on(o.tech_,"seeking",(function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime());})),o.on(o.tech_,"error",(function(){this.tech_.error()&&this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading();})),o.on(o.tech_,"play",o.play),o}s(r,e);var o=r.prototype;return o.setOptions_=function(){var e=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=!1!==this.options_.handleManifestRedirects,this.options_.limitRenditionByPlayerDimensions=!1!==this.options_.limitRenditionByPlayerDimensions,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=void 0!==this.source_.useBandwidthFromLocalStorage?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.handlePartialData=this.options_.handlePartialData||!1,"number"!=typeof this.options_.blacklistDuration&&(this.options_.blacklistDuration=300),"number"!=typeof this.options_.bandwidth&&this.options_.useBandwidthFromLocalStorage){var t=Pn();t&&t.bandwidth&&(this.options_.bandwidth=t.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"}),this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),t&&t.throughput&&(this.options_.throughput=t.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}),this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}));}"number"!=typeof this.options_.bandwidth&&(this.options_.bandwidth=lt.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===lt.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys","handlePartialData","playlistSelector","initialPlaylistSelector","experimentalBufferBasedABR"].forEach((function(t){void 0!==e.source_[t]&&(e.options_[t]=e.source_[t]);})),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;},o.src=function(e,t){var r=this;if(e){this.setOptions_(),this.options_.src=Dn(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=wn,this.options_.sourceType=ae(t),this.options_.seekTo=function(e){r.tech_.setCurrentTime(e);},this.masterPlaylistController_=new Tn(this.options_),this.playbackWatcher_=new An(n.mergeOptions(this.options_,{seekable:function(){return r.seekable()},media:function(){return r.masterPlaylistController_.media()},masterPlaylistController:this.masterPlaylistController_})),this.masterPlaylistController_.on("error",(function(){var e=n.players[r.tech_.options_.playerId],t=r.masterPlaylistController_.error;"object"!=typeof t||t.code?"string"==typeof t&&(t={message:t,code:3}):t.code=3,e.error(t);}));var a=this.options_.experimentalBufferBasedABR?wn.movingAverageBandwidthSelector(.55):wn.STANDARD_PLAYLIST_SELECTOR;this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):a.bind(this),this.masterPlaylistController_.selectInitialPlaylist=wn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(e){this.masterPlaylistController_.selectPlaylist=e.bind(this);}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=e,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1;}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=e,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0};}},systemBandwidth:{get:function(){var e,t=1/(this.bandwidth||1);return e=this.throughput>0?1/this.throughput:0,Math.floor(1/(t+e))},set:function(){n.log.error('The "systemBandwidth" property is read-only');}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return r.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return r.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return r.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return r.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return r.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return r.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return r.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return r.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return q(r.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return r.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return r.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return r.tech_.name_},enumerable:!0},duration:{get:function(){return r.tech_.duration()},enumerable:!0},master:{get:function(){return r.playlists.master},enumerable:!0},playerDimensions:{get:function(){return r.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return q(r.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return r.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){r.options_.useBandwidthFromLocalStorage&&function(e){if(!i.localStorage)return !1;var t=Pn();t=t?n.mergeOptions(t,e):e;try{i.localStorage.setItem("videojs-vhs",JSON.stringify(t));}catch(e){return !1}}({bandwidth:r.bandwidth,throughput:Math.round(r.throughput)});})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=r).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return !Q(e)})).map((function(t,i){return new Sn(e,t,t.id)})):[]};})),this.masterPlaylistController_.sourceUpdater_.on("ready",(function(){var e=r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader;Cn({player:r.player_,sourceKeySystems:r.source_.keySystems,media:r.playlists.media(),audioMedia:e&&e.media(),mainPlaylists:r.playlists.master.playlists});})),this.on(this.masterPlaylistController_,"progress",(function(){this.tech_.trigger("progress");})),this.on(this.masterPlaylistController_,"firstplay",(function(){this.ignoreNextSeekingEvent_=!0;})),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=i.URL.createObjectURL(this.masterPlaylistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_));}},o.setupQualityLevels_=function(){var e=this,t=n.players[this.tech_.options_.playerId];t&&t.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=t.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var t,i;t=e.qualityLevels_,(i=e).representations().forEach((function(e){t.addQualityLevel(e);})),kn(t,i.playlists);})),this.playlists.on("mediachange",(function(){kn(e.qualityLevels_,e.playlists);})));},r.version=function(){return {"@videojs/http-streaming":"2.3.1","mux.js":"5.6.7","mpd-parser":"0.14.0","m3u8-parser":"4.5.0","aes-decrypter":"3.1.0"}},o.version=function(){return this.constructor.version()},o.canChangeType=function(){return nn.canChangeType()},o.play=function(){this.masterPlaylistController_.play();},o.setCurrentTime=function(e){this.masterPlaylistController_.setCurrentTime(e);},o.duration=function(){return this.masterPlaylistController_.duration()},o.seekable=function(){return this.masterPlaylistController_.seekable()},o.dispose=function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.tech_&&delete this.tech_.hls,this.mediaSourceUrl_&&i.URL.revokeObjectURL&&(i.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),e.prototype.dispose.call(this);},o.convertToProgramTime=function(e,t){return function(e){var t=e.playlist,i=e.time,n=void 0===i?void 0:i,r=e.callback;if(!r)throw new Error("getProgramTime: callback must be provided");if(!t||void 0===n)return r({message:"getProgramTime: playlist and time must be provided"});var a=function(e,t){if(!t||!t.segments||0===t.segments.length)return null;for(var i,n=0,r=0;rn){if(e>n+.25*a.duration)return null;i=a;}return {segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:n-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}}(n,t);if(!a)return r({message:"valid programTime was not found"});if("estimate"===a.type)return r({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:a.estimatedStart});var s={mediaSeconds:n},o=function(e,t){if(!t.dateTimeObject)return null;var i=t.videoTimingInfo.transmuxerPrependedSeconds,n=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*n)}(n,a.segment);return o&&(s.programDateTime=o.toISOString()),r(null,s)}({playlist:this.masterPlaylistController_.media(),time:e,callback:t})},o.seekToProgramTime=function(e,t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=2),function e(t){var i=t.programTime,n=t.playlist,r=t.retryCount,a=void 0===r?2:r,s=t.seekTo,o=t.pauseAfterSeek,u=void 0===o||o,d=t.tech,l=t.callback;if(!l)throw new Error("seekToProgramTime: callback must be provided");if(void 0===i||!n||!s)return l({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!n.endList&&!d.hasStarted_)return l({message:"player must be playing a live stream to start buffering"});if(!function(e){if(!e.segments||0===e.segments.length)return !1;for(var t=0;tnew Date(o.getTime()+1e3*u)?null:(i>o&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:J.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})}(i,n);if(!h)return l({message:i+" was not found in the stream"});var c=h.segment,f=function(e,t){var i,n;try{i=new Date(e),n=new Date(t);}catch(e){}var r=i.getTime();return (n.getTime()-r)/1e3}(c.dateTimeObject,i);if("estimate"===h.type)return 0===a?l({message:i+" is not buffered yet. Try again"}):(s(h.estimatedStart+f),void d.one("seeked",(function(){e({programTime:i,playlist:n,retryCount:a-1,seekTo:s,pauseAfterSeek:u,tech:d,callback:l});})));var m=c.start+f;d.one("seeked",(function(){return l(null,d.currentTime())})),u&&d.pause(),s(m);}({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})},r}(n.getComponent("Component")),Rn={name:"videojs-http-streaming",VERSION:"2.3.1",canHandleSource:function(e,t){void 0===t&&(t={});var i=n.mergeOptions(n.options,t);return Rn.canPlayType(e.type,i)},handleSource:function(e,t,i){void 0===i&&(i={});var r=n.mergeOptions(n.options,i);return t.vhs=new xn(e,t,r),n.hasOwnProperty("hls")||Object.defineProperty(t,"hls",{get:function(){return n.log.warn("player.tech().hls is deprecated. Use player.tech().vhs instead."),t.vhs},configurable:!0}),t.vhs.xhr=ie(),t.vhs.src(e.src,e.type),t.vhs},canPlayType:function(e,t){void 0===t&&(t={});var i=n.mergeOptions(n.options,t).vhs.overrideNative,r=void 0===i?!n.browser.IS_ANY_SAFARI:i,a=ae(e);return !a||wn.supportsTypeNatively(a)&&!r?"":"maybe"}};mi("avc1.4d400d,mp4a.40.2")&&n.getTech("Html5").registerSourceHandler(Rn,0),n.VhsHandler=xn,Object.defineProperty(n,"HlsHandler",{get:function(){return n.log.warn("videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead."),xn},configurable:!0}),n.VhsSourceHandler=Rn,Object.defineProperty(n,"HlsSourceHandler",{get:function(){return n.log.warn("videojs.HlsSourceHandler is deprecated. Use videojs.VhsSourceHandler instead."),Rn},configurable:!0}),n.Vhs=wn,Object.defineProperty(n,"Hls",{get:function(){return n.log.warn("videojs.Hls is deprecated. Use videojs.Vhs instead."),wn},configurable:!0}),n.use||(n.registerComponent("Hls",wn),n.registerComponent("Vhs",wn)),n.options.vhs=n.options.vhs||{},n.options.hls=n.options.hls||{},n.registerPlugin?n.registerPlugin("reloadSourceOnError",En):n.plugin("reloadSourceOnError",En),e.LOCAL_STORAGE_KEY="videojs-vhs",e.Vhs=wn,e.VhsHandler=xn,e.VhsSourceHandler=Rn,e.emeKeySystems=On,e.expandDataUri=Dn,e.getAllPsshKeySystemsOptions=Un,e.setupEmeOptions=Cn,e.simpleTypeFromSourceType=ae,Object.defineProperty(e,"__esModule",{value:!0});}));
});
var videojsHttpStreaming_min$1 = /*@__PURE__*/getDefaultExportFromCjs(videojsHttpStreaming_min);
export default videojsHttpStreaming_min$1;