uxerLog:p})}))}({decryptionWorker:i,segment:g,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:l,endedTimelineFn:c,dataFn:d,doneFn:h,onTransmuxerLog:p}) xd({segment:g,bytes:g.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:l,endedTimelineFn:c,dataFn:d,doneFn:h,onTransmuxerLog:p})} g.endOfAllRequests=Date.now() if(g.map&&g.map.encryptedBytes&&!g.map.bytes)return Ad({decryptionWorker:i,id:g.requestId+"-init",encryptedBytes:g.map.encryptedBytes,key:g.map.key},(function(e){g.map.bytes=e wd(g,(function(e){if(e){Sd(t) return h(e,g)}v()}))})) v()}}}},Ld=function(e){var t=e.segment,i=e.progressFn e.trackInfoFn e.timingInfoFn e.videoSegmentTimingInfoFn e.audioSegmentTimingInfoFn e.id3Fn e.captionsFn e.isEndOfTimeline e.endedTimelineFn e.dataFn return function(e){if(!e.target.aborted){t.stats=ql.mergeOptions(t.stats,function(e){var t=e.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0} i.bytesReceived=e.loaded i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3) return i}(e)) !t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()) return i(e,t)}}},Dd=function(e){var t=e.xhr,i=e.xhrOptions,n=e.decryptionWorker,r=e.segment,a=e.abortFn,s=e.progressFn,o=e.trackInfoFn,u=e.timingInfoFn,l=e.videoSegmentTimingInfoFn,c=e.audioSegmentTimingInfoFn,d=e.id3Fn,h=e.captionsFn,p=e.isEndOfTimeline,f=e.endedTimelineFn,m=e.dataFn,g=e.doneFn,v=e.onTransmuxerLog,y=[],_=Od({activeXhrs:y,decryptionWorker:n,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:d,captionsFn:h,isEndOfTimeline:p,endedTimelineFn:f,dataFn:m,doneFn:g,onTransmuxerLog:v}) if(r.key&&!r.key.bytes){var b=[r.key] r.map&&!r.map.bytes&&r.map.key&&r.map.key.resolvedUri===r.key.resolvedUri&&b.push(r.map.key) var T=t(ql.mergeOptions(i,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),Cd(r,b,_)) y.push(T)}if(r.map&&!r.map.bytes){if(r.map.key&&(!r.key||r.key.resolvedUri!==r.map.key.resolvedUri)){var k=t(ql.mergeOptions(i,{uri:r.map.key.resolvedUri,responseType:"arraybuffer"}),Cd(r,[r.map.key],_)) y.push(k)}var S=ql.mergeOptions(i,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:Vc(r.map)}),E=function(e){var t=e.segment,i=e.finishProcessingFn return function(e,n){var r=Ed(e,n) if(r)return i(r,t) var a=new Uint8Array(n.response) if(t.map.key){t.map.encryptedBytes=a return i(null,t)}t.map.bytes=a wd(t,(function(e){if(e){e.xhr=n e.status=n.status return i(e,t)}i(null,t)}))}}({segment:r,finishProcessingFn:_}),C=t(S,E) y.push(C)}var w=ql.mergeOptions(i,{uri:r.part&&r.part.resolvedUri||r.resolvedUri,responseType:"arraybuffer",headers:Vc(r)}),I=t(w,Id({segment:r,finishProcessingFn:_,responseType:w.responseType})) I.addEventListener("progress",Ld({segment:r,progressFn:s,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:d,captionsFn:h,isEndOfTimeline:p,endedTimelineFn:f,dataFn:m})) y.push(I) var P={} y.forEach((function(e){e.addEventListener("loadend",function(e){var t=e.loadendState,i=e.abortFn return function(e){if(e.target.aborted&&i&&!t.calledAbortFn){i() t.calledAbortFn=!0}}}({loadendState:P,abortFn:a}))})) return function(){return Sd(y)}},Rd=Xl("CodecUtils"),Md=function(e,t){var i=t.attributes||{} return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&i.AUDIO&&e.mediaGroups.AUDIO[i.AUDIO]},Nd=function(e){var t={} e.forEach((function(e){var i=e.mediaType,n=e.type,r=e.details t[i]=t[i]||[] t[i].push(We(""+n+r))})) Object.keys(t).forEach((function(e){if(t[e].length>1){Rd("multiple "+e+" codecs found as attributes: "+t[e].join(", ")+". Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.") t[e]=null}else t[e]=t[e][0]})) return t},Ud=function(e){var t=0 e.audio&&t++ e.video&&t++ return t},Bd=function(e,t){var i=t.attributes||{},n=Nd(function(e){var t=e.attributes||{} if(t.CODECS)return Ge(t.CODECS)}(t)||[]) if(Md(e,t)&&!n.audio&&!function(e,t){if(!Md(e,t))return!0 var i=t.attributes||{},n=e.mediaGroups.AUDIO[i.AUDIO] for(var r in n)if(!n[r].uri&&!n[r].playlists)return!0 return!1}(e,t)){var r=Nd(function(e,t){if(!e.mediaGroups.AUDIO||!t)return null var i=e.mediaGroups.AUDIO[t] if(!i)return null for(var n in i){var r=i[n] if(r.default&&r.playlists)return Ge(r.playlists[0].attributes.CODECS)}return null}(e,i.AUDIO)||[]) r.audio&&(n.audio=r.audio)}return n},Fd=Xl("PlaylistSelector"),jd=function(e){if(e&&e.playlist){var t=e.playlist return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})}},Vd=function(e,t){if(!e)return"" var i=x.getComputedStyle(e) return i?i[t]:""},Hd=function(e,t){var i=e.slice() e.sort((function(e,n){var r=t(e,n) return 0===r?i.indexOf(e)-i.indexOf(n):r}))},qd=function(e,t){var i,n e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH) i=i||x.Number.MAX_VALUE t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH) return i-(n=n||x.Number.MAX_VALUE)},Wd=function(e,t,i,n,r,a){if(e){var s={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:r},o=e.playlists if(kc.isAudioOnly(e)){o=a.getAudioTrackPlaylists_() s.audioOnly=!0}var u=o.map((function(e){var t=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height return{bandwidth:e.attributes&&e.attributes.BANDWIDTH||x.Number.MAX_VALUE,width:t,height:i,playlist:e}})) Hd(u,(function(e,t){return e.bandwidth-t.bandwidth})) var l=(u=u.filter((function(e){return!kc.isIncompatible(e.playlist)}))).filter((function(e){return kc.isEnabled(e.playlist)})) l.length||(l=u.filter((function(e){return!kc.isDisabled(e.playlist)}))) var c=l.filter((function(e){return e.bandwidth*ad.BANDWIDTH_VARIANCEi||e.height>n}))).filter((function(e){return e.width===v[0].width&&e.height===v[0].height})) d=y[y.length-1] _=y.filter((function(e){return e.bandwidth===d.bandwidth}))[0]}if(a.experimentalLeastPixelDiffSelector){var k=m.map((function(e){e.pixelDiff=Math.abs(e.width-i)+Math.abs(e.height-n) return e})) Hd(k,(function(e,t){return e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff})) b=k[0]}var S=b||_||T||h||l[0]||u[0] if(S&&S.playlist){var E="sortedPlaylistReps" b?E="leastPixelDiffRep":_?E="resolutionPlusOneRep":T?E="resolutionBestRep":h?E="bandwidthBestRep":l[0]&&(E="enabledPlaylistReps") Fd("choosing "+jd(S)+" using "+E+" with options",s) return S.playlist}Fd("could not choose a playlist with options",s) return null}},Gd=function(){var e=this.useDevicePixelRatio&&x.devicePixelRatio||1 return Wd(this.playlists.master,this.systemBandwidth,parseInt(Vd(this.tech_.el(),"width"),10)*e,parseInt(Vd(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions,this.masterPlaylistController_)},zd=function(e){var t=e.inbandTextTracks,i=e.metadataArray,n=e.timestampOffset,r=e.videoDuration if(i){var a=x.WebKitDataCue||x.VTTCue,s=t.metadataTrack_ if(s){i.forEach((function(e){var t=e.cueTime+n !("number"!=typeof t||x.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new a(t,t,e.value||e.url||e.data||"") i.frame=e i.value=e !function(e){Object.defineProperties(e.frame,{id:{get:function(){ql.log.warn("cue.frame.id is deprecated. Use cue.value.key instead.") return e.value.key}},value:{get:function(){ql.log.warn("cue.frame.value is deprecated. Use cue.value.data instead.") return e.value.data}},privateData:{get:function(){ql.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead.") return e.value.data}}})}(i) s.addCue(i)}))})) if(s.cues&&s.cues.length){for(var o=s.cues,u=[],l=0;l=e&&r.endTime<=t&&i.removeCue(r)}},Xd=function(e){return"number"==typeof e&&isFinite(e)},Yd=1/60,Qd=function(e){var t=e.startOfSegment,i=e.duration,n=e.segment,r=e.part,a=e.playlist,s=a.mediaSequence,o=a.id,u=a.segments,l=void 0===u?[]:u,c=e.mediaIndex,d=e.partIndex,h=e.timeline,p=l.length-1,f="mediaIndex/partIndex increment" e.getMediaInfoForTime?f="getMediaInfoForTime ("+e.getMediaInfoForTime+")":e.isSyncRequest&&(f="getSyncSegmentCandidate (isSyncRequest)") e.independent&&(f+=" with independent "+e.independent) var m="number"==typeof d,g=e.segment.uri?"segment":"pre-segment",v=m?uc({preloadSegment:n})-1:0 return g+" ["+(s+c)+"/"+(s+p)+"]"+(m?" part ["+d+"/"+v+"]":"")+" segment start/end ["+n.start+" => "+n.end+"]"+(m?" part start/end ["+r.start+" => "+r.end+"]":"")+" startOfSegment ["+t+"] duration ["+i+"] timeline ["+h+"] selected by ["+f+"] playlist ["+o+"]"},$d=function(e){return e+"TimingInfo"},Jd=function(e){var t=e.timelineChangeController,i=e.currentTimeline,n=e.segmentTimeline,r=e.loaderType,a=e.audioDisabled if(i===n)return!1 if("audio"===r){var s=t.lastTimelineChange({type:"main"}) return!s||s.to!==n}if("main"===r&&a){var o=t.pendingTimelineChange({type:"audio"}) return!o||o.to!==n}return!1},Zd=function(e){var t=e.segmentDuration,i=e.maxDuration return!!t&&Math.round(t)>i+Yl},eh=function(e,t){if("hls"!==t)return null var i=function(e){var t=0;["video","audio"].forEach((function(i){var n=e[i+"TimingInfo"] if(n){var r,a=n.start,s=n.end "bigint"==typeof a||"bigint"==typeof s?r=x.BigInt(s)-x.BigInt(a):"number"==typeof a&&"number"==typeof s&&(r=s-a) void 0!==r&&r>t&&(t=r)}})) "bigint"==typeof t&&t=11 n.appendInitSegment_={audio:!0,video:!0} n.playlistOfLastInitSegment_={audio:null,video:null} n.callQueue_=[] n.loadQueue_=[] n.metadataQueue_={id3:[],caption:[]} n.waitingOnRemove_=!1 n.quotaExceededErrorRetryTimeout_=null n.activeInitSegmentId_=null n.initSegments_={} n.cacheEncryptionKeys_=t.cacheEncryptionKeys n.keyCache_={} n.decrypter_=t.decrypter n.syncController_=t.syncController n.syncPoint_={segmentIndex:0,time:0} n.transmuxer_=n.createTransmuxer_() n.triggerSyncInfoUpdate_=function(){return n.trigger("syncinfoupdate")} n.syncController_.on("syncinfoupdate",n.triggerSyncInfoUpdate_) n.mediaSource_.addEventListener("sourceopen",(function(){n.isEndOfStream_()||(n.ended_=!1)})) n.fetchAtBuffer_=!1 n.logger_=Xl("SegmentLoader["+n.loaderType_+"]") Object.defineProperty(N(n),"state",{get:function(){return this.state_},set:function(e){if(e!==this.state_){this.logger_(this.state_+" -> "+e) this.state_=e this.trigger("statechange")}}}) n.sourceUpdater_.on("ready",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_()})) "main"===n.loaderType_&&n.timelineChangeController_.on("pendingtimelinechange",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_()})) "audio"===n.loaderType_&&n.timelineChangeController_.on("timelinechange",(function(){n.hasEnoughInfoToLoad_()&&n.processLoadQueue_() n.hasEnoughInfoToAppend_()&&n.processCallQueue_()})) return n}var i=t.prototype i.createTransmuxer_=function(){return yd({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})} i.resetStats_=function(){this.mediaBytesTransferred=0 this.mediaRequests=0 this.mediaRequestsAborted=0 this.mediaRequestsTimedout=0 this.mediaRequestsErrored=0 this.mediaTransferDuration=0 this.mediaSecondsLoaded=0 this.mediaAppends=0} i.dispose=function(){this.trigger("dispose") this.state="DISPOSED" this.pause() this.abort_() this.transmuxer_&&this.transmuxer_.terminate() this.resetStats_() this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_) this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_) this.off()} i.setAudio=function(e){this.audioDisabled_=!e e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())} i.abort=function(){if("WAITING"===this.state){this.abort_() this.state="READY" this.paused()||this.monitorBuffer_()}else this.pendingSegment_&&(this.pendingSegment_=null)} i.abort_=function(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests() this.pendingSegment_=null this.callQueue_=[] this.loadQueue_=[] this.metadataQueue_.id3=[] this.metadataQueue_.caption=[] this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_) this.waitingOnRemove_=!1 x.clearTimeout(this.quotaExceededErrorRetryTimeout_) this.quotaExceededErrorRetryTimeout_=null} i.checkForAbort_=function(e){if("APPENDING"===this.state&&!this.pendingSegment_){this.state="READY" return!0}return!this.pendingSegment_||this.pendingSegment_.requestId!==e} i.error=function(e){if(void 0!==e){this.logger_("error occurred:",e) this.error_=e}this.pendingSegment_=null return this.error_} i.endOfStream=function(){this.ended_=!0 this.transmuxer_&&vd(this.transmuxer_) this.gopBuffer_.length=0 this.pause() this.trigger("ended")} i.buffered_=function(){var e=this.getMediaInfo_() if(!this.sourceUpdater_||!e)return ql.createTimeRanges() if("main"===this.loaderType_){var t=e.hasAudio,i=e.hasVideo,n=e.isMuxed if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered() if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()} i.initSegmentForMap=function(e,t){void 0===t&&(t=!1) if(!e)return null var i=zc(e),n=this.initSegments_[i] t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}) return n||e} i.segmentKey=function(e,t){void 0===t&&(t=!1) if(!e)return null var i=Kc(e),n=this.keyCache_[i] this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes}) var r={resolvedUri:(n||e).resolvedUri} n&&(r.bytes=n.bytes) return r} i.couldBeginLoading_=function(){return this.playlist_&&!this.paused()} i.load=function(){this.monitorBuffer_() if(this.playlist_){if("INIT"===this.state&&this.couldBeginLoading_())return this.init_() !this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY")}} i.init_=function(){this.state="READY" this.resetEverything() return this.monitorBuffer_()} i.playlist=function(e,t){void 0===t&&(t={}) if(e){var i=this.playlist_,n=this.pendingSegment_ this.playlist_=e this.xhrOptions_=t if("INIT"===this.state){e.syncInfo={mediaSequence:e.mediaSequence,time:0} "main"===this.loaderType_&&this.syncController_.setDateTimeMappingForStart(e)}var r=null i&&(i.id?r=i.id:i.uri&&(r=i.uri)) this.logger_("playlist update ["+r+" => "+(e.id||e.uri)+"]") this.trigger("syncinfoupdate") if("INIT"===this.state&&this.couldBeginLoading_())return this.init_() if(i&&i.uri===e.uri){var a=e.mediaSequence-i.mediaSequence this.logger_("live window shift ["+a+"]") if(null!==this.mediaIndex){this.mediaIndex-=a if(this.mediaIndex<0){this.mediaIndex=null this.partIndex=null}else{var s=this.playlist_.segments[this.mediaIndex] if(this.partIndex&&(!s.parts||!s.parts.length||!s.parts[this.partIndex])){var o=this.mediaIndex this.logger_("currently processing part (index "+this.partIndex+") no longer exists.") this.resetLoader() this.mediaIndex=o}}}if(n){n.mediaIndex-=a if(n.mediaIndex<0){n.mediaIndex=null n.partIndex=null}else{n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex]) n.partIndex>=0&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex])}}this.syncController_.saveExpiredSegmentInfo(i,e)}else{null!==this.mediaIndex&&(e.endList?this.resyncLoader():this.resetLoader()) this.currentMediaInfo_=void 0 this.trigger("playlistupdate")}}} i.pause=function(){if(this.checkBufferTimeout_){x.clearTimeout(this.checkBufferTimeout_) this.checkBufferTimeout_=null}} i.paused=function(){return null===this.checkBufferTimeout_} i.resetEverything=function(e){this.ended_=!1 this.appendInitSegment_={audio:!0,video:!0} this.resetLoader() this.remove(0,1/0,e) if(this.transmuxer_){this.transmuxer_.postMessage({action:"clearAllMp4Captions"}) this.transmuxer_.postMessage({action:"reset"})}} i.resetLoader=function(){this.fetchAtBuffer_=!1 this.resyncLoader()} i.resyncLoader=function(){this.transmuxer_&&vd(this.transmuxer_) this.mediaIndex=null this.partIndex=null this.syncPoint_=null this.isPendingTimestampOffset_=!1 this.callQueue_=[] this.loadQueue_=[] this.metadataQueue_.id3=[] this.metadataQueue_.caption=[] this.abort() this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})} i.remove=function(e,t,i,n){void 0===i&&(i=function(){}) void 0===n&&(n=!1) t===1/0&&(t=this.duration_()) if(t<=e)this.logger_("skipping remove because end ${end} is <= start ${start}") else if(this.sourceUpdater_&&this.getMediaInfo_()){var r=1,a=function(){0===--r&&i()} if(n||!this.audioDisabled_){r++ this.sourceUpdater_.removeAudio(e,t,a)}if(n||"main"===this.loaderType_){this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil((t-n)*wr),a=Math.ceil((i-n)*wr),s=e.slice(),o=e.length;o--&&!(e[o].pts<=a););if(-1===o)return s for(var u=o+1;u--&&!(e[u].pts<=r););u=Math.max(u,0) s.splice(u,o-u+1) return s}(this.gopBuffer_,e,t,this.timeMapping_) r++ this.sourceUpdater_.removeVideo(e,t,a)}for(var s in this.inbandTextTracks_)Kd(e,t,this.inbandTextTracks_[s]) Kd(e,t,this.segmentMetadataTrack_) a()}else this.logger_("skipping remove because no source updater or starting media info")} i.monitorBuffer_=function(){this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_) this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),1)} i.monitorBufferTick_=function(){"READY"===this.state&&this.fillBuffer_() this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_) this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),500)} i.fillBuffer_=function(){if(!this.sourceUpdater_.updating()){var e=this.chooseNextRequest_() if(e){if("number"==typeof e.timestampOffset){this.isPendingTimestampOffset_=!1 this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})}this.loadSegment_(e)}}} i.isEndOfStream_=function(e,t,i){void 0===e&&(e=this.mediaIndex) void 0===t&&(t=this.playlist_) void 0===i&&(i=this.partIndex) if(!t||!this.mediaSource_)return!1 var n="number"==typeof e&&t.segments[e],r=e+1===t.segments.length,a=!n||!n.parts||i+1===n.parts.length return t.endList&&"open"===this.mediaSource_.readyState&&r&&a} i.chooseNextRequest_=function(){var e=this.buffered_(),t=ic(e)||0,i=nc(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),a=this.playlist_.segments if(!a.length||n||r)return null this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()) var s={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)} if(s.isSyncRequest)s.mediaIndex=function(e,t,i){t=t||[] for(var n=[],r=0,a=0;ai)return a}}return 0===n.length?0:n[n.length-1]}(this.currentTimeline_,a,t) else if(null!==this.mediaIndex){var o=a[this.mediaIndex],u="number"==typeof this.partIndex?this.partIndex:-1 s.startOfSegment=o.end?o.end:t if(o.parts&&o.parts[u+1]){s.mediaIndex=this.mediaIndex s.partIndex=u+1}else s.mediaIndex=this.mediaIndex+1}else{var l=kc.getMediaInfoForTime({experimentalExactManifestTimings:this.experimentalExactManifestTimings,playlist:this.playlist_,currentTime:this.fetchAtBuffer_?t:this.currentTime_(),startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time}),c=l.segmentIndex,d=l.startTime,h=l.partIndex s.getMediaInfoForTime=this.fetchAtBuffer_?"bufferedEnd "+t:"currentTime "+this.currentTime_() s.mediaIndex=c s.startOfSegment=d s.partIndex=h}var p=a[s.mediaIndex],f=p&&"number"==typeof s.partIndex&&p.parts&&p.parts[s.partIndex] if(!p||"number"==typeof s.partIndex&&!f)return null if("number"!=typeof s.partIndex&&p.parts){s.partIndex=0 f=p.parts[0]}if(!i&&f&&!f.independent)if(0===s.partIndex){var m=a[s.mediaIndex-1],g=m.parts&&m.parts.length&&m.parts[m.parts.length-1] if(g&&g.independent){s.mediaIndex-=1 s.partIndex=m.parts.length-1 s.independent="previous segment"}}else if(p.parts[s.partIndex-1].independent){s.partIndex-=1 s.independent="previous part"}var v=this.mediaSource_&&"ended"===this.mediaSource_.readyState return s.mediaIndex>=a.length-1&&v&&!this.seeking_()?null:this.generateSegmentInfo_(s)} i.generateSegmentInfo_=function(e){var t=e.independent,i=e.playlist,n=e.mediaIndex,r=e.startOfSegment,a=e.isSyncRequest,s=e.partIndex,o=e.forceTimestampOffset,u=e.getMediaInfoForTime,l=i.segments[n],c="number"==typeof s&&l.parts[s],d={requestId:"segment-loader-"+Math.random(),uri:c&&c.resolvedUri||l.resolvedUri,mediaIndex:n,partIndex:c?s:null,isSyncRequest:a,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:l.timeline,duration:c&&c.duration||l.duration,segment:l,part:c,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:u,independent:t},h=void 0!==o?o:this.isPendingTimestampOffset_ d.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:l.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:h}) var p=ic(this.sourceUpdater_.audioBuffered()) "number"==typeof p&&(d.audioAppendStart=p-this.sourceUpdater_.audioTimestampOffset()) this.sourceUpdater_.videoBuffered().length&&(d.gopsToAlignWith=function(e,t,i){if(null==t||!e.length)return[] var n,r=Math.ceil((t-i+3)*wr) for(n=0;nr);n++);return e.slice(n)}(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)) return d} i.timestampOffsetForSegment_=function(e){return i=(t=e).segmentTimeline,n=t.currentTimeline,r=t.startOfSegment,a=t.buffered,t.overrideCheck||i!==n?i "+s+" for "+e) !function(e,t,i){if(!e[i]){t.trigger({type:"usage",name:"vhs-608"}) t.trigger({type:"usage",name:"hls-608"}) var n=i;/^cc708_/.test(i)&&(n="SERVICE"+i.split("_")[1]) var r=t.textTracks().getTrackById(n) if(r)e[i]=r else{var a=i,s=i,o=!1,u=(t.options_.vhs&&t.options_.vhs.captionServices||{})[n] if(u){a=u.label s=u.language o=u.default}e[i]=t.addRemoteTextTrack({kind:"captions",id:n,default:o,label:a,language:s},!1).track}}}(u,i.vhs_.tech_,e) Kd(a,s,u[e]) !function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset if(i){var r=x.WebKitDataCue||x.VTTCue i.forEach((function(e){var i=e.stream t[i].addCue(new r(e.startTime+n,e.endTime+n,e.text))}))}}({captionArray:o,inbandTextTracks:u,timestampOffset:n})})) this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}else this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t))}else this.logger_("SegmentLoader received no captions from a caption event")} i.handleId3_=function(e,t,i){this.earlyAbortWhenNeeded_(e.stats) if(!this.checkForAbort_(e.requestId)){if(this.pendingSegment_.hasAppendedData_){var n=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset() !function(e,t,i){if(!e.metadataTrack_){e.metadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track e.metadataTrack_.inBandMetadataTrackDispatchType=t}}(this.inbandTextTracks_,i,this.vhs_.tech_) zd({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:this.duration_()})}else this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i))}} i.processMetadataQueue_=function(){this.metadataQueue_.id3.forEach((function(e){return e()})) this.metadataQueue_.caption.forEach((function(e){return e()})) this.metadataQueue_.id3=[] this.metadataQueue_.caption=[]} i.processCallQueue_=function(){var e=this.callQueue_ this.callQueue_=[] e.forEach((function(e){return e()}))} i.processLoadQueue_=function(){var e=this.loadQueue_ this.loadQueue_=[] e.forEach((function(e){return e()}))} i.hasEnoughInfoToLoad_=function(){if("audio"!==this.loaderType_)return!0 var e=this.pendingSegment_ return!!e&&(!this.getCurrentMediaInfo_()||!Jd({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))} i.getCurrentMediaInfo_=function(e){void 0===e&&(e=this.pendingSegment_) return e&&e.trackInfo||this.currentMediaInfo_} i.getMediaInfo_=function(e){void 0===e&&(e=this.pendingSegment_) return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_} i.hasEnoughInfoToAppend_=function(){if(!this.sourceUpdater_.ready())return!1 if(this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1 var e=this.pendingSegment_,t=this.getCurrentMediaInfo_() if(!e||!t)return!1 var i=t.hasAudio,n=t.hasVideo,r=t.isMuxed return!(n&&!e.videoTimingInfo)&&(!(i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo)&&!Jd({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))} i.handleData_=function(e,t){this.earlyAbortWhenNeeded_(e.stats) if(!this.checkForAbort_(e.requestId))if(!this.callQueue_.length&&this.hasEnoughInfoToAppend_()){var i=this.pendingSegment_ this.setTimeMapping_(i.timeline) this.updateMediaSecondsLoaded_(i.part||i.segment) if("closed"!==this.mediaSource_.readyState){if(e.map){e.map=this.initSegmentForMap(e.map,!0) i.segment.map=e.map}e.key&&this.segmentKey(e.key,!0) i.isFmp4=e.isFmp4 i.timingInfo=i.timingInfo||{} if(i.isFmp4){this.trigger("fmp4") i.timingInfo.start=i[$d(t.type)].start}else{var n,r=this.getCurrentMediaInfo_(),a="main"===this.loaderType_&&r&&r.hasVideo a&&(n=i.videoTimingInfo.start) i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:a,firstVideoFrameTimeForData:n,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}this.updateAppendInitSegmentStatus(i,t.type) this.updateSourceBufferTimestampOffset_(i) if(i.isSyncRequest){this.updateTimingInfoEnd_(i) this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:"main"===this.loaderType_}) var s=this.chooseNextRequest_() if(s.mediaIndex!==i.mediaIndex||s.partIndex!==i.partIndex){this.logger_("sync segment was incorrect, not appending") return}this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0 this.processMetadataQueue_() this.appendData_(i,t)}}else this.callQueue_.push(this.handleData_.bind(this,e,t))} i.updateAppendInitSegmentStatus=function(e,t){"main"!==this.loaderType_||"number"!=typeof e.timestampOffset||e.changedTimestampOffset||(this.appendInitSegment_={audio:!0,video:!0}) this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)} i.getInitSegmentAndUpdateState_=function(e){var t=e.type,i=e.initSegment,n=e.map,r=e.playlist if(n){var a=zc(n) if(this.activeInitSegmentId_===a)return null i=this.initSegmentForMap(n,!0).bytes this.activeInitSegmentId_=a}if(i&&this.appendInitSegment_[t]){this.playlistOfLastInitSegment_[t]=r this.appendInitSegment_[t]=!1 this.activeInitSegmentId_=null return i}return null} i.handleQuotaExceededError_=function(e,t){var i=this,n=e.segmentInfo,r=e.type,a=e.bytes,s=this.sourceUpdater_.audioBuffered(),o=this.sourceUpdater_.videoBuffered() s.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+tc(s).join(", ")) o.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+tc(o).join(", ")) var u=s.length?s.start(0):0,l=s.length?s.end(s.length-1):0,c=o.length?o.start(0):0,d=o.length?o.end(o.length-1):0 if(l-u<=1&&d-c<=1){this.logger_("On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: "+a.byteLength+", audio buffer: "+tc(s).join(", ")+", video buffer: "+tc(o).join(", ")+", ") this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}) this.trigger("error")}else{this.waitingOnRemove_=!0 this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:n,type:r,bytes:a})) var h=this.currentTime_()-1 this.logger_("On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to "+h) this.remove(0,h,(function(){i.logger_("On QUOTA_EXCEEDED_ERR, retrying append in 1s") i.waitingOnRemove_=!1 i.quotaExceededErrorRetryTimeout_=x.setTimeout((function(){i.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue") i.quotaExceededErrorRetryTimeout_=null i.processCallQueue_()}),1e3)}),!0)}} i.handleAppendError_=function(e,t){var i=e.segmentInfo,n=e.type,r=e.bytes if(t)if(22!==t.code){this.logger_("Received non QUOTA_EXCEEDED_ERR on append",t) this.error(n+" append of "+r.length+"b failed for segment #"+i.mediaIndex+" in playlist "+i.playlist.id) this.trigger("appenderror")}else this.handleQuotaExceededError_({segmentInfo:i,type:n,bytes:r})} i.appendToSourceBuffer_=function(e){var t=e.segmentInfo,i=e.type,n=e.initSegment,r=e.data,a=e.bytes if(!a){var s=[r],o=r.byteLength if(n){s.unshift(n) o+=n.byteLength}a=function(e){var t,i=0 if(e.bytes){t=new Uint8Array(e.bytes) e.segments.forEach((function(e){t.set(e,i) i+=e.byteLength}))}return t}({bytes:o,segments:s})}this.sourceUpdater_.appendBuffer({segmentInfo:t,type:i,bytes:a},this.handleAppendError_.bind(this,{segmentInfo:t,type:i,bytes:a}))} i.handleSegmentTimingInfo_=function(e,t,i){if(this.pendingSegment_&&t===this.pendingSegment_.requestId){var n=this.pendingSegment_.segment,r=e+"TimingInfo" n[r]||(n[r]={}) n[r].transmuxerPrependedSeconds=i.prependedContentDuration||0 n[r].transmuxedPresentationStart=i.start.presentation n[r].transmuxedDecodeStart=i.start.decode n[r].transmuxedPresentationEnd=i.end.presentation n[r].transmuxedDecodeEnd=i.end.decode n[r].baseMediaDecodeTime=i.baseMediaDecodeTime}} i.appendData_=function(e,t){var i=t.type,n=t.data if(n&&n.byteLength&&("audio"!==i||!this.audioDisabled_)){var r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null}) this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n})}} i.loadSegment_=function(e){var t=this this.state="WAITING" this.pendingSegment_=e this.trimBackBuffer_(e) "number"==typeof e.timestampOffset&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}) this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):this.loadQueue_.push((function(){var i=R({},e,{forceTimestampOffset:!0}) R(e,t.generateSegmentInfo_(i)) t.isPendingTimestampOffset_=!1 t.updateTransmuxerAndRequestSegment_(e)}))} i.updateTransmuxerAndRequestSegment_=function(e){var t=this if(this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)){this.gopBuffer_.length=0 e.gopsToAlignWith=[] this.timeMapping_=0 this.transmuxer_.postMessage({action:"reset"}) this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset})}var i=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),r=null!==this.mediaIndex,a=e.timeline!==this.currentTimeline_&&e.timeline>0,s=n||r&&a this.logger_("Requesting "+Qd(e)) if(i.map&&!i.map.bytes){this.logger_("going to request init segment.") this.appendInitSegment_={video:!0,audio:!0}}e.abortRequests=Dd({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:i,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:s,endedTimelineFn:function(){t.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:function(i){var n=i.message,r=i.level,a=i.stream t.logger_(Qd(e)+" logged from transmuxer stream "+a+" as a "+r+": "+n)}})} i.trimBackBuffer_=function(e){var t=function(e,t,i){var n=t-ad.BACK_BUFFER_LENGTH e.length&&(n=Math.max(n,e.start(0))) var r=t-i return Math.min(r,n)}(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10) t>0&&this.remove(0,t)} i.createSimplifiedSegmentObj_=function(e){var t=e.segment,i=e.part,n={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part},r=e.playlist.segments[e.mediaIndex-1] r&&r.timeline===t.timeline&&(r.videoTimingInfo?n.baseStartTime=r.videoTimingInfo.transmuxedDecodeEnd:r.audioTimingInfo&&(n.baseStartTime=r.audioTimingInfo.transmuxedDecodeEnd)) if(t.key){var a=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]) n.key=this.segmentKey(t.key) n.key.iv=a}t.map&&(n.map=this.initSegmentForMap(t.map)) return n} i.saveTransferStats_=function(e){this.mediaRequests+=1 if(e){this.mediaBytesTransferred+=e.bytesReceived this.mediaTransferDuration+=e.roundTripTime}} i.saveBandwidthRelatedStats_=function(e,t){this.pendingSegment_.byteLength=t.bytesReceived if(e=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,i.gopInfo,this.safeAppend_)) this.state="APPENDING" this.trigger("appending") this.waitForAppendsToComplete_(n)}}} i.setTimeMapping_=function(e){var t=this.syncController_.mappingForTimeline(e) null!==t&&(this.timeMapping_=t)} i.updateMediaSecondsLoaded_=function(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration} i.shouldUpdateTransmuxerTimestampOffset_=function(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())} i.trueSegmentStart_=function(e){var t=e.currentStart,i=e.playlist,n=e.mediaIndex,r=e.firstVideoFrameTimeForData,a=e.currentVideoTimestampOffset,s=e.useVideoTimingInfo,o=e.videoTimingInfo,u=e.audioTimingInfo if(void 0!==t)return t if(!s)return u.start var l=i.segments[n-1] return 0!==n&&l&&void 0!==l.start&&l.end===r+a?o.start:r} i.waitForAppendsToComplete_=function(e){var t=this.getCurrentMediaInfo_(e) if(t){var i=t.hasAudio,n=t.hasVideo,r=t.isMuxed,a="main"===this.loaderType_&&n,s=!this.audioDisabled_&&i&&!r e.waitingOnAppends=0 if(e.hasAppendedData_){a&&e.waitingOnAppends++ s&&e.waitingOnAppends++ a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)) s&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}else{e.timingInfo||"number"!=typeof e.timestampOffset||(this.isPendingTimestampOffset_=!0) e.timingInfo={start:0} e.waitingOnAppends++ if(!this.isPendingTimestampOffset_){this.updateSourceBufferTimestampOffset_(e) this.processMetadataQueue_()}this.checkAppendsDone_(e)}}else{this.error({message:"No starting media returned, likely due to an unsupported media format.",blacklistDuration:1/0}) this.trigger("error")}} i.checkAppendsDone_=function(e){if(!this.checkForAbort_(e.requestId)){e.waitingOnAppends-- 0===e.waitingOnAppends&&this.handleAppendsDone_()}} i.checkForIllegalMediaSwitch=function(e){var t=function(e,t,i){return"main"===e&&t&&i?i.hasAudio||i.hasVideo?t.hasVideo&&!i.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!t.hasVideo&&i.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null}(this.loaderType_,this.getCurrentMediaInfo_(),e) if(t){this.error({message:t,blacklistDuration:1/0}) this.trigger("error") return!0}return!1} i.updateSourceBufferTimestampOffset_=function(e){if(null!==e.timestampOffset&&"number"==typeof e.timingInfo.start&&!e.changedTimestampOffset&&"main"===this.loaderType_){var t=!1 e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}) e.changedTimestampOffset=!0 if(e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()){this.sourceUpdater_.videoTimestampOffset(e.timestampOffset) t=!0}if(e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()){this.sourceUpdater_.audioTimestampOffset(e.timestampOffset) t=!0}t&&this.trigger("timestampoffset")}} i.getSegmentStartTimeForTimestampOffsetCalculation_=function(e){var t=e.videoTimingInfo,i=e.audioTimingInfo,n=e.timingInfo return this.useDtsForTimestampOffset_?t&&"number"==typeof t.transmuxedDecodeStart?t.transmuxedDecodeStart:i&&"number"==typeof i.transmuxedDecodeStart?i.transmuxedDecodeStart:n.start:n.start} i.updateTimingInfoEnd_=function(e){e.timingInfo=e.timingInfo||{} var t=this.getMediaInfo_(),i="main"===this.loaderType_&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo i&&(e.timingInfo.end="number"==typeof i.end?i.end:i.start+e.duration)} i.handleAppendsDone_=function(){this.pendingSegment_&&this.trigger("appendsdone") if(this.pendingSegment_){var e=this.pendingSegment_ this.updateTimingInfoEnd_(e) this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:"main"===this.loaderType_}) var t=eh(e,this.sourceType_) t&&("warn"===t.severity?ql.log.warn(t.message):this.logger_(t.message)) this.recordThroughput_(e) this.pendingSegment_=null this.state="READY" if(e.isSyncRequest){this.trigger("syncinfoupdate") if(!e.hasAppendedData_){this.logger_("Throwing away un-appended sync request "+Qd(e)) return}}this.logger_("Appended "+Qd(e)) this.addSegmentMetadataCue_(e) this.fetchAtBuffer_=!0 if(this.currentTimeline_!==e.timeline){this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}) "main"!==this.loaderType_||this.audioDisabled_||this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})}this.currentTimeline_=e.timeline this.trigger("syncinfoupdate") var i=e.segment,n=e.part,r=i.end&&this.currentTime_()-i.end>3*e.playlist.targetDuration,a=n&&n.end&&this.currentTime_()-n.end>3*e.playlist.partTargetDuration if(r||a){this.logger_("bad "+(r?"segment":"part")+" "+Qd(e)) this.resetEverything()}else{null!==this.mediaIndex&&this.trigger("bandwidthupdate") this.trigger("progress") this.mediaIndex=e.mediaIndex this.partIndex=e.partIndex this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream() this.trigger("appended") e.hasAppendedData_&&this.mediaAppends++ this.paused()||this.monitorBuffer_()}}else{this.state="READY" this.paused()||this.monitorBuffer_()}} i.recordThroughput_=function(e){if(e.duration=e.playlist.segments.length){e=null break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e} i.stopForError=function(e){this.error(e) this.state="READY" this.pause() this.trigger("error")} i.segmentRequestFinished_=function(e,t,i){var n=this if(this.subtitlesTrack_){this.saveTransferStats_(t.stats) if(this.pendingSegment_)if(e){e.code===Td&&this.handleTimeout_() e.code===kd?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1 this.stopForError(e)}else{var r=this.pendingSegment_ this.saveBandwidthRelatedStats_(r.duration,t.stats) this.state="APPENDING" this.trigger("appending") var a=r.segment a.map&&(a.map.bytes=t.map.bytes) r.bytes=t.bytes if("function"!=typeof x.WebVTT&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s,o=function(){n.subtitlesTrack_.tech_.off("vttjsloaded",s) n.stopForError({message:"Error loading vtt.js"})} s=function(){n.subtitlesTrack_.tech_.off("vttjserror",o) n.segmentRequestFinished_(e,t,i)} this.state="WAITING_ON_VTTJS" this.subtitlesTrack_.tech_.one("vttjsloaded",s) this.subtitlesTrack_.tech_.one("vttjserror",o)}else{a.requested=!0 try{this.parseVTTCues_(r)}catch(e){this.stopForError({message:e.message}) return}this.updateTimeMapping_(r,this.syncController_.timelines[r.timeline],this.playlist_) r.cues.length?r.timingInfo={start:r.cues[0].startTime,end:r.cues[r.cues.length-1].endTime}:r.timingInfo={start:r.startOfSegment,end:r.startOfSegment+r.duration} if(r.isSyncRequest){this.trigger("syncinfoupdate") this.pendingSegment_=null this.state="READY"}else{r.byteLength=r.bytes.byteLength this.mediaSecondsLoaded+=a.duration r.cues.forEach((function(e){n.subtitlesTrack_.addCue(n.featuresNativeTextTracks_?new x.VTTCue(e.startTime,e.endTime,e.text):e)})) !function(e){var t=e.cues if(t)for(var i=0;i1&&n.push(t[a]) n.length&&n.forEach((function(t){return e.removeCue(t)}))}}(this.subtitlesTrack_) this.handleAppendsDone_()}}}else{this.state="READY" this.mediaRequestsAborted+=1}}else this.state="READY"} i.handleData_=function(){} i.updateTimingInfoEnd_=function(){} i.parseVTTCues_=function(e){var t,i=!1 if("function"==typeof x.TextDecoder)t=new x.TextDecoder("utf8") else{t=x.WebVTT.StringDecoder() i=!0}var n=new x.WebVTT.Parser(x,x.vttjs,t) e.cues=[] e.timestampmap={MPEGTS:0,LOCAL:0} n.oncue=e.cues.push.bind(e.cues) n.ontimestampmap=function(t){e.timestampmap=t} n.onparsingerror=function(e){ql.log.warn("Error encountered when parsing cues: "+e.message)} if(e.segment.map){var r=e.segment.map.bytes i&&(r=Sh(r)) n.parse(r)}var a=e.bytes i&&(a=Sh(a)) n.parse(a) n.flush()} i.updateTimeMapping_=function(e,t,i){var n=e.segment if(t)if(e.cues.length){var r=e.timestampmap,a=r.MPEGTS/wr-r.LOCAL+t.mapping e.cues.forEach((function(e){e.startTime+=a e.endTime+=a})) if(!i.syncInfo){var s=e.cues[0].startTime,o=e.cues[e.cues.length-1].startTime i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(s,o-n.duration)}}}else n.empty=!0} return t}(th),wh=function(e,t){for(var i=e.cues,n=0;n=r.adStartTime&&t<=r.adEndTime)return r}return null},Ih=[{name:"VOD",run:function(e,t,i,n,r){if(i!==1/0){return{time:0,segmentIndex:0,partIndex:null}}return null}},{name:"ProgramDateTime",run:function(e,t,i,n,r){if(!Object.keys(e.timelineToDatetimeMappings).length)return null var a=null,s=null,o=sc(t) r=r||0 for(var u=0;u