diff --git a/src/components/video-editor.tsx b/src/components/video-editor.tsx index f3f9349..ac07d99 100644 --- a/src/components/video-editor.tsx +++ b/src/components/video-editor.tsx @@ -31,17 +31,26 @@ export function VideoEditor() { if (!video) return; const handleTimeUpdate = () => { - if (video.currentTime > trimValues[1]) { - video.pause(); + // When the video plays past the end of the trim selection, loop back to the start + if (video.currentTime >= trimValues[1]) { + video.currentTime = trimValues[0]; + } + }; + + const handlePlay = () => { + // If the video is outside the trim range when play is clicked, jump to the start of the trim + if (video.currentTime < trimValues[0] || video.currentTime >= trimValues[1]) { video.currentTime = trimValues[0]; } }; video.addEventListener('timeupdate', handleTimeUpdate); + video.addEventListener('play', handlePlay); return () => { if (video) { video.removeEventListener('timeupdate', handleTimeUpdate); + video.removeEventListener('play', handlePlay); } }; }, [trimValues]);