import { useEffect, useState } from 'react'; import { getPlayerDuration, getPlayerTime, subscribePlayerTime } from './player-time'; /** * Position + duration, straight off the engine's per-frame feed. * * A scrubber genuinely wants every frame, so — unlike the lyrics — this does re-render at 60fps. Keep it * in the smallest component that draws the bar: whatever calls this hook repaints with it. */ export const usePlayerClock = () => { const [clock, setClock] = useState(() => ({ position: getPlayerTime(), duration: getPlayerDuration() })); useEffect(() => subscribePlayerTime((position, duration) => setClock({ position, duration })), []); return clock; };