Skip to content

Commit

Permalink
fix(HLS): getPlayheadTimeAsDate() differs from X-EXT-PROGRAM-DATE-TIME (
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jan 9, 2024
1 parent 4022788 commit 776b69d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,22 @@ shaka.hls.HlsParser = class {
this.presentationTimeline_.setSegmentAvailabilityDuration(
segmentAvailabilityDuration);
}

if (!this.presentationTimeline_.isStartTimeLocked()) {
const streamInfos = Array.from(this.uriToStreamInfosMap_.values());
const activeStreamInfos =
streamInfos.filter((s) => s.stream.segmentIndex);
for (const streamInfo of activeStreamInfos) {
if (streamInfo.type != 'audio' && streamInfo.type != 'video') {
continue;
}
const firstReference = streamInfo.stream.segmentIndex.get(0);
if (firstReference && firstReference.syncTime) {
const syncTime = firstReference.syncTime;
this.presentationTimeline_.setPresentationStartTime(syncTime);
}
}
}
} else {
// Use the minimum duration as the presentation duration.
this.presentationTimeline_.setDuration(this.getMinDuration_());
Expand Down
11 changes: 11 additions & 0 deletions lib/media/presentation_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ shaka.media.PresentationTimeline = class {
}


/**
* Returns if the presentation timeline's start time is locked.
*
* @return {boolean}
* @export
*/
isStartTimeLocked() {
return this.startTimeLocked_;
}


/**
* Gives PresentationTimeline a Stream's minimum segment start time.
*
Expand Down

0 comments on commit 776b69d

Please sign in to comment.