The
useStore hook is from
zustand,
and inherits all of the documentation for Zustand stores.Features
- Flexible interaction with the player state store
- Based on Zustand’s
useStorehooks
Anatomy
Import the components and piece the parts together.State
TheuseMediaContext hook returns a Zustand store, which contains the
PlayerState.
aria
The ARIA text for the current state, providing accessible descriptions for media
control actions.
buffered
Current buffered end time for the media in seconds.
bufferedPercent
Current buffered percent of the media, from 0 to 1.
canPlay
Indicates if the media has loaded sufficiently and can be played.
currentSource
The current source that is playing.
currentUrl
The final playback URL for the media that is playing, after any redirects.
duration
Current total duration of the media in seconds.
error
If the media has experienced an error, this property provides details.
errorCount
The number of consecutive errors that have occurred during the media playback,
without resolution.
stalled
Indicates if the media playback is currently stalled.
fullscreen
Indicates if the media is being played in fullscreen mode.
hasPlayed
Indicates if the media has been played yet.
hidden
Indicates if all controls are currently hidden.
live
Indicates if the content is live media.
loading
Indicates if the media is currently loading.
mounted
Indicates if the video element is mounted on the DOM. This is used for
initialization logic.
playbackRate
The current playback rate for the media. Defaults to 1. constant means playing
WebRTC playback at a constant pace and not speeding up.
pictureInPicture
Indicates if the media is in picture in picture mode.
poster
The poster image URL for the media. Any thumbnails are automatically parsed from
the input Src[].