Skip to content

Commit

Permalink
fix: account for some dynamic changes to media-time-range (#859)
Browse files Browse the repository at this point in the history
(mostly relevant for DVR).
  • Loading branch information
cjpillsbury committed Mar 18, 2024
1 parent b625e22 commit bea8fca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/js/media-time-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ class MediaTimeRange extends MediaChromeRange {
this.updateBufferedBar();
}

if (attrName === MediaUIAttributes.MEDIA_DURATION) {
if (
attrName === MediaUIAttributes.MEDIA_DURATION ||
attrName === MediaUIAttributes.MEDIA_SEEKABLE
) {
this.mediaChaptersCues = this.#mediaChaptersCues;
this.updateBar();
}
Expand All @@ -445,7 +448,7 @@ class MediaTimeRange extends MediaChromeRange {
&& !this.mediaPaused
&& !this.mediaLoading
&& !this.mediaEnded
&& this.mediaDuration > 0
&& this.mediaSeekableEnd > 0
&& isElementVisible(this);
}

Expand Down Expand Up @@ -766,7 +769,7 @@ class MediaTimeRange extends MediaChromeRange {
return;
}

const duration = this.mediaDuration;
const duration = this.mediaSeekableEnd;
// If no duration we can't calculate which time to show
if (!duration) return;

Expand Down
3 changes: 2 additions & 1 deletion src/js/utils/range-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export class RangeAnimation {
// 1. Always allow increases.
// 2. Allow a relatively large decrease (user action or Safari jumping back :s).
const increase = start - this.#range.valueAsNumber;
if (increase > 0 || increase < -.03) {
const durationDelta = Math.abs(duration - this.duration);
if (increase > 0 || increase < -.03 || durationDelta >= 0.5) {
this.callback(start);
}

Expand Down

0 comments on commit bea8fca

Please sign in to comment.