From 66eb6f13d52edfd7497d40315f16e490268632f4 Mon Sep 17 00:00:00 2001 From: DevloperAmanSingh Date: Wed, 25 Jun 2025 13:27:39 +0530 Subject: [PATCH] feat(preview-panel): add volume control and mute functionality to the video player --- .../src/components/editor/preview-panel.tsx | 67 ++++++++++++++----- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/apps/web/src/components/editor/preview-panel.tsx b/apps/web/src/components/editor/preview-panel.tsx index 624a549..33bfe68 100644 --- a/apps/web/src/components/editor/preview-panel.tsx +++ b/apps/web/src/components/editor/preview-panel.tsx @@ -5,16 +5,17 @@ import { useMediaStore } from "@/stores/media-store"; import { usePlaybackStore } from "@/stores/playback-store"; import { VideoPlayer } from "@/components/ui/video-player"; import { Button } from "@/components/ui/button"; -import { Play, Pause } from "lucide-react"; +import { Play, Pause, Volume2, VolumeX } from "lucide-react"; import { useState, useRef } from "react"; // Debug flag - set to false to hide active clips info -const SHOW_DEBUG_INFO = process.env.NODE_ENV === 'development'; +const SHOW_DEBUG_INFO = process.env.NODE_ENV === "development"; export function PreviewPanel() { const { tracks } = useTimelineStore(); const { mediaItems } = useMediaStore(); - const { isPlaying, toggle, currentTime } = usePlaybackStore(); + const { isPlaying, toggle, currentTime, muted, toggleMute, volume } = + usePlaybackStore(); const [canvasSize, setCanvasSize] = useState({ width: 1920, height: 1080 }); const [showDebug, setShowDebug] = useState(SHOW_DEBUG_INFO); const previewRef = useRef(null); @@ -30,12 +31,14 @@ export function PreviewPanel() { tracks.forEach((track) => { track.clips.forEach((clip) => { const clipStart = clip.startTime; - const clipEnd = clip.startTime + (clip.duration - clip.trimStart - clip.trimEnd); + const clipEnd = + clip.startTime + (clip.duration - clip.trimStart - clip.trimEnd); if (currentTime >= clipStart && currentTime < clipEnd) { - const mediaItem = clip.mediaId === "test" - ? { type: "test", name: clip.name, url: "", thumbnailUrl: "" } - : mediaItems.find((item) => item.id === clip.mediaId); + const mediaItem = + clip.mediaId === "test" + ? { type: "test", name: clip.name, url: "", thumbnailUrl: "" } + : mediaItems.find((item) => item.id === clip.mediaId); if (mediaItem || clip.mediaId === "test") { activeClips.push({ clip, track, mediaItem }); @@ -134,13 +137,19 @@ export function PreviewPanel() {