"use client"; 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"; export function PreviewPanel() { const { tracks } = useTimelineStore(); const { mediaItems } = useMediaStore(); const { isPlaying, toggle, currentTime } = usePlaybackStore(); // Find the active clip at the current playback time const getActiveClip = () => { for (const track of tracks) { for (const clip of track.clips) { const clipStart = clip.startTime; const clipEnd = clip.startTime + (clip.duration - clip.trimStart - clip.trimEnd); if (currentTime >= clipStart && currentTime < clipEnd) { return clip; } } } return null; }; const activeClip = getActiveClip(); const activeMediaItem = activeClip ? mediaItems.find((item) => item.id === activeClip.mediaId) : null; const aspectRatio = activeMediaItem?.aspectRatio || 16 / 9; const renderContent = () => { if (!activeMediaItem || !activeClip) { return (
{tracks.length === 0 ? "Drop media to start editing" : "No clip at current time"}
); } // Calculate the relative time within the clip (accounting for trim) const relativeTime = Math.max(0, currentTime - activeClip.startTime + activeClip.trimStart); if (activeMediaItem.type === "video") { return ( ); } if (activeMediaItem.type === "image") { return ( ); } if (activeMediaItem.type === "audio") { return (
🎵

{activeMediaItem.name}

); } return null; }; return (
1 ? "100%" : "auto", height: aspectRatio <= 1 ? "100%" : "auto", maxWidth: "100%", maxHeight: "100%", }} > {renderContent()}
{activeMediaItem && (

{activeMediaItem.name}

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

)}
); }