Skip to content

Commit

Permalink
fix: target-live-window unneeded sprout
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Dec 13, 2023
1 parent b4ae1b1 commit c35b93e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/vanilla-ts-esm/public/mux-player-theme-classic.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ <h1><a href="/">Elements</a></h1>

<mux-player
theme="classic"
stream-type="live:dvr"
stream-type="live"
target-live-window="Infinity"
playback-id="v69RSHhFelSm4701snP22dYz2jICy4E4FUyk02rW4gxRM"
title="My amazing video"
></mux-player>
Expand Down
3 changes: 2 additions & 1 deletion examples/vanilla-ts-esm/public/mux-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ <h1><a href="/">Elements</a></h1>
></mux-player>

<mux-player
stream-type="live:dvr"
stream-type="live"
target-live-window="Infinity"
playback-id="v69RSHhFelSm4701snP22dYz2jICy4E4FUyk02rW4gxRM"
title="My amazing video"
></mux-player>
Expand Down
11 changes: 9 additions & 2 deletions packages/mux-player/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,14 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {
// NOTE: For now, since we are continuing support of the deprecated stream types (namely, "dvr" types) and not advertising the
// new APIs such as `targetLiveWindow`/`target-live-window`, we will (presumpuously) update the `targetLiveWindow` based on the
// stream type (CJP).
this.targetLiveWindow = newValue === StreamTypes.LIVE ? 0 : Number.NaN;
if (newValue === StreamTypes.LIVE) {
// Don't override if the user has already set a value.
if (this.getAttribute(PlayerAttributes.TARGET_LIVE_WINDOW) == null) {
this.targetLiveWindow = 0;
}
} else {
this.targetLiveWindow = Number.NaN;
}
}
}
}
Expand Down Expand Up @@ -1382,7 +1389,7 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {

set targetLiveWindow(val: number | undefined) {
// don't cause an infinite loop and avoid change event dispatching
if (val == this.targetLiveWindow) return;
if (val == this.targetLiveWindow || (Number.isNaN(val) && Number.isNaN(this.targetLiveWindow))) return;

if (val == null) {
this.removeAttribute(PlayerAttributes.TARGET_LIVE_WINDOW);
Expand Down

0 comments on commit c35b93e

Please sign in to comment.