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";
import { MediaPlayer, type MediaPlayerProps } from "@vidstack/react";
<MediaPlayer src="...">
<MediaProvider />
</MediaPlayer>
<MediaPlayer src="...">
<MediaProvider />
</MediaPlayer>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| string | undefined |
| boolean | false |
| ReactNode | null |
| boolean | false |
| boolean | false |
| number | 2000 |
| mixed | null |
| number | 0 |
| ScreenOrientationLockType | 'landscape' |
| boolean | 'false' |
| MediaKeyShortcuts | MEDIA_KEY_SHORTCUTS |
| MediaKeyTarget | `player` |
| number | 10 |
| MediaLoadingStrategy | 'visible' |
| LogLevel | __DEV__ ? 'warn' : 'silent' |
| boolean | false |
| number | 30 |
| boolean | false |
| boolean | true |
| number | 1 |
| boolean | false |
| string | '' |
| boolean | false |
| string | 'metadata' |
| MediaSrc | '' |
| 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}>
import { MediaPlayer, MediaPlayerInstance } from "@vidstack/react"
const ref = useRef<MediaPlayerInstance>(null),
{ /* state props */ } = useStore(MediaPlayerInstance, ref);
<MediaPlayer ref={ref}>
Prop | Type | Default |
---|---|---|
| object | null |
| object | [] |
| boolean | false |
| boolean | false |
| object | null |
| boolean | false |
| object | new TimeRange() |
| number | undefined |
| number | undefined |
| boolean | false |
| boolean | false |
| boolean | canOrientScreen() |
| boolean | false |
| boolean | false |
| boolean | undefined |
| boolean | true |
| boolean | true |
| boolean | false |
| boolean | false |
| boolean | false |
| string | null |
| object | undefined |
| number | 0 |
| number | 0 |
| boolean | false |
| object | null |
| boolean | false |
| number | 0 |
| string | '' |
| string | 'unknown' |
| string | '' |
| string | 'unknown' |
| boolean | undefined |
| boolean | undefined |
| number | undefined |
| number | 10 |
| number | undefined |
| number | null |
| string | __DEV__ ? 'warn' : 'silent' |
| boolean | false |
| number | 0 |
| string | 'unknown' |
| number | 0 |
| number | 60 |
| boolean | false |
| string | 'landscape' |
| boolean | true |
| boolean | false |
| number | 1 |
| object | new TimeRange() |
| boolean | false |
| boolean | false |
| string | 'fine' |
| string | undefined |
| string | 'metadata' |
| string | '' |
| string | 'unknown' |
| string | '' |
| string | 'unknown' |
| object | [] |
| object | null |
| 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 |
| 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}>
import { 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 |
| MediaPlayerState |
| TextRenderers |
| TextTrackList |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
| method |
|