Skip to content

fix: Mux - conditionally render MuxPlayer only when data is ready []#10710

Open
Renzo Delfino (R-Delfino95) wants to merge 1 commit intocontentful:masterfrom
R-Delfino95:fix/re-render-player
Open

fix: Mux - conditionally render MuxPlayer only when data is ready []#10710
Renzo Delfino (R-Delfino95) wants to merge 1 commit intocontentful:masterfrom
R-Delfino95:fix/re-render-player

Conversation

@R-Delfino95
Copy link
Contributor

Purpose

The MuxPlayer was always mounted in the DOM and hidden via display: none, meaning the player component would initialize and attempt to load resources even when the required data wasn't available yet. This caused unnecessary resource usage and a visible flicker on signed playback assets where the player would briefly appear then hide again while tokens were loading.

Approach

Part of the DRM feature (#10376) was to fix the re-render issue. We can now safely conditionally render MuxPlayer instead of keeping it mounted at all times.

Replaced CSS-based hiding with conditional rendering ({showPlayer && <section>...</section>}) so MuxPlayer only mounts when all required data is present.

Extracted the readiness logic into an isPlayerReady() method that gates on:

  • Public playback: asset is ready and playbackId exists
  • Signed playback: isUsingSigned(), tokens finished loading, and playbackToken is set
    Also fixed the signed playback flicker by batching isTokenLoading: false together with the token values into a single setState call in setSignedPlayback. Previously, isTokenLoading was set to false inside fetchSignedTokens before the tokens were written to state, causing an intermediate render where the player appeared ready but had no tokens yet.

Testing steps

  1. Open a Contentful entry with a public Mux asset — player should appear once the asset is ready, no flicker
  2. Open an entry with a signed Mux asset — "Waiting for asset to be playable" should show while tokens load, then player appears once (no flicker)
  3. Open an entry with a DRM asset — player should not render, only the DRM warning note
  4. Open an entry with no asset — uploader dropzone should show normally

Breaking Changes

None.

Dependencies and/or References

None.

Deployment

No extra deployment steps required.

@R-Delfino95 Renzo Delfino (R-Delfino95) marked this pull request as ready for review March 23, 2026 18:25
@R-Delfino95 Renzo Delfino (R-Delfino95) requested a review from a team as a code owner March 23, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant