Create polished demo videos without editing skills. Mac/Windows/Linux
feat: add audio option in tools
4rjuncc687d6990e1f
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex f410b42b..323f34fe 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -7,6 +7,52 @@ import { Toaster } from "@/components/ui/sonner";import { useI18n } from "@/contexts/I18nContext";import { SUPPORTED_LOCALES } from "@/i18n/config";import type { AppLocale } from "@/i18n/config";++import VideoPlayback, { VideoPlaybackRef } from "./VideoPlayback";+import PlaybackControls from "./PlaybackControls";+import TimelineEditor from "./timeline/TimelineEditor";+import { SettingsPanel } from "./SettingsPanel";+import { ExportDialog } from "./ExportDialog";+import { DEFAULT_WALLPAPER_RELATIVE_PATH, WALLPAPER_PATHS } from "@/lib/wallpapers";+import {+ createProjectData,+ deriveNextId,+ fromFileUrl,+ normalizeProjectEditor,+ toFileUrl,+ validateProjectData,+} from "./projectPersistence";++import type { Span } from "dnd-timeline";+import {+ DEFAULT_CURSOR_CLICK_BOUNCE,+ DEFAULT_CURSOR_MOTION_BLUR,+ DEFAULT_CURSOR_SIZE,+ DEFAULT_CURSOR_SMOOTHING,+ DEFAULT_ZOOM_DEPTH,+ DEFAULT_ZOOM_MOTION_BLUR,+ clampFocusToDepth,+ DEFAULT_CROP_REGION,+ DEFAULT_ANNOTATION_POSITION,+ DEFAULT_ANNOTATION_SIZE,+ DEFAULT_ANNOTATION_STYLE,+ DEFAULT_FIGURE_DATA,+ DEFAULT_PLAYBACK_SPEED,+ type ZoomDepth,+ type ZoomFocus,+ type ZoomRegion,+ type CursorTelemetryPoint,+ type TrimRegion,+ type AnnotationRegion,+ type CropRegion,+ type FigureData,+ type SpeedRegion,+ type AudioRegion,+ type PlaybackSpeed,+} from "./types";+import { VideoExporter, GifExporter, type ExportProgress, type ExportQuality, type ExportSettings, type ExportFormat, type GifFrameRate, type GifSizePreset, GIF_SIZE_PRESETS, calculateOutputDimensions } from "@/lib/exporter";+import { type AspectRatio, getAspectRatioValue } from "@/utils/aspectRatioUtils";+import { getAssetPath } from "@/lib/assetPath";import { useShortcuts } from "@/contexts/ShortcutsContext";import { getAssetPath } from "@/lib/assetPath";import {@@ -75,14 +121,16 @@ import { findDominantRegion } from "./videoPlayback/zoomRegionUtils";const LOOP_CURSOR_END_WINDOW_MS = 670;type EditorHistorySnapshot = {- zoomRegions: ZoomRegion[];- trimRegions: TrimRegion[];- speedRegions: SpeedRegion[];- annotationRegions: AnnotationRegion[];- selectedZoomId: string | null;- selectedTrimId: string | null;- selectedSpeedId: string | null;- selectedAnnotationId: string | null;+ zoomRegions: ZoomRegion[];+ trimRegions: TrimRegion[];+ speedRegions: SpeedRegion[];+ annotationRegions: AnnotationRegion[];+ audioRegions: AudioRegion[];+ selectedZoomId: string | null;+ selectedTrimId: string | null;+ selectedSpeedId: string | null;+ selectedAnnotationId: string | null;+ selectedAudioId: string | null;};type PendingExportSave = {@@ -142,6 +190,8 @@ export default function VideoEditor() {const [selectedSpeedId, setSelectedSpeedId] = useState<string | null>(null);const [annotationRegions, setAnnotationRegions] = useState<AnnotationRegion[]>([]);const [selectedAnnotationId, setSelectedAnnotationId] = useState<string | null>(null);+ const [audioRegions, setAudioRegions] = useState<AudioRegion[]>([]);+ const [selectedAudioId, setSelectedAudioId] = useState<string | null>(null);const [isExporting, setIsExporting] = useState(false);const [exportProgress, setExportProgress] = useState<ExportProgress | null>(null);const [exportError, setExportError] = useState<string | null>(null);@@ -160,6 +210,7 @@ export default function VideoEditor() {const nextZoomIdRef = useRef(1);const nextTrimIdRef = useRef(1);const nextSpeedIdRef = useRef(1);+ const nextAudioIdRef = useRef(1);const { shortcuts, isMac } = useShortcuts();const nextAnnotationIdRef = useRef(1);@@ -178,10 +229,12 @@ export default function VideoEditor() {trimRegions: JSON.parse(JSON.stringify(snapshot.trimRegions)),speedRegions: JSON.parse(JSON.stringify(snapshot.speedRegions)),annotationRegions: JSON.parse(JSON.stringify(snapshot.annotationRegions)),+ audioRegions: JSON.parse(JSON.stringify(snapshot.audioRegions)),selectedZoomId: snapshot.selectedZoomId,selectedTrimId: snapshot.selectedTrimId,selectedSpeedId: snapshot.selectedSpeedId,selectedAnnotationId: snapshot.selectedAnnotationId,+ selectedAudioId: snapshot.selectedAudioId,};}, []);@@ -191,20 +244,24 @@ export default function VideoEditor() {trimRegions,speedRegions,annotationRegions,+ audioRegions,selectedZoomId,selectedTrimId,selectedSpeedId,selectedAnnotationId,+ selectedAudioId,};}, [zoomRegions,trimRegions,speedRegions,annotationRegions,+ audioRegions,selectedZoomId,selectedTrimId,selectedSpeedId,selectedAnnotationId,+ selectedAudioId,]);const applyHistorySnapshot = useCallback((snapshot: EditorHistorySnapshot) => {@@ -214,15 +271,18 @@ export default function VideoEditor() {setTrimRegions(cloned.trimRegions);setSpeedRegions(cloned.speedRegions);setAnnotationRegions(cloned.annotationRegions);+ setAudioRegions(cloned.audioRegions);setSelectedZoomId(cloned.selectedZoomId);setSelectedTrimId(cloned.selectedTrimId);setSelectedSpeedId(cloned.selectedSpeedId);setSelectedAnnotationId(cloned.selectedAnnotationId);+ setSelectedAudioId(cloned.selectedAudioId);nextZoomIdRef.current = deriveNextId("zoom", cloned.zoomRegions.map((region) => region.id));nextTrimIdRef.current = deriveNextId("trim", cloned.trimRegions.map((region) => region.id));nextSpeedIdRef.current = deriveNextId("speed", cloned.speedRegions.map((region) => region.id));nextAnnotationIdRef.current = deriveNextId("annotation", cloned.annotationRegions.map((region) => region.id));+ nextAudioIdRef.current = deriveNextId("audio", cloned.audioRegions.map((region) => region.id));nextAnnotationZIndexRef.current =cloned.annotationRegions.reduce((max, region) => Math.max(max, region.zIndex), 0) + 1;}, [cloneSnapshot]);@@ -292,6 +352,7 @@ export default function VideoEditor() {setTrimRegions(normalizedEditor.trimRegions);setSpeedRegions(normalizedEditor.speedRegions);setAnnotationRegions(normalizedEditor.annotationRegions);+ setAudioRegions(normalizedEditor.audioRegions);setAspectRatio(normalizedEditor.aspectRatio);setExportQuality(normalizedEditor.exportQuality);setExportFormat(normalizedEditor.exportFormat);@@ -303,10 +364,12 @@ export default function VideoEditor() {setSelectedTrimId(null);setSelectedSpeedId(null);setSelectedAnnotationId(null);+ setSelectedAudioId(null);nextZoomIdRef.current = deriveNextId("zoom", normalizedEditor.zoomRegions.map((region) => region.id));nextTrimIdRef.current = deriveNextId("trim", normalizedEditor.trimRegions.map((region) => region.id));nextSpeedIdRef.current = deriveNextId("speed", normalizedEditor.speedRegions.map((region) => region.id));+ nextAudioIdRef.current = deriveNextId("audio", normalizedEditor.audioRegions.map((region) => region.id));nextAnnotationIdRef.current = deriveNextId("annotation",normalizedEditor.annotationRegions.map((region) => region.id),@@ -343,6 +406,7 @@ export default function VideoEditor() {trimRegions,speedRegions,annotationRegions,+ audioRegions,aspectRatio,exportQuality,exportFormat,@@ -371,6 +435,7 @@ export default function VideoEditor() {zoomRegions,trimRegions,speedRegions,+ audioRegions,annotationRegions,aspectRatio,exportQuality,@@ -480,6 +545,7 @@ export default function VideoEditor() {trimRegions,speedRegions,annotationRegions,+ audioRegions,aspectRatio,exportQuality,exportFormat,@@ -814,7 +880,10 @@ export default function VideoEditor() {const handleSelectZoom = useCallback((id: string | null) => {setSelectedZoomId(id);- if (id) setSelectedTrimId(null);+ if (id) {+ setSelectedTrimId(null);+ setSelectedAudioId(null);+ }}, []);const handleSelectTrim = useCallback((id: string | null) => {@@ -822,6 +891,7 @@ export default function VideoEditor() {if (id) {setSelectedZoomId(null);setSelectedAnnotationId(null);+ setSelectedAudioId(null);}}, []);@@ -830,6 +900,7 @@ export default function VideoEditor() {if (id) {setSelectedZoomId(null);setSelectedTrimId(null);+ setSelectedAudioId(null);}}, []);@@ -952,6 +1023,7 @@ export default function VideoEditor() {setSelectedZoomId(null);setSelectedTrimId(null);setSelectedAnnotationId(null);+ setSelectedAudioId(null);}}, []);@@ -991,6 +1063,54 @@ export default function VideoEditor() {}}, [selectedSpeedId]);+ const handleSelectAudio = useCallback((id: string | null) => {+ setSelectedAudioId(id);+ if (id) {+ setSelectedZoomId(null);+ setSelectedTrimId(null);+ setSelectedAnnotationId(null);+ setSelectedSpeedId(null);+ }+ }, []);++ const handleAudioAdded = useCallback((span: Span, audioPath: string) => {+ const id = `audio-${nextAudioIdRef.current++}`;+ const newRegion: AudioRegion = {+ id,+ startMs: Math.round(span.start),+ endMs: Math.round(span.end),+ audioPath,+ volume: 1,+ };+ setAudioRegions((prev) => [...prev, newRegion]);+ setSelectedAudioId(id);+ setSelectedZoomId(null);+ setSelectedTrimId(null);+ setSelectedAnnotationId(null);+ setSelectedSpeedId(null);+ }, []);++ const handleAudioSpanChange = useCallback((id: string, span: Span) => {+ setAudioRegions((prev) =>+ prev.map((region) =>+ region.id === id+ ? {+ ...region,+ startMs: Math.round(span.start),+ endMs: Math.round(span.end),+ }+ : region,+ ),+ );+ }, []);++ const handleAudioDelete = useCallback((id: string) => {+ setAudioRegions((prev) => prev.filter((region) => region.id !== id));+ if (selectedAudioId === id) {+ setSelectedAudioId(null);+ }+ }, [selectedAudioId]);+const handleSpeedChange = useCallback((speed: PlaybackSpeed) => {if (!selectedSpeedId) return;setSpeedRegions((prev) =>@@ -1210,6 +1330,78 @@ export default function VideoEditor() {}}, [selectedSpeedId, speedRegions]);+ useEffect(() => {+ if (selectedAudioId && !audioRegions.some((region) => region.id === selectedAudioId)) {+ setSelectedAudioId(null);+ }+ }, [selectedAudioId, audioRegions]);++ // Audio playback sync: manage Audio elements that play in sync with video+ const audioElementsRef = useRef<Map<string, HTMLAudioElement>>(new Map());++ useEffect(() => {+ const existing = audioElementsRef.current;+ const currentIds = new Set(audioRegions.map(r => r.id));++ // Remove old audio elements+ for (const [id, audio] of existing) {+ if (!currentIds.has(id)) {+ audio.pause();+ audio.src = '';+ existing.delete(id);+ }+ }++ // Create/update audio elements+ for (const region of audioRegions) {+ let audio = existing.get(region.id);+ if (!audio) {+ audio = new Audio();+ audio.preload = 'auto';+ existing.set(region.id, audio);+ }+ const expectedSrc = toFileUrl(region.audioPath);+ if (audio.src !== expectedSrc) {+ audio.src = expectedSrc;+ }+ audio.volume = region.volume;+ }++ return () => {+ for (const audio of existing.values()) {+ audio.pause();+ audio.src = '';+ }+ existing.clear();+ };+ }, [audioRegions]);++ // Sync audio playback with video currentTime and isPlaying state+ useEffect(() => {+ for (const region of audioRegions) {+ const audio = audioElementsRef.current.get(region.id);+ if (!audio) continue;++ const currentTimeMs = currentTime * 1000;+ const isInRegion = currentTimeMs >= region.startMs && currentTimeMs < region.endMs;++ if (isPlaying && isInRegion) {+ const audioOffset = (currentTimeMs - region.startMs) / 1000;+ // Only seek if significantly out of sync (> 200ms)+ if (Math.abs(audio.currentTime - audioOffset) > 0.2) {+ audio.currentTime = audioOffset;+ }+ if (audio.paused) {+ audio.play().catch(() => {});+ }+ } else {+ if (!audio.paused) {+ audio.pause();+ }+ }+ }+ }, [isPlaying, currentTime, audioRegions]);+const showExportSuccessToast = useCallback((filePath: string) => {toast.success(`Exported successfully to ${filePath}`, {action: {@@ -1746,6 +1938,12 @@ export default function VideoEditor() {onSpeedDelete={handleSpeedDelete}selectedSpeedId={selectedSpeedId}onSelectSpeed={handleSelectSpeed}+ audioRegions={audioRegions}+ onAudioAdded={handleAudioAdded}+ onAudioSpanChange={handleAudioSpanChange}+ onAudioDelete={handleAudioDelete}+ selectedAudioId={selectedAudioId}+ onSelectAudio={handleSelectAudio}annotationRegions={annotationRegions}onAnnotationAdded={handleAnnotationAdded}onAnnotationSpanChange={handleAnnotationSpanChange}diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.tsindex be25b8fd..e7f13bc7 100644--- a/src/components/video-editor/projectPersistence.ts+++ b/src/components/video-editor/projectPersistence.ts@@ -18,6 +18,7 @@ import {type CropRegion,type SpeedRegion,type TrimRegion,+ type AudioRegion,type ZoomRegion,} from "./types";@@ -42,6 +43,7 @@ export interface ProjectEditorState {trimRegions: TrimRegion[];speedRegions: SpeedRegion[];annotationRegions: AnnotationRegion[];+ audioRegions: AudioRegion[];aspectRatio: AspectRatio;exportQuality: ExportQuality;exportFormat: ExportFormat;@@ -289,6 +291,25 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro}): [];+ const normalizedAudioRegions: AudioRegion[] = Array.isArray((editor as Partial<ProjectEditorState>).audioRegions)+ ? ((editor as Partial<ProjectEditorState>).audioRegions as AudioRegion[])+ .filter((region): region is AudioRegion => Boolean(region && typeof region.id === "string"))+ .map((region) => {+ const rawStart = isFiniteNumber(region.startMs) ? Math.round(region.startMs) : 0;+ const rawEnd = isFiniteNumber(region.endMs) ? Math.round(region.endMs) : rawStart + 1000;+ const startMs = Math.max(0, Math.min(rawStart, rawEnd));+ const endMs = Math.max(startMs + 1, rawEnd);++ return {+ id: region.id,+ startMs,+ endMs,+ audioPath: typeof region.audioPath === "string" ? region.audioPath : "",+ volume: isFiniteNumber(region.volume) ? clamp(region.volume, 0, 2) : 1,+ };+ })+ : [];+const rawCropX = isFiniteNumber(editor.cropRegion?.x) ? editor.cropRegion.x : DEFAULT_CROP_REGION.x;const rawCropY = isFiniteNumber(editor.cropRegion?.y) ? editor.cropRegion.y : DEFAULT_CROP_REGION.y;const rawCropWidth = isFiniteNumber(editor.cropRegion?.width) ? editor.cropRegion.width : DEFAULT_CROP_REGION.width;@@ -331,6 +352,7 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): ProtrimRegions: normalizedTrimRegions,speedRegions: normalizedSpeedRegions,annotationRegions: normalizedAnnotationRegions,+ audioRegions: normalizedAudioRegions,aspectRatio:typeof editor.aspectRatio === "string" &&(validAspectRatios.has(editor.aspectRatio as AspectRatio) || isCustomAspectRatio(editor.aspectRatio))diff --git a/src/components/video-editor/timeline/Item.tsx b/src/components/video-editor/timeline/Item.tsxindex 2870fc92..0b319feb 100644--- a/src/components/video-editor/timeline/Item.tsx+++ b/src/components/video-editor/timeline/Item.tsx@@ -4,18 +4,19 @@ import { Gauge, MessageSquare, Scissors, ZoomIn } from "lucide-react";import { useMemo } from "react";import { useScopedT } from "@/contexts/I18nContext";import { cn } from "@/lib/utils";+import { ZoomIn, Scissors, MessageSquare, Gauge, Music } from "lucide-react";import glassStyles from "./ItemGlass.module.css";interface ItemProps {- id: string;- span: Span;- rowId: string;- children: React.ReactNode;- isSelected?: boolean;- onSelect?: () => void;- zoomDepth?: number;- speedValue?: number;- variant?: "zoom" | "trim" | "annotation" | "speed";+ id: string;+ span: Span;+ rowId: string;+ children: React.ReactNode;+ isSelected?: boolean;+ onSelect?: () => void;+ zoomDepth?: number;+ speedValue?: number;+ variant?: 'zoom' | 'trim' | 'annotation' | 'speed' | 'audio';}// Map zoom depth to multiplier labels@@ -56,19 +57,30 @@ export default function Item({data: { rowId },});- const isZoom = variant === "zoom";- const isTrim = variant === "trim";- const isSpeed = variant === "speed";+ const isZoom = variant === 'zoom';+ const isTrim = variant === 'trim';+ const isSpeed = variant === 'speed';+ const isAudio = variant === 'audio';- const glassClass = isZoom- ? glassStyles.glassGreen- : isTrim- ? glassStyles.glassRed- : isSpeed- ? glassStyles.glassAmber- : glassStyles.glassYellow;+ const glassClass = isZoom+ ? glassStyles.glassGreen+ : isTrim+ ? glassStyles.glassRed+ : isSpeed+ ? glassStyles.glassAmber+ : isAudio+ ? glassStyles.glassPurple+ : glassStyles.glassYellow;- const endCapColor = isZoom ? "#2563EB" : isTrim ? "#ef4444" : isSpeed ? "#d97706" : "#B4A046";+ const endCapColor = isZoom+ ? '#2563EB'+ : isTrim+ ? '#ef4444'+ : isSpeed+ ? '#d97706'+ : isAudio+ ? '#a855f7'+ : '#B4A046';const timeLabel = useMemo(() => `${formatMs(span.start)} – ${formatMs(span.end)}`,@@ -78,93 +90,88 @@ export default function Item({const MIN_ITEM_PX = 6;const safeItemStyle = { ...itemStyle, minWidth: MIN_ITEM_PX };- return (- <div- ref={setNodeRef}- style={safeItemStyle}- {...listeners}- {...attributes}- onPointerDownCapture={() => onSelect?.()}- className="group"- >- <div style={{ ...itemContentStyle, minWidth: 24 }}>- <div- className={cn(- glassClass,- "w-full h-full overflow-hidden flex items-center justify-center gap-1.5 cursor-grab active:cursor-grabbing relative",- isSelected && glassStyles.selected,- )}- style={{ height: 40, color: "#fff", minWidth: 24 }}- onClick={(event) => {- event.stopPropagation();- onSelect?.();- }}- >- <div- className={cn(glassStyles.zoomEndCap, glassStyles.left)}- style={{- cursor: "col-resize",- pointerEvents: "auto",- width: 8,- opacity: 0.9,- background: endCapColor,- }}- title={t("resizeLeft")}- />- <div- className={cn(glassStyles.zoomEndCap, glassStyles.right)}- style={{- cursor: "col-resize",- pointerEvents: "auto",- width: 8,- opacity: 0.9,- background: endCapColor,- }}- title={t("resizeRight")}- />- {/* Content */}- <div className="relative z-10 flex flex-col items-center justify-center text-white/90 opacity-80 group-hover:opacity-100 transition-opacity select-none overflow-hidden">- <div className="flex items-center gap-1.5">- {isZoom ? (- <>- <ZoomIn className="w-3.5 h-3.5 shrink-0" />- <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">- {ZOOM_LABELS[zoomDepth] || `${zoomDepth}×`}- </span>- </>- ) : isTrim ? (- <>- <Scissors className="w-3.5 h-3.5 shrink-0" />- <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">- {t("trim.label", undefined, { index: "" }).trim()}- </span>- </>- ) : isSpeed ? (- <>- <Gauge className="w-3.5 h-3.5 shrink-0" />- <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">- {speedValue !== undefined ? `${speedValue}×` : t("speed.label")}- </span>- </>- ) : (- <>- <MessageSquare className="w-3.5 h-3.5 shrink-0" />- <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">- {children}- </span>- </>- )}- </div>- <span- className={`text-[9px] tabular-nums tracking-tight whitespace-nowrap transition-opacity ${- isSelected ? "opacity-60" : "opacity-0 group-hover:opacity-40"- }`}- >- {timeLabel}- </span>- </div>- </div>- </div>- </div>- );+ return (+ <div+ ref={setNodeRef}+ style={safeItemStyle}+ {...listeners}+ {...attributes}+ onPointerDownCapture={() => onSelect?.()}+ className="group"+ >+ <div style={{ ...itemContentStyle, minWidth: 24 }}>+ <div+ className={cn(+ glassClass,+ "w-full h-full overflow-hidden flex items-center justify-center gap-1.5 cursor-grab active:cursor-grabbing relative",+ isSelected && glassStyles.selected+ )}+ style={{ height: 40, color: '#fff', minWidth: 24 }}+ onClick={(event) => {+ event.stopPropagation();+ onSelect?.();+ }}+ >+ <div+ className={cn(glassStyles.zoomEndCap, glassStyles.left)}+ style={{ cursor: 'col-resize', pointerEvents: 'auto', width: 8, opacity: 0.9, background: endCapColor }}+ title="Resize left"+ />+ <div+ className={cn(glassStyles.zoomEndCap, glassStyles.right)}+ style={{ cursor: 'col-resize', pointerEvents: 'auto', width: 8, opacity: 0.9, background: endCapColor }}+ title="Resize right"+ />+ {/* Content */}+ <div className="relative z-10 flex flex-col items-center justify-center text-white/90 opacity-80 group-hover:opacity-100 transition-opacity select-none overflow-hidden">+ <div className="flex items-center gap-1.5">+ {isZoom ? (+ <>+ <ZoomIn className="w-3.5 h-3.5 shrink-0" />+ <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">+ {ZOOM_LABELS[zoomDepth] || `${zoomDepth}×`}+ </span>+ </>+ ) : isTrim ? (+ <>+ <Scissors className="w-3.5 h-3.5 shrink-0" />+ <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">+ Trim+ </span>+ </>+ ) : isSpeed ? (+ <>+ <Gauge className="w-3.5 h-3.5 shrink-0" />+ <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">+ {speedValue !== undefined ? `${speedValue}×` : 'Speed'}+ </span>+ </>+ ) : isAudio ? (+ <>+ <Music className="w-3.5 h-3.5 shrink-0" />+ <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">+ {children}+ </span>+ </>+ ) : (+ <>+ <MessageSquare className="w-3.5 h-3.5 shrink-0" />+ <span className="text-[11px] font-semibold tracking-tight whitespace-nowrap">+ {children}+ </span>+ </>+ )}+ </div>+ <span+ className={`text-[9px] tabular-nums tracking-tight whitespace-nowrap transition-opacity ${+ isSelected ? 'opacity-60' : 'opacity-0 group-hover:opacity-40'+ }`}+ >+ {timeLabel}+ </span>+ </div>+ </div>+ </div>+ </div>+ );}diff --git a/src/components/video-editor/timeline/ItemGlass.module.css b/src/components/video-editor/timeline/ItemGlass.module.cssindex 23754429..9c96ea22 100644--- a/src/components/video-editor/timeline/ItemGlass.module.css+++ b/src/components/video-editor/timeline/ItemGlass.module.css@@ -102,6 +102,32 @@z-index: 10;}+.glassPurple {+ position: relative;+ border-radius: 8px;+ -corner-smoothing: antialiased;+ background: rgba(168, 85, 247, 0.15);+ border: 1px solid rgba(168, 85, 247, 0.3);+ box-shadow: 0 2px 12px 0 rgba(168, 85, 247, 0.1) inset;+ margin: 2px 0;+ backdrop-filter: blur(4px);+ -webkit-backdrop-filter: blur(4px);+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);+}++.glassPurple:hover {+ background: rgba(168, 85, 247, 0.25);+ border-color: rgba(168, 85, 247, 0.5);+ box-shadow: 0 4px 20px 0 rgba(168, 85, 247, 0.2) inset;+}++.glassPurple.selected {+ background: rgba(168, 85, 247, 0.35);+ border-color: #a855f7;+ box-shadow: 0 0 0 1px #a855f7, 0 4px 20px 0 rgba(168, 85, 247, 0.3) inset;+ z-index: 10;+}+.zoomEndCap {position: absolute;top: 0;@@ -120,7 +146,9 @@.glassYellow:hover .zoomEndCap,.glassYellow.selected .zoomEndCap,.glassAmber:hover .zoomEndCap,-.glassAmber.selected .zoomEndCap {+.glassAmber.selected .zoomEndCap,+.glassPurple:hover .zoomEndCap,+.glassPurple.selected .zoomEndCap {opacity: 1;}diff --git a/src/components/video-editor/timeline/TimelineEditor.tsx b/src/components/video-editor/timeline/TimelineEditor.tsxindex 13ce0719..31d9c496 100644--- a/src/components/video-editor/timeline/TimelineEditor.tsx+++ b/src/components/video-editor/timeline/TimelineEditor.tsx@@ -1,5 +1,16 @@-import type { Range, Span } from "dnd-timeline";+import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type WheelEvent } from "react";import { useTimelineContext } from "dnd-timeline";+import { Button } from "@/components/ui/button";+import { Plus, Scissors, ZoomIn, MessageSquare, ChevronDown, Check, Gauge, WandSparkles, Music } from "lucide-react";+import { toast } from "sonner";+import { cn } from "@/lib/utils";+import TimelineWrapper from "./TimelineWrapper";+import Row from "./Row";+import Item from "./Item";+import KeyframeMarkers from "./KeyframeMarkers";+import type { Range, Span } from "dnd-timeline";+import type { ZoomRegion, TrimRegion, AnnotationRegion, SpeedRegion, AudioRegion, CursorTelemetryPoint, ZoomFocus } from "../types";+import { v4 as uuidv4 } from 'uuid';import {Check,ChevronDown,@@ -44,42 +55,49 @@ const ZOOM_ROW_ID = "row-zoom";const TRIM_ROW_ID = "row-trim";const ANNOTATION_ROW_ID = "row-annotation";const SPEED_ROW_ID = "row-speed";+const AUDIO_ROW_ID = "row-audio";const FALLBACK_RANGE_MS = 1000;const TARGET_MARKER_COUNT = 12;const SUGGESTION_SPACING_MS = 1800;interface TimelineEditorProps {- videoDuration: number;- currentTime: number;- onSeek?: (time: number) => void;- cursorTelemetry?: CursorTelemetryPoint[];- zoomRegions: ZoomRegion[];- onZoomAdded: (span: Span) => void;- onZoomSuggested?: (span: Span, focus: ZoomFocus) => void;- onZoomSpanChange: (id: string, span: Span) => void;- onZoomDelete: (id: string) => void;- selectedZoomId: string | null;- onSelectZoom: (id: string | null) => void;- trimRegions?: TrimRegion[];- onTrimAdded?: (span: Span) => void;- onTrimSpanChange?: (id: string, span: Span) => void;- onTrimDelete?: (id: string) => void;- selectedTrimId?: string | null;- onSelectTrim?: (id: string | null) => void;- annotationRegions?: AnnotationRegion[];- onAnnotationAdded?: (span: Span) => void;- onAnnotationSpanChange?: (id: string, span: Span) => void;- onAnnotationDelete?: (id: string) => void;- selectedAnnotationId?: string | null;- onSelectAnnotation?: (id: string | null) => void;- speedRegions?: SpeedRegion[];- onSpeedAdded?: (span: Span) => void;- onSpeedSpanChange?: (id: string, span: Span) => void;- onSpeedDelete?: (id: string) => void;- selectedSpeedId?: string | null;- onSelectSpeed?: (id: string | null) => void;- aspectRatio: AspectRatio;- onAspectRatioChange: (aspectRatio: AspectRatio) => void;+ videoDuration: number;+ currentTime: number;+ onSeek?: (time: number) => void;+ cursorTelemetry?: CursorTelemetryPoint[];+ zoomRegions: ZoomRegion[];+ onZoomAdded: (span: Span) => void;+ onZoomSuggested?: (span: Span, focus: ZoomFocus) => void;+ onZoomSpanChange: (id: string, span: Span) => void;+ onZoomDelete: (id: string) => void;+ selectedZoomId: string | null;+ onSelectZoom: (id: string | null) => void;+ trimRegions?: TrimRegion[];+ onTrimAdded?: (span: Span) => void;+ onTrimSpanChange?: (id: string, span: Span) => void;+ onTrimDelete?: (id: string) => void;+ selectedTrimId?: string | null;+ onSelectTrim?: (id: string | null) => void;+ annotationRegions?: AnnotationRegion[];+ onAnnotationAdded?: (span: Span) => void;+ onAnnotationSpanChange?: (id: string, span: Span) => void;+ onAnnotationDelete?: (id: string) => void;+ selectedAnnotationId?: string | null;+ onSelectAnnotation?: (id: string | null) => void;+ speedRegions?: SpeedRegion[];+ onSpeedAdded?: (span: Span) => void;+ onSpeedSpanChange?: (id: string, span: Span) => void;+ onSpeedDelete?: (id: string) => void;+ selectedSpeedId?: string | null;+ onSelectSpeed?: (id: string | null) => void;+ audioRegions?: AudioRegion[];+ onAudioAdded?: (span: Span, audioPath: string) => void;+ onAudioSpanChange?: (id: string, span: Span) => void;+ onAudioDelete?: (id: string) => void;+ selectedAudioId?: string | null;+ onSelectAudio?: (id: string | null) => void;+ aspectRatio: AspectRatio;+ onAspectRatioChange: (aspectRatio: AspectRatio) => void;}interface TimelineScaleConfig {@@ -89,13 +107,13 @@ interface TimelineScaleConfig {}interface TimelineRenderItem {- id: string;- rowId: string;- span: Span;- label: string;- zoomDepth?: number;- speedValue?: number;- variant: "zoom" | "trim" | "annotation" | "speed";+ id: string;+ rowId: string;+ span: Span;+ label: string;+ zoomDepth?: number;+ speedValue?: number;+ variant: 'zoom' | 'trim' | 'annotation' | 'speed' | 'audio';}const SCALE_CANDIDATES = [@@ -443,33 +461,37 @@ function TimelineAxis({}function Timeline({- items,- videoDurationMs,- currentTimeMs,- onSeek,- onSelectZoom,- onSelectTrim,- onSelectAnnotation,- onSelectSpeed,- selectedZoomId,- selectedTrimId,- selectedAnnotationId,- selectedSpeedId,- keyframes = [],+ items,+ videoDurationMs,+ currentTimeMs,+ onSeek,+ onSelectZoom,+ onSelectTrim,+ onSelectAnnotation,+ onSelectSpeed,+ onSelectAudio,+ selectedZoomId,+ selectedTrimId,+ selectedAnnotationId,+ selectedSpeedId,+ selectedAudioId,+ keyframes = [],}: {- items: TimelineRenderItem[];- videoDurationMs: number;- currentTimeMs: number;- onSeek?: (time: number) => void;- onSelectZoom?: (id: string | null) => void;- onSelectTrim?: (id: string | null) => void;- onSelectAnnotation?: (id: string | null) => void;- onSelectSpeed?: (id: string | null) => void;- selectedZoomId: string | null;- selectedTrimId?: string | null;- selectedAnnotationId?: string | null;- selectedSpeedId?: string | null;- keyframes?: { id: string; time: number }[];+ items: TimelineRenderItem[];+ videoDurationMs: number;+ currentTimeMs: number;+ onSeek?: (time: number) => void;+ onSelectZoom?: (id: string | null) => void;+ onSelectTrim?: (id: string | null) => void;+ onSelectAnnotation?: (id: string | null) => void;+ onSelectSpeed?: (id: string | null) => void;+ onSelectAudio?: (id: string | null) => void;+ selectedZoomId: string | null;+ selectedTrimId?: string | null;+ selectedAnnotationId?: string | null;+ selectedSpeedId?: string | null;+ selectedAudioId?: string | null;+ keyframes?: { id: string; time: number }[];}) {const { setTimelineRef, style, sidebarWidth, range, pixelsToValue } = useTimelineContext();const localTimelineRef = useRef<HTMLDivElement | null>(null);@@ -486,12 +508,13 @@ function Timeline({(e: React.MouseEvent<HTMLDivElement>) => {if (!onSeek || videoDurationMs <= 0) return;- // Only clear selection if clicking on empty space (not on items)- // This is handled by event propagation - items stop propagation- onSelectZoom?.(null);- onSelectTrim?.(null);- onSelectAnnotation?.(null);- onSelectSpeed?.(null);+ // Only clear selection if clicking on empty space (not on items)+ // This is handled by event propagation - items stop propagation+ onSelectZoom?.(null);+ onSelectTrim?.(null);+ onSelectAnnotation?.(null);+ onSelectSpeed?.(null);+ onSelectAudio?.(null);const rect = e.currentTarget.getBoundingClientRect();const clickX = e.clientX - rect.left - sidebarWidth;@@ -502,25 +525,14 @@ function Timeline({const absoluteMs = Math.max(0, Math.min(range.start + relativeMs, videoDurationMs));const timeInSeconds = absoluteMs / 1000;- onSeek(timeInSeconds);- },- [- onSeek,- onSelectZoom,- onSelectTrim,- onSelectAnnotation,- onSelectSpeed,- videoDurationMs,- sidebarWidth,- range.start,- pixelsToValue,- ],- );+ onSeek(timeInSeconds);+ }, [onSeek, onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, videoDurationMs, sidebarWidth, range.start, pixelsToValue]);- const zoomItems = items.filter((item) => item.rowId === ZOOM_ROW_ID);- const trimItems = items.filter((item) => item.rowId === TRIM_ROW_ID);- const annotationItems = items.filter((item) => item.rowId === ANNOTATION_ROW_ID);- const speedItems = items.filter((item) => item.rowId === SPEED_ROW_ID);+ const zoomItems = items.filter(item => item.rowId === ZOOM_ROW_ID);+ const trimItems = items.filter(item => item.rowId === TRIM_ROW_ID);+ const annotationItems = items.filter(item => item.rowId === ANNOTATION_ROW_ID);+ const speedItems = items.filter(item => item.rowId === SPEED_ROW_ID);+ const audioItems = items.filter(item => item.rowId === AUDIO_ROW_ID);return (<div@@ -592,58 +604,80 @@ function Timeline({))}</Row>- <Row id={SPEED_ROW_ID} isEmpty={speedItems.length === 0} hint="Press S to add speed">- {speedItems.map((item) => (- <Item- id={item.id}- key={item.id}- rowId={item.rowId}- span={item.span}- isSelected={item.id === selectedSpeedId}- onSelect={() => onSelectSpeed?.(item.id)}- variant="speed"- speedValue={item.speedValue}- >- {item.label}- </Item>- ))}- </Row>- </div>- );+ <Row id={SPEED_ROW_ID} isEmpty={speedItems.length === 0} hint="Press S to add speed">+ {speedItems.map((item) => (+ <Item+ id={item.id}+ key={item.id}+ rowId={item.rowId}+ span={item.span}+ isSelected={item.id === selectedSpeedId}+ onSelect={() => onSelectSpeed?.(item.id)}+ variant="speed"+ speedValue={item.speedValue}+ >+ {item.label}+ </Item>+ ))}+ </Row>++ <Row id={AUDIO_ROW_ID} isEmpty={audioItems.length === 0} hint="Click music icon to add audio">+ {audioItems.map((item) => (+ <Item+ id={item.id}+ key={item.id}+ rowId={item.rowId}+ span={item.span}+ isSelected={item.id === selectedAudioId}+ onSelect={() => onSelectAudio?.(item.id)}+ variant="audio"+ >+ {item.label}+ </Item>+ ))}+ </Row>+ </div>+ );}export default function TimelineEditor({- videoDuration,- currentTime,- onSeek,- cursorTelemetry = [],- zoomRegions,- onZoomAdded,- onZoomSuggested,- onZoomSpanChange,- onZoomDelete,- selectedZoomId,- onSelectZoom,- trimRegions = [],- onTrimAdded,- onTrimSpanChange,- onTrimDelete,- selectedTrimId,- onSelectTrim,- annotationRegions = [],- onAnnotationAdded,- onAnnotationSpanChange,- onAnnotationDelete,- selectedAnnotationId,- onSelectAnnotation,- speedRegions = [],- onSpeedAdded,- onSpeedSpanChange,- onSpeedDelete,- selectedSpeedId,- onSelectSpeed,- aspectRatio,- onAspectRatioChange,+ videoDuration,+ currentTime,+ onSeek,+ cursorTelemetry = [],+ zoomRegions,+ onZoomAdded,+ onZoomSuggested,+ onZoomSpanChange,+ onZoomDelete,+ selectedZoomId,+ onSelectZoom,+ trimRegions = [],+ onTrimAdded,+ onTrimSpanChange,+ onTrimDelete,+ selectedTrimId,+ onSelectTrim,+ annotationRegions = [],+ onAnnotationAdded,+ onAnnotationSpanChange,+ onAnnotationDelete,+ selectedAnnotationId,+ onSelectAnnotation,+ speedRegions = [],+ onSpeedAdded,+ onSpeedSpanChange,+ onSpeedDelete,+ selectedSpeedId,+ onSelectSpeed,+ audioRegions = [],+ onAudioAdded,+ onAudioSpanChange,+ onAudioDelete,+ selectedAudioId,+ onSelectAudio,+ aspectRatio,+ onAspectRatioChange,}: TimelineEditorProps) {const totalMs = useMemo(() => Math.max(0, Math.round(videoDuration * 1000)), [videoDuration]);const currentTimeMs = useMemo(() => Math.round(currentTime * 1000), [currentTime]);@@ -749,6 +783,12 @@ export default function TimelineEditor({onSelectSpeed(null);}, [selectedSpeedId, onSpeedDelete, onSelectSpeed]);+ const deleteSelectedAudio = useCallback(() => {+ if (!selectedAudioId || !onAudioDelete || !onSelectAudio) return;+ onAudioDelete(selectedAudioId);+ onSelectAudio(null);+ }, [selectedAudioId, onAudioDelete, onSelectAudio]);+useEffect(() => {setRange(createInitialRange(totalMs));}, [totalMs]);@@ -759,9 +799,11 @@ export default function TimelineEditor({const zoomRegionsRef = useRef(zoomRegions);const trimRegionsRef = useRef(trimRegions);const speedRegionsRef = useRef(speedRegions);+ const audioRegionsRef = useRef(audioRegions);zoomRegionsRef.current = zoomRegions;trimRegionsRef.current = trimRegions;speedRegionsRef.current = speedRegions;+ audioRegionsRef.current = audioRegions;useEffect(() => {if (totalMs === 0 || safeMinDurationMs <= 0) {@@ -803,8 +845,20 @@ export default function TimelineEditor({onSpeedSpanChange?.(region.id, { start: normalizedStart, end: normalizedEnd });}});++ audioRegionsRef.current.forEach((region) => {+ const clampedStart = Math.max(0, Math.min(region.startMs, totalMs));+ const minEnd = clampedStart + safeMinDurationMs;+ const clampedEnd = Math.min(totalMs, Math.max(minEnd, region.endMs));+ const normalizedStart = Math.max(0, Math.min(clampedStart, totalMs - safeMinDurationMs));+ const normalizedEnd = Math.max(minEnd, Math.min(clampedEnd, totalMs));++ if (normalizedStart !== region.startMs || normalizedEnd !== region.endMs) {+ onAudioSpanChange?.(region.id, { start: normalizedStart, end: normalizedEnd });+ }+ });// Only re-run when the timeline scale changes, not on every region edit- }, [totalMs, safeMinDurationMs, onZoomSpanChange, onTrimSpanChange, onSpeedSpanChange]);+ }, [totalMs, safeMinDurationMs, onZoomSpanChange, onTrimSpanChange, onSpeedSpanChange, onAudioSpanChange]);const hasOverlap = useCallback((newSpan: Span, excludeId?: string): boolean => {// Determine which row the item belongs to@@ -812,13 +866,14 @@ export default function TimelineEditor({const isTrimItem = trimRegions.some(r => r.id === excludeId);const isAnnotationItem = annotationRegions.some(r => r.id === excludeId);const isSpeedItem = speedRegions.some(r => r.id === excludeId);+ const isAudioItem = audioRegions.some(r => r.id === excludeId);if (isAnnotationItem) {return false;}// Helper to check overlap against a specific set of regions- const checkOverlap = (regions: (ZoomRegion | TrimRegion | SpeedRegion)[]) => {+ const checkOverlap = (regions: (ZoomRegion | TrimRegion | SpeedRegion | AudioRegion)[]) => {return regions.some((region) => {if (region.id === excludeId) return false;// True overlap: regions actually intersect (not just adjacent)@@ -838,8 +893,12 @@ export default function TimelineEditor({return checkOverlap(speedRegions);}+ if (isAudioItem) {+ return checkOverlap(audioRegions);+ }+return false;- }, [zoomRegions, trimRegions, annotationRegions, speedRegions]);+ }, [zoomRegions, trimRegions, annotationRegions, speedRegions, audioRegions]);// Keep newly added timeline regions at the original short default instead of// scaling them with the full recording length.@@ -1023,6 +1082,52 @@ export default function TimelineEditor({onSpeedAdded({ start: startPos, end: startPos + actualDuration });}, [videoDuration, totalMs, currentTimeMs, speedRegions, onSpeedAdded, defaultRegionDurationMs]);+ const handleAddAudio = useCallback(async () => {+ if (!videoDuration || videoDuration === 0 || totalMs === 0 || !onAudioAdded) {+ return;+ }++ const result = await (window as any).electronAPI.openAudioFilePicker();+ if (!result?.success || !result.path) {+ return;+ }++ // Load the audio file to get its full duration+ const audioDurationMs = await new Promise<number>((resolve) => {+ const audio = new Audio(`file://${result.path}`);+ audio.addEventListener('loadedmetadata', () => {+ resolve(Math.round(audio.duration * 1000));+ });+ audio.addEventListener('error', () => {+ resolve(0);+ });+ });++ if (audioDurationMs <= 0) {+ toast.error("Could not read audio file", {+ description: "The selected file may be corrupted or in an unsupported format.",+ });+ return;+ }++ const startPos = Math.max(0, Math.min(currentTimeMs, totalMs));+ const sorted = [...audioRegions].sort((a, b) => a.startMs - b.startMs);+ const nextRegion = sorted.find(region => region.startMs > startPos);+ const gapToNext = nextRegion ? nextRegion.startMs - startPos : totalMs - startPos;++ const isOverlapping = sorted.some(region => startPos >= region.startMs && startPos < region.endMs);+ if (isOverlapping || gapToNext <= 0) {+ toast.error("Cannot place audio here", {+ description: "Audio region already exists at this location or not enough space available.",+ });+ return;+ }++ // Use full audio duration, but clamp to available gap and video length+ const actualDuration = Math.min(audioDurationMs, gapToNext, totalMs - startPos);+ onAudioAdded({ start: startPos, end: startPos + actualDuration }, result.path);+ }, [videoDuration, totalMs, currentTimeMs, audioRegions, onAudioAdded]);+const handleAddAnnotation = useCallback(() => {if (!videoDuration || videoDuration === 0 || totalMs === 0 || !onAnnotationAdded) {return;@@ -1096,12 +1201,14 @@ export default function TimelineEditor({deleteSelectedAnnotation();} else if (selectedSpeedId) {deleteSelectedSpeed();+ } else if (selectedAudioId) {+ deleteSelectedAudio();}}};window.addEventListener('keydown', handleKeyDown);return () => window.removeEventListener('keydown', handleKeyDown);- }, [addKeyframe, handleAddZoom, handleAddTrim, handleAddAnnotation, handleAddSpeed, deleteSelectedKeyframe, deleteSelectedZoom, deleteSelectedTrim, deleteSelectedAnnotation, deleteSelectedSpeed, selectedKeyframeId, selectedZoomId, selectedTrimId, selectedAnnotationId, selectedSpeedId, annotationRegions, currentTime, onSelectAnnotation, keyShortcuts, isMac]);+ }, [addKeyframe, handleAddZoom, handleAddTrim, handleAddAnnotation, handleAddSpeed, deleteSelectedKeyframe, deleteSelectedZoom, deleteSelectedTrim, deleteSelectedAnnotation, deleteSelectedSpeed, deleteSelectedAudio, selectedKeyframeId, selectedZoomId, selectedTrimId, selectedAnnotationId, selectedSpeedId, selectedAudioId, annotationRegions, currentTime, onSelectAnnotation, keyShortcuts, isMac]);const clampedRange = useMemo<Range>(() => {if (totalMs === 0) {@@ -1163,16 +1270,25 @@ export default function TimelineEditor({variant: 'speed',}));- return [...zooms, ...trims, ...annotations, ...speeds];- }, [zoomRegions, trimRegions, annotationRegions, speedRegions]);+ const audios: TimelineRenderItem[] = audioRegions.map((region, index) => ({+ id: region.id,+ rowId: AUDIO_ROW_ID,+ span: { start: region.startMs, end: region.endMs },+ label: `Audio ${index + 1}`,+ variant: 'audio',+ }));++ return [...zooms, ...trims, ...annotations, ...speeds, ...audios];+ }, [zoomRegions, trimRegions, annotationRegions, speedRegions, audioRegions]);// Flat list of all non-annotation region spans for neighbour-clamping during drag/resizeconst allRegionSpans = useMemo(() => {const zooms = zoomRegions.map((r) => ({ id: r.id, start: r.startMs, end: r.endMs }));const trims = trimRegions.map((r) => ({ id: r.id, start: r.startMs, end: r.endMs }));const speeds = speedRegions.map((r) => ({ id: r.id, start: r.startMs, end: r.endMs }));- return [...zooms, ...trims, ...speeds];- }, [zoomRegions, trimRegions, speedRegions]);+ const audios = audioRegions.map((r) => ({ id: r.id, start: r.startMs, end: r.endMs }));+ return [...zooms, ...trims, ...speeds, ...audios];+ }, [zoomRegions, trimRegions, speedRegions, audioRegions]);const handleItemSpanChange = useCallback((id: string, span: Span) => {// Check if it's a zoom, trim, speed, or annotation item@@ -1184,8 +1300,10 @@ export default function TimelineEditor({onSpeedSpanChange?.(id, span);} else if (annotationRegions.some(r => r.id === id)) {onAnnotationSpanChange?.(id, span);+ } else if (audioRegions.some(r => r.id === id)) {+ onAudioSpanChange?.(id, span);}- }, [zoomRegions, trimRegions, speedRegions, annotationRegions, onZoomSpanChange, onTrimSpanChange, onSpeedSpanChange, onAnnotationSpanChange]);+ }, [zoomRegions, trimRegions, speedRegions, annotationRegions, audioRegions, onZoomSpanChange, onTrimSpanChange, onSpeedSpanChange, onAnnotationSpanChange, onAudioSpanChange]);const panTimelineRange = useCallback((deltaMs: number) => {if (!Number.isFinite(deltaMs) || deltaMs === 0 || totalMs <= 0) {@@ -1297,6 +1415,15 @@ export default function TimelineEditor({><Gauge className="w-4 h-4" /></Button>+ <Button+ onClick={handleAddAudio}+ variant="ghost"+ size="icon"+ className="h-7 w-7 text-slate-400 hover:text-[#a855f7] hover:bg-[#a855f7]/10 transition-all"+ title="Add Audio"+ >+ <Music className="w-4 h-4" />+ </Button></div><div className="flex items-center gap-2"><DropdownMenu>@@ -1407,10 +1534,12 @@ export default function TimelineEditor({onSelectTrim={onSelectTrim}onSelectAnnotation={onSelectAnnotation}onSelectSpeed={onSelectSpeed}+ onSelectAudio={onSelectAudio}selectedZoomId={selectedZoomId}selectedTrimId={selectedTrimId}selectedAnnotationId={selectedAnnotationId}selectedSpeedId={selectedSpeedId}+ selectedAudioId={selectedAudioId}keyframes={keyframes}/></TimelineWrapper>