Core
Player
This is the top-most component in the library used to group media elements and control the flow of media state.
See the following sections for more information:
- The loading guide covers how to handle loading various media resources.
- The events guide covers the basics on how to listen and track updates.
- The state management guide covers how to read, update, and subscribe to state changes.
- The API pages cover how to interact with various player APIs and hooks.
API Reference
Section titled API ReferenceHTMLAttributes
Ref<MediaPlayerInstance>
All media components exist inside the <MediaPlayer>
component. This component's main
responsibilities are to manage media state updates, dispatch media events, handle media
requests, and expose media state through HTML attributes and CSS properties for styling
purposes.
import { MediaPlayer, type MediaPlayerProps } from "@vidstack/react";
<MediaPlayer src="...">
<MediaProvider />
</MediaPlayer>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| PlayerSrc | undefined |
| string | undefined |
| boolean | false |
| ReactNode | null |
| string | '' |
| MediaImage[] | null |
| boolean | false |
| boolean | false |
| number | 0 |
| number | 0 |
| boolean | false |
| number | 2000 |
| mixed | null |
| mixed | null |
| number | 0 |
| number | -1 |
| string | 'landscape' |
| GoogleCastOptions | {} |
| boolean | false |
| boolean | 'false' |
| MediaKeyShortcuts | MEDIA_KEY_SHORTCUTS |
| MediaKeyTarget | `player` |
| number | 10 |
| MediaLoadingStrategy | 'visible' |
| LogLevel | __DEV__ ? 'warn' : 'silent' |
| boolean | false |
| number | 60 |
| boolean | false |
| boolean | true |
| number | 1 |
| boolean | false |
| boolean | false |
| string | '' |
| MediaPosterLoadingStrategy | 'visible' |
| boolean | false |
| string | 'metadata' |
| string | null |
| MediaStreamType | 'unknown' |
| string | '' |
| MediaViewType | 'unknown' |
| number | 1 |
State
Section titled Stateimport { MediaPlayer, MediaPlayerInstance } from "@vidstack/react"
const ref = useRef<MediaPlayerInstance>(null),
{ /* state props */ } = useStore(MediaPlayerInstance, ref);
<MediaPlayer ref={ref}>
Prop | Type | Default |
---|---|---|
| string | '' |
| object | null |
| number | null |
| object | null |
| object | [] |
| boolean | false |
| object | null |
| boolean | false |
| object | new TimeRange() |
| number | undefined |
| number | undefined |
| number | undefined |
| boolean | false |
| boolean | false |
| boolean | false |
| boolean | false |
| boolean | false |
| boolean | canOrientScreen() |
| boolean | false |
| boolean | false |
| boolean | undefined |
| boolean | false |
| boolean | true |
| boolean | true |
| boolean | false |
| number | 0 |
| number | 0 |
| boolean | false |
| boolean | undefined |
| boolean | false |
| string | null |
| object | undefined |
| number | undefined |
| number | undefined |
| boolean | false |
| object | null |
| boolean | false |
| boolean | undefined |
| number | 0 |
| boolean | undefined |
| number | 0 |
| boolean | undefined |
| boolean | undefined |
| boolean | undefined |
| object | null |
| boolean | undefined |
| number | undefined |
| boolean | undefined |
| number | undefined |
| number | 10 |
| number | undefined |
| string | __DEV__ ? 'warn' : 'silent' |
| boolean | undefined |
| number | 0 |
| string | 'unknown' |
| number | 0 |
| number | 60 |
| boolean | false |
| boolean | undefined |
| string | 'landscape' |
| boolean | true |
| boolean | false |
| number | 1 |
| object | new TimeRange() |
| boolean | false |
| boolean | false |
| string | 'fine' |
| string | undefined |
| string | 'metadata' |
| object | [] |
| object | null |
| object | null |
| object | null |
| string | 'disconnected' |
| string | 'none' |
| object | new TimeRange() |
| number | undefined |
| number | undefined |
| number | undefined |
| boolean | false |
| object | { src: '', type: '' } |
| object | [] |
| boolean | false |
| string | undefined |
| object | null |
| object | [] |
| string | undefined |
| boolean | false |
| string | undefined |
| number | 1 |
| boolean | false |
| number | 0 |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
| function |
Instance
Section titled Instanceimport { MediaPlayer, type MediaPlayerInstance } from "@vidstack/react"
const ref = useRef<MediaPlayerInstance>(null);
useEffect(() => { /* Use props/methods here. */ }, [])
<MediaPlayer ref={ref}>
Prop | Type |
---|---|
| AudioTrackList |
| RequestQueue |
| ScreenOrientationController |
| AnyMediaProvider |
| VideoQualityList |
| MediaRemoteControl |
| MediaPlayerState |
| TextRenderers |
| TextTrackList |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether AirPlay is connected. |
| Autoplay has successfully started. |
| Autoplay has failed to start. |
| Media is not ready for playback or waiting for more data. |
| Whether AirPlay is available. |
| Fullscreen mode is available. |
| Whether Google Cast is available. |
| Media can now begin loading. |
| Picture-in-Picture mode is available. |
| Media is ready for playback. |
| Seeking operations are permitted. |
| Captions are available and visible. |
| Controls are visible. |
| Playback has ended. |
| Issue with media loading/playback. |
| Fullscreen mode is active. |
| Whether Google Cast is connected. |
| iOS controls are visible. |
| Specified load strategy. |
| Media is live stream. |
| Playback is at the live edge. |
| Media is set to replay on end. |
| Current media type (audio/video). |
| Whether volume is muted (0). |
| Current screen orientation (landscape/portrait). |
| Whether playback is paused. |
| Picture-in-picture mode is active. |
| Playback is active. |
| Media should play inline by default (iOS). |
| The user's pointer device type (coarse/fine). |
| The user is interacting with the time slider. |
| The remote playback type (airplay/google-cast). |
| The remote playback state (connecting/connected/disconnected). |
| User is seeking to a new playback position. |
| Media playback has started. |
| Current stream type. |
| Current view type (audio/video). |
| Media is waiting for more data to resume playback. |
| Whether player is being keyboard focused. |
| Whether player is being keyboard focused or hovered over. |