const { useRef, useEffect } = React; const VideoPlayer = ({ videoUrl, currentTime, onTimeUpdate, onDurationChange, setVideoRef }) => { const videoRef = useRef(null); useEffect(() => { if (setVideoRef) { setVideoRef(videoRef.current); } }, [setVideoRef]); useEffect(() => { // Sync video time if external currentTime changes significantly (scrubbing) // We use a threshold to avoid feedback loops if (videoRef.current && Math.abs(videoRef.current.currentTime - currentTime) > 0.5) { videoRef.current.currentTime = currentTime; } }, [currentTime]); return (
); }; window.VideoPlayer = VideoPlayer;