react-datocms icon indicating copy to clipboard operation
react-datocms copied to clipboard

More clearly indicate that `muxPlaybackId` is required?

Open arcataroger opened this issue 3 months ago • 2 comments

When passing a data object to the VideoPlayer, muxPlaybackId (or playbackId) is required, but not indicated as such in the type:

export type Video = {
  /** Title attribute (`title`) for the video */
  title?: Possibly<string>;
  /** The height of the video */
  height?: Possibly<number>;
  /** The width of the video */
  width?: Possibly<number>;
  /** The MUX playbaack ID */
  muxPlaybackId?: Possibly<string>;
  /** The MUX playbaack ID */
  playbackId?: Possibly<string>;
  /** A data: URI containing a blurhash for the video  */
  blurUpThumb?: Possibly<string>;
  /** Other data can be passed, but they have no effect on rendering the player */
  // biome-ignore lint/suspicious/noExplicitAny: we intentionally want to allow to add any other value to this video object
  [k: string]: any;
};

As such, it causes situations where a missing ID can cause the player to appear as though it has a loading issue (the bottom player in this case), showing a loading spinner forever:

Image

Should we do any of the following:

  • Mark at least one of the playback ID parameters as required in the TypeScript
  • Optionally also accept, and check for, streamingUrl as a fallback and extract the ID from there
  • If no ID is present in either the param or a fallback, how a visual error (like a div overlay) instead of trying to actually load the video

arcataroger avatar Sep 12 '25 14:09 arcataroger

Mark at least one of the playback ID parameters as required in the TypeScript

Let's go with this approach @arcataroger

stefanoverna avatar Sep 29 '25 11:09 stefanoverna

@stefanoverna PR here for now: https://github.com/datocms/react-datocms/pull/115

Mux upstream released mux-player@v3 not too long ago (we're still on v2). Maybe for the next major release, we can hard remove one of the redundant props (muxPlaybackId vs playbackId)?

arcataroger avatar Sep 29 '25 19:09 arcataroger