Hooks
useProgressBar
Low-level drag state for a raw HTMLVideoElement progress bar.
useProgressBar({video}) is a low-level helper for custom scrubber drag handling around a raw HTMLVideoElement.
Important
If you are building on top of a VideoPlayer scope, prefer usePlayerProgress() — it binds to the enclosing player scope and needs no arguments.
Signature
const progressBar = useProgressBar({video});It returns:
progressisDragginghandleDragStart(event)
Example
import {useRef} from "react";
import {useProgressBar} from "@rixl/media-react";
function NativeVideoProgress() {
const videoRef = useRef<HTMLVideoElement | null>(null);
const {progress, isDragging, handleDragStart} = useProgressBar({video: videoRef.current});
return (
<div className="space-y-3">
<video ref={videoRef} src="/example.mp4" className="w-full" />
<div role="presentation" className="h-2 rounded bg-gray-200" onMouseDown={handleDragStart} onTouchStart={handleDragStart}>
<div className="h-2 rounded bg-black" style={{width: `${progress * 100}%`}} />
</div>
<div>{isDragging ? "Dragging" : "Idle"}</div>
</div>
);
}Notes
- This hook does not return
duration,isPlaying, or other playback state. - Use it when you need the SDK's drag handling but you already control the raw media element yourself.
- The new Lit
Videowrapper does not expose a DOM ref; for a progress bar with it, useonRixlAnalyticsto observewatchevents, or use aVideoPlayerscope with a raw<video>element.