From 71b6718337ec24ce8791ef039c7dd08ced81e974 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 13 Aug 2025 00:52:19 +0200 Subject: feat: implement mute video tracks --- .../editor/timeline/timeline-element.tsx | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'apps/web/src/components/editor/timeline') diff --git a/apps/web/src/components/editor/timeline/timeline-element.tsx b/apps/web/src/components/editor/timeline/timeline-element.tsx index b26a14bb..f2623161 100644 --- a/apps/web/src/components/editor/timeline/timeline-element.tsx +++ b/apps/web/src/components/editor/timeline/timeline-element.tsx @@ -50,6 +50,7 @@ export function TimelineElement({ replaceElementMedia, rippleEditingEnabled, toggleElementHidden, + toggleElementMuted, } = useTimelineStore(); const { currentTime } = usePlaybackStore(); @@ -57,7 +58,7 @@ export function TimelineElement({ element.type === "media" ? mediaItems.find((item) => item.id === element.mediaId) : null; - const isAudio = mediaItem?.type === "audio"; + const hasAudio = mediaItem?.type === "audio" || mediaItem?.type === "video"; const { resizing, handleResizeStart, handleResizeMove, handleResizeEnd } = useTimelineElementResize({ @@ -124,8 +125,12 @@ export function TimelineElement({ } }; - const handleToggleElementHidden = (e: React.MouseEvent) => { + const handleToggleElementContext = (e: React.MouseEvent) => { e.stopPropagation(); + if (hasAudio && element.type === "media") { + toggleElementMuted(track.id, element.id); + return; + } toggleElementHidden(track.id, element.id); }; @@ -246,6 +251,8 @@ export function TimelineElement({ } }; + const isMuted = element.type === "media" ? element.muted === true : false; + return ( @@ -279,9 +286,9 @@ export function TimelineElement({ {renderElementContent()} - {element.hidden && ( + {(hasAudio ? isMuted : element.hidden) && (
- {isAudio ? ( + {hasAudio ? ( ) : ( @@ -309,9 +316,9 @@ export function TimelineElement({ Split at playhead - - {isAudio ? ( - element.hidden ? ( + + {hasAudio ? ( + isMuted ? ( ) : ( @@ -322,8 +329,8 @@ export function TimelineElement({ )} - {isAudio - ? element.hidden + {hasAudio + ? isMuted ? "Unmute" : "Mute" : element.hidden -- cgit v1.3.1