fix(preview): mute button not affecting embedded video audio, ensure topmost video track renders above lower tracksmute button not affecting embedded video audio (#529) (#532)

This commit is contained in:
Justin322322
2025-08-09 23:39:24 +02:00
committed by GitHub
parent 8c205273b7
commit e908bad167
2 changed files with 9 additions and 4 deletions
@@ -234,7 +234,8 @@ export function PreviewPanel() {
const getActiveElements = (): ActiveElement[] => { const getActiveElements = (): ActiveElement[] => {
const activeElements: ActiveElement[] = []; const activeElements: ActiveElement[] = [];
tracks.forEach((track) => { // Iterate tracks from bottom to top so topmost track renders last (on top)
;[...tracks].reverse().forEach((track) => {
track.elements.forEach((element) => { track.elements.forEach((element) => {
if (element.hidden) return; if (element.hidden) return;
const elementStart = element.startTime; const elementStart = element.startTime;
@@ -311,6 +312,7 @@ export function PreviewPanel() {
trimEnd={element.trimEnd} trimEnd={element.trimEnd}
clipDuration={element.duration} clipDuration={element.duration}
className="w-full h-full object-cover" className="w-full h-full object-cover"
trackMuted={true}
/> />
</div> </div>
); );
@@ -434,6 +436,7 @@ export function PreviewPanel() {
trimStart={element.trimStart} trimStart={element.trimStart}
trimEnd={element.trimEnd} trimEnd={element.trimEnd}
clipDuration={element.duration} clipDuration={element.duration}
trackMuted={elementData.track.muted}
/> />
</div> </div>
); );
@@ -459,7 +462,7 @@ export function PreviewPanel() {
// Audio elements (no visual representation) // Audio elements (no visual representation)
if (mediaItem.type === "audio") { if (mediaItem.type === "audio") {
return ( return (
<div key={element.id} className="absolute inset-0"> <div key={element.id} className="absolute inset-0" style={{ pointerEvents: "none" }}>
<AudioPlayer <AudioPlayer
src={mediaItem.url!} src={mediaItem.url!}
clipStartTime={element.startTime} clipStartTime={element.startTime}
+4 -2
View File
@@ -11,6 +11,7 @@ interface VideoPlayerProps {
trimStart: number; trimStart: number;
trimEnd: number; trimEnd: number;
clipDuration: number; clipDuration: number;
trackMuted?: boolean;
} }
export function VideoPlayer({ export function VideoPlayer({
@@ -21,6 +22,7 @@ export function VideoPlayer({
trimStart, trimStart,
trimEnd, trimEnd,
clipDuration, clipDuration,
trackMuted = false,
}: VideoPlayerProps) { }: VideoPlayerProps) {
const videoRef = useRef<HTMLVideoElement>(null); const videoRef = useRef<HTMLVideoElement>(null);
const { isPlaying, currentTime, volume, speed, muted } = usePlaybackStore(); const { isPlaying, currentTime, volume, speed, muted } = usePlaybackStore();
@@ -109,9 +111,9 @@ export function VideoPlayer({
if (!video) return; if (!video) return;
video.volume = volume; video.volume = volume;
video.muted = muted; video.muted = muted || trackMuted;
video.playbackRate = speed; video.playbackRate = speed;
}, [volume, speed, muted]); }, [volume, speed, muted, trackMuted]);
return ( return (
<video <video