usePlayerProgress
Read timeline state and perform seeking without reaching for a DOM video ref.
usePlayerProgress() is the preferred public hook for custom timeline UI within a VideoPlayer scope.
Use this hook inside Video children, or inside a shared VideoPlayer that contains one Video. The player scope is resolved
automatically.
Signature
const progress = usePlayerProgress();It returns:
currentTimedurationprogressbufferedseekTo(seconds)seekBy(deltaSeconds)
progress and buffered are ratios from 0 to 1.
Example
import {Video, VideoPlayer, usePlayerProgress} from "@rixl/media-react";
function CustomProgressControls() {
const {currentTime, duration, progress, buffered, seekBy} = usePlayerProgress();
return (
<div className="space-y-2">
<div>{`${Math.round(currentTime)}s / ${Math.round(duration)}s`}</div>
<div>{`Played: ${Math.round(progress * 100)}% | Buffered: ${Math.round(buffered * 100)}%`}</div>
<button type="button" onClick={() => seekBy(10)}>
Seek +10s
</button>
</div>
);
}
function CustomPlayer() {
return (
<VideoPlayer>
<CustomProgressControls />
<Video id="YOUR_VIDEO_ID" theme="hideUI" style={{display: "block", aspectRatio: "16 / 9"}} />
</VideoPlayer>
);
}Notes
- This hook resolves the current player from scope.
- Before metadata is ready, timeline values can be
0. - Prefer this hook over
useProgressBarwhen you are building on top of a scope-aware player.