useActiveCue
Tracks the active subtitle cue from a video element's
playback time. Binds to the element value (callback-ref) so the listener
attaches exactly when it mounts, and drives updates from a requestAnimationFrame
loop while playing — timeupdate alone fires sparsely and can stall, which
froze the subtitle on a cue. setActiveIdx bails out when unchanged, so the
rAF loop costs nothing until the cue actually changes.
Functions¶
useActiveCue()¶
Defined in: src/features/player/hooks/useActiveCue.ts:20
Returns the index of the cue under the video's current time (or null).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
video |
| HTMLVideoElement | null |
The video element (from a callback ref). |
cues |
Cue[] |
The parsed cues. |
Returns¶
number | null
The active cue index, or null.