i=t.mediaSequence-e.mediaSequence if(i>86400)ql.log.warn("Not saving expired segment info. Media sequence gap "+i+" is too large.") else for(var n=i-1;n>=0;n--){var r=e.segments[n] if(r&&void 0!==r.start){t.syncInfo={mediaSequence:e.mediaSequence+n,time:r.start} this.logger_("playlist refresh sync: [time:"+t.syncInfo.time+", mediaSequence: "+t.syncInfo.mediaSequence+"]") this.trigger("syncinfoupdate") break}}} i.setDateTimeMappingForStart=function(e){this.timelineToDatetimeMappings={} if(e.segments&&e.segments.length&&e.segments[0].dateTimeObject){var t=e.segments[0],i=t.dateTimeObject.getTime()/1e3 this.timelineToDatetimeMappings[t.timeline]=-i}} i.saveSegmentTimingInfo=function(e){var t=e.segmentInfo,i=e.shouldSaveTimelineMapping,n=this.calculateSegmentTimeMapping_(t,t.timingInfo,i),r=t.segment if(n){this.saveDiscontinuitySyncInfo_(t) t.playlist.syncInfo||(t.playlist.syncInfo={mediaSequence:t.playlist.mediaSequence+t.mediaIndex,time:r.start})}var a=r.dateTimeObject r.discontinuity&&i&&a&&(this.timelineToDatetimeMappings[r.timeline]=-a.getTime()/1e3)} i.timestampOffsetForTimeline=function(e){return void 0===this.timelines[e]?null:this.timelines[e].time} i.mappingForTimeline=function(e){return void 0===this.timelines[e]?null:this.timelines[e].mapping} i.calculateSegmentTimeMapping_=function(e,t,i){var n,r,a=e.segment,s=e.part,o=this.timelines[e.timeline] if("number"==typeof e.timestampOffset){o={time:e.startOfSegment,mapping:e.startOfSegment-t.start} if(i){this.timelines[e.timeline]=o this.trigger("timestampoffset") this.logger_("time mapping for timeline "+e.timeline+": [time: "+o.time+"] [mapping: "+o.mapping+"]")}n=e.startOfSegment r=t.end+o.mapping}else{if(!o)return!1 n=t.start+o.mapping r=t.end+o.mapping}if(s){s.start=n s.end=r}(!a.start||no){var u=void 0 u=s<0?i.start-hc({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):i.end+hc({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}) this.discontinuities[a]={time:u,accuracy:o}}}} i.dispose=function(){this.trigger("dispose") this.off()} return t}(ql.EventTarget),xh=function(e){B(t,e) function t(){var t;(t=e.call(this)||this).pendingTimelineChanges_={} t.lastTimelineChanges_={} return t}var i=t.prototype i.clearPendingTimelineChange=function(e){this.pendingTimelineChanges_[e]=null this.trigger("pendingtimelinechange")} i.pendingTimelineChange=function(e){var t=e.type,i=e.from,n=e.to if("number"==typeof i&&"number"==typeof n){this.pendingTimelineChanges_[t]={type:t,from:i,to:n} this.trigger("pendingtimelinechange")}return this.pendingTimelineChanges_[t]} i.lastTimelineChange=function(e){var t=e.type,i=e.from,n=e.to if("number"==typeof i&&"number"==typeof n){this.lastTimelineChanges_[t]={type:t,from:i,to:n} delete this.pendingTimelineChanges_[t] this.trigger("timelinechange")}return this.lastTimelineChanges_[t]} i.dispose=function(){this.trigger("dispose") this.pendingTimelineChanges_={} this.lastTimelineChanges_={} this.off()} return t}(ql.EventTarget),Ah=ud(ld((function(){function e(e,t,i){return e(i={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&i.path)}},i.exports),i.exports}var t=e((function(e){function t(e,t){for(var i=0;i-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;!d[t];t^=n||1,i=f[i]||1){a=(a=i^i<<1^i<<2^i<<3^i<<4)>>8^255&a^99 d[t]=a h[a]=t o=16843009*p[r=p[n=p[t]]]^65537*r^257*n^16843008*t s=257*p[a]^16843008*a for(e=0;e<4;e++){l[e][t]=s=s<<24^s>>>8 c[e][a]=o=o<<24^o>>>8}}for(e=0;e<5;e++){l[e]=l[e].slice(0) c[e]=c[e].slice(0)}return u}()) this._tables=[[a[0][0].slice(),a[0][1].slice(),a[0][2].slice(),a[0][3].slice(),a[0][4].slice()],[a[1][0].slice(),a[1][1].slice(),a[1][2].slice(),a[1][3].slice(),a[1][4].slice()]] var t,i,n,r=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 l=e.slice(0),c=[] this._key=[l,c] for(t=o;t<4*o+28;t++){n=l[t-1] if(t%o==0||8===o&&t%o==4){n=r[n>>>24]<<24^r[n>>16&255]<<16^r[n>>8&255]<<8^r[255&n] if(t%o==0){n=n<<8^n>>>24^u<<24 u=u<<1^283*(u>>7)}}l[t]=l[t-o]^n}for(i=0;t;i++,t--){n=l[3&i?t:t-4] c[i]=t<=4||i<4?n:s[0][r[n>>>24]]^s[1][r[n>>16&255]]^s[2][r[n>>8&255]]^s[3][r[255&n]]}}e.prototype.decrypt=function(e,t,i,n,r,a){var s,o,u,l,c=this._key[1],d=e^c[0],h=n^c[1],p=i^c[2],f=t^c[3],m=c.length/4-2,g=4,v=this._tables[1],y=v[0],_=v[1],b=v[2],T=v[3],k=v[4] for(l=0;l>>24]^_[h>>16&255]^b[p>>8&255]^T[255&f]^c[g] o=y[h>>>24]^_[p>>16&255]^b[f>>8&255]^T[255&d]^c[g+1] u=y[p>>>24]^_[f>>16&255]^b[d>>8&255]^T[255&h]^c[g+2] f=y[f>>>24]^_[d>>16&255]^b[h>>8&255]^T[255&p]^c[g+3] g+=4 d=s h=o p=u}for(l=0;l<4;l++){r[(3&-l)+a]=k[d>>>24]<<24^k[h>>16&255]<<16^k[p>>8&255]<<8^k[255&f]^c[g++] s=d d=h h=p p=f f=s}} return e}(),o=function(e){n(t,e) function t(){var t;(t=e.call(this,r)||this).jobs=[] t.delay=1 t.timeout_=null return t}var i=t.prototype i.processJob_=function(){this.jobs.shift()() this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null} i.push=function(e){this.jobs.push(e) this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))} return t}(r),u=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},l=function(){function e(t,i,n,r){var a=e.STEP,s=new Int32Array(t.buffer),l=new Uint8Array(t.byteLength),c=0 this.asyncStream_=new o this.asyncStream_.push(this.decryptChunk_(s.subarray(c,c+a),i,n,l)) for(c=a;c>2),m=new s(Array.prototype.slice.call(t)),g=new Uint8Array(e.byteLength),v=new Int32Array(g.buffer) n=i[0] r=i[1] a=i[2] o=i[3] for(p=0;p=0&&(t="main-desc") return t},Dh=function(e,t){e.abort() e.pause() if(t&&t.activePlaylistLoader){t.activePlaylistLoader.pause() t.activePlaylistLoader=null}},Rh=function(e,t){t.activePlaylistLoader=e e.load()},Mh={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e],r=t.blacklistCurrentPlaylist Dh(i,n) var a=n.activeTrack(),s=n.activeGroup(),o=(s.filter((function(e){return e.default}))[0]||s[0]).id,u=n.tracks[o] if(a!==u){ql.log.warn("Problem encountered loading the alternate audio track.Switching back to default.") for(var l in n.tracks)n.tracks[l].enabled=n.tracks[l]===u n.onTrackChanged()}else r({message:"Problem encountered loading the default audio track."})}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e] ql.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.") Dh(i,n) var r=n.activeTrack() r&&(r.mode="disabled") n.onTrackChanged()}}},Nh={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",Mh[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",Mh[e](e,i))}},Uh={AUDIO:function(e,t){var i=t.vhs,n=t.sourceType,r=t.segmentLoaders[e],a=t.requestOptions,s=t.master.mediaGroups,o=t.mediaTypes[e],u=o.groups,l=o.tracks,c=o.logger_,d=t.masterPlaylistLoader,h=Tc(d.master) if(!s[e]||0===Object.keys(s[e]).length){s[e]={main:{default:{default:!0}}} h&&(s[e].main.default.playlists=d.master.playlists)}for(var p in s[e]){u[p]||(u[p]=[]) for(var f in s[e][p]){var m=s[e][p][f],g=void 0 if(h){c("AUDIO group '"+p+"' label '"+f+"' is a master playlist") m.isMasterPlaylist=!0 g=null}else g="vhs-json"===n&&m.playlists?new Nc(m.playlists[0],i,a):m.resolvedUri?new Nc(m.resolvedUri,i,a):m.playlists&&"dash"===n?new rd(m.playlists[0],i,a,d):null m=ql.mergeOptions({id:f,playlistLoader:g},m) Nh[e](e,m.playlistLoader,t) u[p].push(m) if(void 0===l[f]){var v=new ql.AudioTrack({id:f,kind:Lh(m),enabled:!1,language:m.language,default:m.default,label:f}) l[f]=v}}}r.on("error",Mh[e](e,t))},SUBTITLES:function(e,t){var i=t.tech,n=t.vhs,r=t.sourceType,a=t.segmentLoaders[e],s=t.requestOptions,o=t.master.mediaGroups,u=t.mediaTypes[e],l=u.groups,c=u.tracks,d=t.masterPlaylistLoader for(var h in o[e]){l[h]||(l[h]=[]) for(var p in o[e][h])if(!o[e][h][p].forced){var f=o[e][h][p],m=void 0 if("hls"===r)m=new Nc(f.resolvedUri,n,s) else if("dash"===r){if(!f.playlists.filter((function(e){return e.excludeUntil!==1/0})).length)return m=new rd(f.playlists[0],n,s,d)}else"vhs-json"===r&&(m=new Nc(f.playlists?f.playlists[0]:f.resolvedUri,n,s)) f=ql.mergeOptions({id:p,playlistLoader:m},f) Nh[e](e,f.playlistLoader,t) l[h].push(f) if(void 0===c[p]){var g=i.addRemoteTextTrack({id:p,kind:"subtitles",default:f.default&&f.autoselect,language:f.language,label:p},!1).track c[p]=g}}}a.on("error",Mh[e](e,t))},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,n=t.master.mediaGroups,r=t.mediaTypes[e],a=r.groups,s=r.tracks for(var o in n[e]){a[o]||(a[o]=[]) for(var u in n[e][o]){var l=n[e][o][u] if(/^(?:CC|SERVICE)/.test(l.instreamId)){var c=i.options_.vhs&&i.options_.vhs.captionServices||{},d={label:u,language:l.language,instreamId:l.instreamId,default:l.default&&l.autoselect} c[d.instreamId]&&(d=ql.mergeOptions(d,c[d.instreamId])) void 0===d.default&&delete d.default a[o].push(ql.mergeOptions({id:u},l)) if(void 0===s[u]){var h=i.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track s[u]=h}}}}}},Bh=function e(t,i){for(var n=0;n1&&Tc(t.master))for(var u=0;u "+a+" from "+t) this.tech_.trigger({type:"usage",name:"vhs-rendition-change-"+t})}this.masterPlaylistLoader_.media(e,i)} i.startABRTimer_=function(){var e=this this.stopABRTimer_() this.abrTimer_=x.setInterval((function(){return e.checkABR_()}),250)} i.stopABRTimer_=function(){if(!this.tech_.scrubbing||!this.tech_.scrubbing()){x.clearInterval(this.abrTimer_) this.abrTimer_=null}} i.getAudioTrackPlaylists_=function(){var e=this.master(),t=e&&e.playlists||[] if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t var i,n=e.mediaGroups.AUDIO,r=Object.keys(n) if(Object.keys(this.mediaTypes_.AUDIO.groups).length)i=this.mediaTypes_.AUDIO.activeTrack() else{var a=n.main||r.length&&n[r[0]] for(var s in a)if(a[s].default){i={label:s} break}}if(!i)return t var o=[] for(var u in n)if(n[u][i.label]){var l=n[u][i.label] if(l.playlists&&l.playlists.length)o.push.apply(o,l.playlists) else if(l.uri)o.push(l) else if(e.playlists.length)for(var c=0;c1){this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}) this.tech_.trigger({type:"usage",name:"hls-alternate-audio"})}if(this.useCueTags_){this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"}) this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}} i.shouldSwitchToMedia_=function(e){var t=this.masterPlaylistLoader_.media()||this.masterPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),n=this.bufferLowWaterLine(),r=this.bufferHighWaterLine() return function(e){var t=e.currentPlaylist,i=e.buffered,n=e.currentTime,r=e.nextPlaylist,a=e.bufferLowWaterLine,s=e.bufferHighWaterLine,o=e.duration,u=e.experimentalBufferBasedABR,l=e.log if(!r){ql.log.warn("We received no playlist to switch to. Please check your stream.") return!1}var c="allowing switch "+(t&&t.id||"null")+" -> "+r.id if(!t){l(c+" as current playlist is not set") return!0}if(r.id===t.id)return!1 var d=Boolean(Jl(i,n).length) if(!t.endList){if(!d&&"number"==typeof t.partTargetDuration){l("not "+c+" as current playlist is live llhls, but currentTime isn't in buffered.") return!1}l(c+" as current playlist is live") return!0}var h=nc(i,n),p=u?ad.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:ad.MAX_BUFFER_LOW_WATER_LINE if(om)&&h>=a){var v=c+" as forwardBuffer >= bufferLowWaterLine ("+h+" >= "+a+")" u&&(v+=" and next bandwidth > current bandwidth ("+f+" > "+m+")") l(v) return!0}l("not "+c+" as no switching criteria met") return!1}({buffered:this.tech_.buffered(),currentTime:i,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:this.duration(),experimentalBufferBasedABR:this.experimentalBufferBasedABR,log:this.logger_})} i.setupSegmentLoaderListeners_=function(){var e=this if(!this.experimentalBufferBasedABR){this.mainSegmentLoader_.on("bandwidthupdate",(function(){var t=e.selectPlaylist() e.shouldSwitchToMedia_(t)&&e.switchMedia_(t,"bandwidthupdate") 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){if(!e.experimentalBufferBasedABR){e.delegateLoaders_("all",["abort"]) e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120)}})) var t=function(){if(!e.sourceUpdater_.hasCreatedSourceBuffers())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(){if(!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(){if(!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()}))} i.mediaSecondsLoaded_=function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)} i.load=function(){this.mainSegmentLoader_.load() this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load() this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()} i.smoothQualityChange_=function(e){void 0===e&&(e=this.selectPlaylist()) this.fastQualityChange_(e)} i.fastQualityChange_=function(e){var t=this void 0===e&&(e=this.selectPlaylist()) if(e!==this.masterPlaylistLoader_.media()){this.switchMedia_(e,"fast-quality") this.mainSegmentLoader_.resetEverything((function(){ql.browser.IE_VERSION||ql.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}else this.logger_("skipping fastQualityChange because new media is same as old")} i.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()this.maxPlaylistRetries?1/0:Date.now()+1e3*t i.excludeUntil=n e.reason&&(i.lastExcludeReason_=e.reason) this.tech_.trigger("blacklistplaylist") this.tech_.trigger({type:"usage",name:"vhs-rendition-blacklisted"}) this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}) var u=this.selectPlaylist() if(u){var l=e.internal?this.logger_:ql.log.warn,c=e.message?" "+e.message:"" l((e.internal?"Internal problem":"Problem")+" encountered with playlist "+i.id+"."+c+" Switching to playlist "+u.id+".") u.attributes.AUDIO!==i.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]) u.attributes.SUBTITLES!==i.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]) this.delegateLoaders_("main",["abort","pause"]) var d=u.targetDuration/2*1e3||5e3,h="number"==typeof u.lastRequest&&Date.now()-u.lastRequest<=d return this.switchMedia_(u,"exclude",s||h)}this.error="Playback cannot continue. No available working or supported playlists." this.trigger("error")}else{this.error=e "open"!==this.mediaSource.readyState?this.trigger("error"):this.sourceUpdater_.endOfStream("network")}} i.pauseLoading=function(){this.delegateLoaders_("all",["abort","pause"]) this.stopABRTimer_()} i.delegateLoaders_=function(e,t){var i=this,n=[],r="all"===e;(r||"main"===e)&&n.push(this.masterPlaylistLoader_) var a=[];(r||"audio"===e)&&a.push("AUDIO") if(r||"subtitle"===e){a.push("CLOSED-CAPTIONS") a.push("SUBTITLES")}a.forEach((function(e){var t=i.mediaTypes_[e]&&i.mediaTypes_[e].activePlaylistLoader t&&n.push(t)}));["main","audio","subtitle"].forEach((function(t){var r=i[t+"SegmentLoader_"] !r||e!==t&&"all"!==e||n.push(r)})) n.forEach((function(e){return t.forEach((function(t){"function"==typeof e[t]&&e[t]()}))}))} i.setCurrentTime=function(e){var t=Jl(this.tech_.buffered(),e) if(!this.masterPlaylistLoader_||!this.masterPlaylistLoader_.media())return 0 if(!this.masterPlaylistLoader_.media().segments)return 0 if(t&&t.length)return e this.mainSegmentLoader_.resetEverything() this.mainSegmentLoader_.abort() if(this.mediaTypes_.AUDIO.activePlaylistLoader){this.audioSegmentLoader_.resetEverything() this.audioSegmentLoader_.abort()}if(this.mediaTypes_.SUBTITLES.activePlaylistLoader){this.subtitleSegmentLoader_.resetEverything() this.subtitleSegmentLoader_.abort()}this.load()} i.duration=function(){if(!this.masterPlaylistLoader_)return 0 var e=this.masterPlaylistLoader_.media() return e?e.endList?this.mediaSource?this.mediaSource.duration:nh.Playlist.duration(e):1/0:0} i.seekable=function(){return this.seekable_} i.onSyncInfoUpdate_=function(){var e if(this.masterPlaylistLoader_){var t=this.masterPlaylistLoader_.media() if(t){var i=this.syncController_.getExpiredTime(t,this.duration()) if(null!==i){var n=this.masterPlaylistLoader_.master,r=nh.Playlist.seekable(t,i,nh.Playlist.liveEdgeDelay(n,t)) if(0!==r.length){if(this.mediaTypes_.AUDIO.activePlaylistLoader){t=this.mediaTypes_.AUDIO.activePlaylistLoader.media() if(null===(i=this.syncController_.getExpiredTime(t,this.duration())))return if(0===(e=nh.Playlist.seekable(t,i,nh.Playlist.liveEdgeDelay(n,t))).length)return}var a,s if(this.seekable_&&this.seekable_.length){a=this.seekable_.end(0) s=this.seekable_.start(0)}e?e.start(0)>r.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=ql.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0)0&&(n=Math.max(n,i.end(i.length-1))) this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}else{this.updateDuration_=this.updateDuration.bind(this,e) this.mediaSource.addEventListener("sourceopen",this.updateDuration_)}} i.dispose=function(){var e=this this.trigger("dispose") this.decrypter_.terminate() this.masterPlaylistLoader_.dispose() this.mainSegmentLoader_.dispose() this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);["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()} i.master=function(){return this.masterPlaylistLoader_.master} i.media=function(){return this.masterPlaylistLoader_.media()||this.initialMedia_} i.areMediaTypesKnown_=function(){var e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),i=!e||!!this.audioSegmentLoader_.getCurrentMediaInfo_() return!(!t||!i)} i.getCodecsOrExclude_=function(){var e=this,t={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}} t.video=t.main var i=Bd(this.master(),this.media()),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader t.main.hasVideo&&(n.video=i.video||t.main.videoCodec||"avc1.4d400d") t.main.isMuxed&&(n.video+=","+(i.audio||t.main.audioCodec||Qe)) if(t.main.hasAudio&&!t.main.isMuxed||t.audio.hasAudio||r){n.audio=i.audio||t.main.audioCodec||t.audio.audioCodec||Qe t.audio.isFmp4=t.main.hasAudio&&!t.main.isMuxed?t.main.isFmp4:t.audio.isFmp4}if(n.audio||n.video){var a,s={};["video","audio"].forEach((function(e){if(n.hasOwnProperty(e)&&!(r=t[e].isFmp4,o=n[e],r?Xe(o):Ye(o))){var i=t[e].isFmp4?"browser":"muxer" s[i]=s[i]||[] s[i].push(n[e]) "audio"===e&&(a=i)}var r,o})) if(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_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){var u=[];["video","audio"].forEach((function(t){var i=(Ge(e.sourceUpdater_.codecs[t]||"")[0]||{}).type,r=(Ge(n[t]||"")[0]||{}).type i&&r&&i.toLowerCase()!==r.toLowerCase()&&u.push('"'+e.sourceUpdater_.codecs[t]+'" -> "'+n[t]+'"')})) if(u.length){this.blacklistCurrentPlaylist({playlist:this.media(),message:"Codec switching not supported: "+u.join(", ")+".",blacklistDuration:1/0,internal:!0}) return}}return n}var l=Object.keys(s).reduce((function(e,t){e&&(e+=", ") return e+=t+' does not support codec(s): "'+s[t].join(",")+'"'}),"")+"." this.blacklistCurrentPlaylist({playlist:this.media(),internal:!0,message:l,blacklistDuration:1/0})}else this.blacklistCurrentPlaylist({playlist:this.media(),message:"Could not determine codecs for playlist.",blacklistDuration:1/0})} i.tryToCreateSourceBuffers_=function(){if("open"===this.mediaSource.readyState&&!this.sourceUpdater_.hasCreatedSourceBuffers()&&this.areMediaTypesKnown_()){var e=this.getCodecsOrExclude_() if(e){this.sourceUpdater_.createSourceBuffers(e) var t=[e.video,e.audio].filter(Boolean).join(",") this.excludeIncompatibleVariants_(t)}}} i.excludeUnsupportedVariants_=function(){var e=this,t=this.master().playlists,i=[] Object.keys(t).forEach((function(n){var r=t[n] if(-1===i.indexOf(r.id)){i.push(r.id) var a=Bd(e.master,r),s=[] !a.audio||Ye(a.audio)||Xe(a.audio)||s.push("audio codec "+a.audio) !a.video||Ye(a.video)||Xe(a.video)||s.push("video codec "+a.video) a.text&&"stpp.ttml.im1t"===a.text&&s.push("text codec "+a.text) if(s.length){r.excludeUntil=1/0 e.logger_("excluding "+r.id+" for unsupported: "+s.join(", "))}}}))} i.excludeIncompatibleVariants_=function(e){var t=this,i=[],n=this.master().playlists,r=Nd(Ge(e)),a=Ud(r),s=r.video&&Ge(r.video)[0]||null,o=r.audio&&Ge(r.audio)[0]||null Object.keys(n).forEach((function(e){var r=n[e] if(-1===i.indexOf(r.id)&&r.excludeUntil!==1/0){i.push(r.id) var u=[],l=Bd(t.masterPlaylistLoader_.master,r),c=Ud(l) if(l.audio||l.video){c!==a&&u.push('codec count "'+c+'" !== "'+a+'"') if(!t.sourceUpdater_.canChangeType()){var d=l.video&&Ge(l.video)[0]||null,h=l.audio&&Ge(l.audio)[0]||null d&&s&&d.type.toLowerCase()!==s.type.toLowerCase()&&u.push('video codec "'+d.type+'" !== "'+s.type+'"') h&&o&&h.type.toLowerCase()!==o.type.toLowerCase()&&u.push('audio codec "'+h.type+'" !== "'+o.type+'"')}if(u.length){r.excludeUntil=1/0 t.logger_("blacklisting "+r.id+": "+u.join(" && "))}}}}))} i.updateAdCues_=function(e){var t=0,i=this.seekable() i.length&&(t=i.start(0)) !function(e,t,i){void 0===i&&(i=0) if(e.segments)for(var n,r=i,a=0;a0&&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_() if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime){this.consecutiveUpdates++ this.waiting_()}else if(e===this.lastRecordedTime)this.consecutiveUpdates++ else{this.consecutiveUpdates=0 this.lastRecordedTime=e}}} t.cancelTimer_=function(){this.consecutiveUpdates=0 if(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)}if(this.beforeSeekableWindow_(t,i)){var n=t.start(0) e=n+(n===t.end(0)?0:Ql)}if(void 0!==e){this.logger_("Trying to seek outside of seekable at time "+i+" with seekable range "+ec(t)+". Seeking to "+e+".") this.tech_.setCurrentTime(e) return!0}for(var r=this.masterPlaylistController_.sourceUpdater_,a=this.tech_.buffered(),s=r.audioBuffer?r.audioBuffered():null,o=r.videoBuffer?r.videoBuffered():null,u=this.media(),l=u.partTargetDuration?u.partTargetDuration:2*(u.targetDuration-Yl),c=[s,o],d=0;d "+i.end(0)+"]. Attempting to resume playback by seeking to the current time.") this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"}) this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})}else;}} t.techWaiting_=function(){var e=this.seekable(),t=this.tech_.currentTime() if(this.tech_.seeking()||null!==this.timer_)return!0 if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1) 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"}) return!0}var n=this.tech_.vhs.masterPlaylistController_.sourceUpdater_,r=this.tech_.buffered() if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t})){this.cancelTimer_() this.tech_.setCurrentTime(t) this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}) this.tech_.trigger({type:"usage",name:"hls-video-underflow"}) return!0}var a=Zl(r,t) if(a.length>0){var s=a.start(0)-t 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) return!0}return!1} t.afterSeekableWindow_=function(e,t,i,n){void 0===n&&(n=!1) if(!e.length)return!1 var r=e.end(e.length-1)+Ql !i.endList&&n&&(r=e.end(e.length-1)+3*i.targetDuration) return t>r} t.beforeSeekableWindow_=function(e,t){return!!(e.length&&e.start(0)>0&&t2)return{start:r,end:a}}return null} return e}(),Kh={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},Xh=function e(t,i){var n=0,r=0,a=ql.mergeOptions(Kh,i) t.ready((function(){t.trigger({type:"usage",name:"vhs-error-reload-initialized"}) t.trigger({type:"usage",name:"hls-error-reload-initialized"})})) var s=function(){r&&t.currentTime(r)},o=function(e){if(null!=e){r=t.duration()!==1/0&&t.currentTime()||0 t.one("loadedmetadata",s) t.src(e) t.trigger({type:"usage",name:"vhs-error-reload"}) t.trigger({type:"usage",name:"hls-error-reload"}) t.play()}},u=function(){if(Date.now()-n<1e3*a.errorInterval){t.trigger({type:"usage",name:"vhs-error-reload-canceled"}) t.trigger({type:"usage",name:"hls-error-reload-canceled"})}else{if(a.getSource&&"function"==typeof a.getSource){n=Date.now() return a.getSource.call(t,o)}ql.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")}},l=function e(){t.off("loadedmetadata",s) t.off("error",u) t.off("dispose",e)} t.on("error",u) t.on("dispose",l) t.reloadSourceOnError=function(i){l() e(t,i)}},Yh="2.14.0",Qh={PlaylistLoader:Nc,Playlist:kc,utils:Yc,STANDARD_PLAYLIST_SELECTOR:Gd,INITIAL_PLAYLIST_SELECTOR:function(){var e=this,t=this.playlists.master.playlists.filter(kc.isEnabled) Hd(t,(function(e,t){return qd(e,t)})) return t.filter((function(t){return!!Bd(e.playlists.master,t).video}))[0]||null},lastBandwidthSelector:Gd,movingAverageBandwidthSelector:function(e){var t=-1,i=-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&&x.devicePixelRatio||1 if(t<0){t=this.systemBandwidth i=this.systemBandwidth}if(this.systemBandwidth>0&&this.systemBandwidth!==i){t=e*this.systemBandwidth+(1-e)*t i=this.systemBandwidth}return Wd(this.playlists.master,t,parseInt(Vd(this.tech_.el(),"width"),10)*n,parseInt(Vd(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions,this.masterPlaylistController_)}},comparePlaylistBandwidth:qd,comparePlaylistResolution:function(e,t){var i,n e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width) i=i||x.Number.MAX_VALUE t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width) return i===(n=n||x.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:jc()} Object.keys(ad).forEach((function(e){Object.defineProperty(Qh,e,{get:function(){ql.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing") return ad[e]},set:function(t){ql.log.warn("using Vhs."+e+" is UNSAFE be sure you know what you are doing") "number"!=typeof t||t<0?ql.log.warn("value of Vhs."+e+" must be greater than or equal to 0"):ad[e]=t}})})) var $h="videojs-vhs",Jh=function(e,t){for(var i=t.media(),n=-1,r=0;r