diff --git a/public/wallpaper.png b/public/wallpaper.png new file mode 100644 index 0000000..0e51d83 Binary files /dev/null and b/public/wallpaper.png differ diff --git a/src/components/VideoEditor.tsx b/src/components/VideoEditor.tsx index 13189e0..c6a887e 100644 --- a/src/components/VideoEditor.tsx +++ b/src/components/VideoEditor.tsx @@ -1,4 +1,5 @@ + import { useEffect, useRef, useState } from "react"; export default function VideoEditor() { @@ -11,6 +12,7 @@ export default function VideoEditor() { const videoRef = useRef(null); const canvasRef = useRef(null); + const isSeeking = useRef(false); useEffect(() => { async function loadVideo() { @@ -36,15 +38,12 @@ export default function VideoEditor() { if (!video || !canvas) return; let animationId: number; - function drawFrame() { if (!video || !canvas || video.paused || video.ended) return; - if (canvas.width !== video.videoWidth || canvas.height !== video.videoHeight) { canvas.width = video.videoWidth; canvas.height = video.videoHeight; } - const ctx = canvas.getContext('2d'); if (ctx) { ctx.clearRect(0, 0, canvas.width, canvas.height); @@ -52,14 +51,11 @@ export default function VideoEditor() { } animationId = requestAnimationFrame(drawFrame); } - const handlePlay = () => drawFrame(); const handlePause = () => cancelAnimationFrame(animationId); - video.addEventListener('play', handlePlay); video.addEventListener('pause', handlePause); video.addEventListener('ended', handlePause); - return () => { video.removeEventListener('play', handlePlay); video.removeEventListener('pause', handlePause); @@ -72,12 +68,18 @@ export default function VideoEditor() { if (!videoRef.current) return; isPlaying ? videoRef.current.pause() : videoRef.current.play(); } - function handleSeek(e: React.ChangeEvent) { if (!videoRef.current) return; - videoRef.current.currentTime = parseFloat(e.target.value); + const newTime = parseFloat(e.target.value); + videoRef.current.currentTime = newTime; + setCurrentTime(newTime); + } + function handleSeekStart() { + isSeeking.current = true; + } + function handleSeekEnd() { + isSeeking.current = false; } - function formatTime(seconds: number) { if (!isFinite(seconds) || isNaN(seconds) || seconds < 0) return '0:00'; const mins = Math.floor(seconds / 60); @@ -92,7 +94,6 @@ export default function VideoEditor() { ); } - if (error) { return (
@@ -102,69 +103,63 @@ export default function VideoEditor() { } return ( -
-
-
- {videoPath && ( - <> - -