import { useCallback, useEffect, useRef } from "react"; import { useProgressBar } from "@/hooks/useProgressBar"; import { usePlayerStore } from "@/stores/player/store"; export function ProgressBar() { const { duration, time, buffered } = usePlayerStore((s) => s.progress); const display = usePlayerStore((s) => s.display); const setDraggingTime = usePlayerStore((s) => s.setDraggingTime); const setSeeking = usePlayerStore((s) => s.setSeeking); const { isSeeking } = usePlayerStore((s) => s.interface); const commitTime = useCallback( (percentage) => { display?.setTime(percentage * duration); }, [duration, display] ); const ref = useRef(null); const { dragging, dragPercentage, dragMouseDown } = useProgressBar( ref, commitTime ); useEffect(() => { setSeeking(dragging); }, [setSeeking, dragging]); useEffect(() => { setDraggingTime((dragPercentage / 100) * duration); }, [setDraggingTime, duration, dragPercentage]); return (
{/* Pre-loaded content bar */}
{/* Actual progress bar */}
); }