usePlayback
Control playback, loading state, and playback speed for the current scoped Video instance.
usePlayback() exposes player-scoped transport state and actions.
Use this hook inside Video children, or inside a shared VideoPlayer that contains one Video. The player scope is resolved
automatically.
Signature
const playback = usePlayback();It returns:
pausedloadingendedhasInteractedplaybackRateplay()pause()togglePlay()setPlaybackRate(rate)pauseOthers()
Example
import {Video, VideoPlayer, usePlayback} from "@rixl/media-react";
function CustomPlaybackControls() {
const {paused, playbackRate, togglePlay, setPlaybackRate, pauseOthers} = usePlayback();
return (
<div className="flex items-center gap-3">
<button type="button" onClick={() => void togglePlay()}>
{paused ? "Play" : "Pause"}
</button>
<button type="button" onClick={() => setPlaybackRate(1)}>
1x
</button>
<button type="button" onClick={() => setPlaybackRate(1.5)}>
1.5x
</button>
<button type="button" onClick={() => pauseOthers()}>
Pause others
</button>
<span>{playbackRate.toFixed(2)}x</span>
</div>
);
}
function CustomPlayer() {
return (
<VideoPlayer>
<CustomPlaybackControls />
<Video id="YOUR_VIDEO_ID" theme="hideUI" style={{display: "block", aspectRatio: "16 / 9"}} />
</VideoPlayer>
);
}Notes
play()andtogglePlay()return promises because browser media playback can fail.- Playback rate is player-scoped and clamped by the SDK.
pauseOthers()is player-relative: it pauses every other mounted player without pausing the current one.- Use this hook for transport controls. Use
usePlayerProgress()for timeline reads and seeking.