useVideo
About
A comprehensive React hook for video control and state management. This hook provides a ref to attach to video elements, reactive state tracking, and a complete set of video control methods.
Examples
Basic video player
Advanced video player with seek controls
Video playlist with multiple videos
Arguments
The useVideo
hook takes no arguments.
Return Value
Returns an array with three elements:
VideoState
Property | Type | Description |
---|---|---|
currentTime | number | Current playback time in seconds |
duration | number | Total duration of the video in seconds |
isPaused | boolean | Whether the video is currently paused |
isMuted | boolean | Whether the video is currently muted |
volume | number | Current volume level (0.0 to 1.0) |
VideoControls
Method | Type | Description |
---|---|---|
play | () => void | Start playing the video |
pause | () => void | Pause the video |
toggleMute | () => void | Toggle mute state |
setVolume | (volume: number) => void | Set volume level (0.0 to 1.0) |
setCurrentTime | (time: number) => void | Set current playback time in seconds |
fastForward | (seconds: number) => void | Fast forward by specified seconds |
rewind | (seconds: number) => void | Rewind by specified seconds |
toggleFullScreen | () => void | Toggle fullscreen mode |
VideoRef
The first element in the return array is a React ref that should be attached to the video element you want to control. This ref provides access to the underlying HTMLVideoElement.