import { formatDetailedTime } from './lib/timeUtils'; import logger from './lib/logger'; import VideoPlayer from '@/components/VideoPlayer'; import TimelineControls from '@/components/TimelineControls'; import EditingTools from '@/components/EditingTools'; import ClipSegments from '@/components/ClipSegments'; import MobilePlayPrompt from '@/components/IOSPlayPrompt'; import useVideoChapters from '@/hooks/useVideoChapters'; import { useEffect } from 'react'; const App = () => { const { videoRef, currentTime, duration, isPlaying, setIsPlaying, isMuted, trimStart, trimEnd, splitPoints, zoomLevel, clipSegments, selectedSegmentId, hasUnsavedChanges, historyPosition, history, handleTrimStartChange, handleTrimEndChange, handleZoomChange, handleMobileSafeSeek, handleSplit, handleReset, handleUndo, handleRedo, toggleMute, handleSegmentUpdate, handleChapterSave, handleSelectedSegmentChange, isMobile, videoInitialized, setVideoInitialized, } = useVideoChapters(); const handlePlay = () => { if (!videoRef.current) return; const video = videoRef.current; // If already playing, just pause the video if (isPlaying) { video.pause(); setIsPlaying(false); logger.debug('Video paused'); return; } // Start playing - no boundary checking, play through entire timeline video .play() .then(() => { setIsPlaying(true); setVideoInitialized(true); logger.debug('Continuous playback started from:', formatDetailedTime(video.currentTime)); }) .catch((err) => { console.error('Error playing video:', err); }); }; // Handle keyboard shortcuts useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { // Don't handle keyboard shortcuts if user is typing in an input field const target = event.target as HTMLElement; if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) { return; } switch (event.code) { case 'Space': event.preventDefault(); // Prevent default spacebar behavior (scrolling, button activation) handlePlay(); break; case 'ArrowLeft': event.preventDefault(); if (videoRef.current) { const newTime = Math.max(currentTime - 10, 0); handleMobileSafeSeek(newTime); logger.debug('Jumped backward 10 seconds to:', formatDetailedTime(newTime)); } break; case 'ArrowRight': event.preventDefault(); if (videoRef.current) { const newTime = Math.min(currentTime + 10, duration); handleMobileSafeSeek(newTime); logger.debug('Jumped forward 10 seconds to:', formatDetailedTime(newTime)); } break; } }; document.addEventListener('keydown', handleKeyDown); return () => { document.removeEventListener('keydown', handleKeyDown); }; }, [handlePlay, handleMobileSafeSeek, currentTime, duration, videoRef]); return (
{/* Video Player */} {/* Editing Tools */} 0} canRedo={historyPosition < history.length - 1} /> {/* Timeline Controls */} {/* Clip Segments */}
); }; export default App;