interface MediaPlayerProps

Passed to MediaPlayer by GlobalPlayer, which wires the callbacks and the handles to PlayerContext, and by the file previews, which pass only the media.

Properties

src: string
kind: "audio" | "video"
optional
poster: string

Shown before a video plays.

optional
autoplay: boolean
optional
startTime: number

In seconds. Read on mount only: later seeks go through seekRef.

optional
onPlayStateChange: (playing: boolean) => void
optional
onTimeUpdate: (
time: number,
duration: number
) => void
optional
onEnded: () => void

Called at the media's end, where GlobalPlayer plays the next item.

optional
onError: () => void

Called when the media fails to load or decode, where a stream's URL is re-resolved.

Where an audio file's waveform comes from. Without it, as for a stream whose bytes another site serves, audio seeks on a plain bar.

optional
seekRef: { current: ((t: number) => void) | null; }

Receives its seek handle while mounted, for PlayerContext's seekTo.

optional
toggleRef: { current: (() => void) | null; }

Receives its play/pause handle while mounted, for togglePlay.

Usage

import { type MediaPlayerProps } from "src/components/player/MediaPlayer.tsx";