The useStore hook is from zustand, and inherits all of the documentation for Zustand stores.


  • Flexible interaction with the player state store
  • Based on Zustand’s useStore hooks


Import the components and piece the parts together.

import * as Player from "@livepeer/react/player";
import { useMediaContext, useStore } from "@livepeer/react/player";

export default () => (
    {/** The `useMediaContext` hook can be used in any component,
    as long as it's inside the Player.Root React Context provider */}
    <CustomComponent />

function CustomComponent({ __scopeMedia }: MediaScopedProps) {
  const context = useMediaContext("CustomComponent", __scopeMedia);

  const { currentSource } = useStore(, ({ currentSource }) => ({

  return currentSource?.type ?? null;


The useMediaContext hook returns a Zustand store, which contains the PlayerState.


The ARIA text for the current state, providing accessible descriptions for media control actions.

type AriaText = {
  progress: string;
  pictureInPicture: string;
  fullscreen: string;
  playPause: string;
  clip: string | null;
  time: string;

aria: AriaText;


Current buffered end time for the media in seconds.

buffered: number;


Current buffered percent of the media, from 0 to 1.

bufferedPercent: number;


Indicates if the media has loaded sufficiently and can be played.


The current source that is playing.

type Src =
  | AudioSrc
  | HlsSrc
  | VideoSrc
  | Base64Src
  | WebRTCSrc
  | ImageSrc
  | VideoTextTrackSrc;

currentSource: Src | null;


The final playback URL for the media that is playing, after any redirects.

currentUrl: string | null;


Current total duration of the media in seconds.

duration: number;


If the media has experienced an error, this property provides details.

type PlaybackError = {
  type: "offline" | "access-control" | "fallback" | "permissions" | "unknown";
  message: string;

error: PlaybackError | null;


The number of consecutive errors that have occurred during the media playback, without resolution.

errorCount: number;


Indicates if the media playback is currently stalled.


Indicates if the media is being played in fullscreen mode.


Indicates if the media has been played yet.


Indicates if all controls are currently hidden.


Indicates if the content is live media.


Indicates if the media is currently loading.


Indicates if the video element is mounted on the DOM. This is used for initialization logic.


The current playback rate for the media. Defaults to 1. constant means playing WebRTC playback at a constant pace and not speeding up.

type PlaybackRate = number | "constant";

playbackRate: PlaybackRate;


Indicates if the media is in picture in picture mode.


The poster image URL for the media. Any thumbnails are automatically parsed from the input Src[].

poster: string | null;


Current progress of the media in seconds.

progress: number;


Indicates if the media is currently trying to play or paused.


The sorted sources that were passed into the Player. These are the playback sources which will be tried, in order (e.g. WebRTC with a fallback to HLS).

sortedSources: Src[] | string | null;


Current volume of the media. 0 if it is muted.

volume: number;


Indicates if the media is currently waiting for data.


The quality of the video playback.

type VideoQuality =
  | "1080p"
  | "720p"
  | "480p"
  | "360p"
  | "240p"
  | "144p"
  | "auto";

videoQuality: VideoQuality;


Indicates if the media playback has ended.


An object containing functions to manipulate the media’s state, such as toggling play/pause, seeking, and changing volume.

These functions are internal - please refer to the UI Kit source code before interacting with these functions.

__controlsFunctions: {
  setHidden: (hidden: boolean) => void;
  onCanPlay: () => void;
  onDurationChange: (duration: number) => void;
  onEnded: () => void;
  onError: (error: Error | null) => void;
  onFinalUrl: (url: string | null) => void;
  onLoading: () => void;
  onPause: () => void;
  onPlay: () => void;
  onProgress: (time: number) => void;
  onStalled: () => void;
  onWaiting: () => void;
  requestClip: () => void;
  requestMeasure: () => void;
  requestSeek: (time: number) => void;
  requestSeekBack: (difference?: number) => void;
  requestSeekDiff: (difference: number) => void;
  requestSeekForward: (difference?: number) => void;
  requestToggleFullscreen: () => void;
  requestToggleMute: () => void;
  requestTogglePictureInPicture: () => void;
  requestVolume: (volume: number) => void;
  setAutohide: (autohide: number) => void;
  setFullscreen: (fullscreen: boolean) => void;
  setHlsConfig: (hlsConfig: any) => void;
  setLive: (live: boolean) => void;
  setMounted: () => void;
  setPictureInPicture: (pictureInPicture: boolean) => void;
  setPlaybackRate: (rate: number | string) => void;
  setPoster: (poster: string | null) => void;
  setVideoQuality: (videoQuality: VideoQuality) => void;
  setSize: (size: Partial<MediaSizing>) => void;
  setVolume: (volume: number) => void;
  setWebsocketMetadata: (metadata: Metadata) => void;
  togglePlay: (force?: boolean) => void;
  updateBuffered: (buffered: number) => void;
  updateLastInteraction: () => void;
  updatePlaybackOffsetMs: (offset: number) => void;


Information about the device’s capabilities and support for media features. This is an internal object used by Player/Broadcast, but can be used for detecting device capabilities.

type DeviceInformation = {
  version: string;
  isMobile: boolean;
  isIos: boolean;
  isAndroid: boolean;
  userAgent: string;
  screenWidth: number | null;
  /** If the media supports changing the volume */
  isVolumeChangeSupported: boolean;
  /** If the media supports PiP */
  isPictureInPictureSupported: boolean;
  /** If the media supports fullscreen */
  isFullscreenSupported: boolean;
  /** If the media supports HLS playback */
  isHlsSupported: boolean;
  /** If the media supports WebRTC */
  isWebRTCSupported: boolean;

__device: DeviceInformation;


Represents the state of various media control actions, such as play/pause and fullscreen changes. This is an internal object used by Player/Broadcast.

__controls: ControlsState;


The initial properties passed into the media component. This is an internal object used by Player/Broadcast.

__initialProps: InitialProps;


Metadata related to the media, such as buffer window and frame rate. This is an internal object used by Player/Broadcast.

type Metadata = {
  bframes?: number;
  bufferWindow?: number;

__metadata: Metadata | null;