From ed6ab6cd5b6fec5f8e7d7cbcaa5224393729164e Mon Sep 17 00:00:00 2001 From: Hyteq Date: Mon, 23 Jun 2025 09:18:15 +0300 Subject: feat: cleaned up video player, added functionality, zooming in/out, timeline position viewer, keyboard controls --- apps/web/src/components/editor/preview-panel.tsx | 92 ++++++++---------------- 1 file changed, 31 insertions(+), 61 deletions(-) (limited to 'apps/web/src/components/editor/preview-panel.tsx') diff --git a/apps/web/src/components/editor/preview-panel.tsx b/apps/web/src/components/editor/preview-panel.tsx index 16c808f4..593758e1 100644 --- a/apps/web/src/components/editor/preview-panel.tsx +++ b/apps/web/src/components/editor/preview-panel.tsx @@ -2,57 +2,52 @@ import { useTimelineStore } from "@/stores/timeline-store"; import { useMediaStore } from "@/stores/media-store"; +import { usePlaybackStore } from "@/stores/playback-store"; import { ImageTimelineTreatment } from "@/components/ui/image-timeline-treatment"; +import { VideoPlayer } from "@/components/ui/video-player"; import { Button } from "@/components/ui/button"; import { Play, Pause } from "lucide-react"; -import { useState } from "react"; export function PreviewPanel() { const { tracks } = useTimelineStore(); const { mediaItems } = useMediaStore(); - const [isPlaying, setIsPlaying] = useState(false); + const { isPlaying, toggle } = usePlaybackStore(); - // Get the first clip from the first track for preview (simplified for now) const firstClip = tracks[0]?.clips[0]; const firstMediaItem = firstClip ? mediaItems.find((item) => item.id === firstClip.mediaId) : null; - // Calculate dynamic aspect ratio - default to 16:9 if no media const aspectRatio = firstMediaItem?.aspectRatio || 16 / 9; - const renderPreviewContent = () => { + const renderContent = () => { if (!firstMediaItem) { return ( -
- Drop media here or click to import +
+ Drop media to start editing
); } - if (firstMediaItem.type === "image") { + if (firstMediaItem.type === "video") { return ( - ); } - if (firstMediaItem.type === "video") { - return firstMediaItem.thumbnailUrl ? ( - {firstMediaItem.name} - ) : ( -
- Video Preview -
); } @@ -62,6 +57,14 @@ export function PreviewPanel() {
🎵

{firstMediaItem.name}

+
); @@ -73,7 +76,7 @@ export function PreviewPanel() { return (
1 ? "100%" : "auto", @@ -82,49 +85,16 @@ export function PreviewPanel() { maxHeight: "100%", }} > - {renderPreviewContent()} - - {/* Playback Controls Overlay */} - {firstMediaItem && ( -
-
- - - {firstClip?.name || "No clip selected"} - -
-
- )} + {renderContent()}
- {/* Preview Info */} {firstMediaItem && (

- Preview: {firstMediaItem.name} - {firstMediaItem.type === "image" && - " (with CapCut-style treatment)"} -
- - Aspect Ratio: {aspectRatio.toFixed(2)} ( - {aspectRatio > 1 - ? "Landscape" - : aspectRatio < 1 - ? "Portrait" - : "Square"} - ) - + {firstMediaItem.name} +

+

+ {aspectRatio.toFixed(2)} • {aspectRatio > 1 ? "Landscape" : aspectRatio < 1 ? "Portrait" : "Square"}

)} -- cgit v1.3.1