From 605c3752e3b10131eb0c7a21bcc9f918fe8b4705 Mon Sep 17 00:00:00 2001 From: Arnei Date: Mon, 3 Jun 2024 09:53:33 +0200 Subject: [PATCH] Fix editor not playing audio due to video order If the editor has multiple videos, it will consider one of them the "primary" video, from which it will play back audio. Even if that "primary" video does not have any audio. This changes the logic so that the first video with audio the editor comes across is made the "primary" video, so that there should always be audio playing if audio is available. --- src/main/VideoPlayers.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/VideoPlayers.tsx b/src/main/VideoPlayers.tsx index 0eb23d6e8..a72986601 100644 --- a/src/main/VideoPlayers.tsx +++ b/src/main/VideoPlayers.tsx @@ -21,6 +21,7 @@ import { setJumpTriggered, selectJumpTriggered, setCurrentlyAt, + selectVideos, } from "../redux/videoSlice"; import ReactPlayer, { Config } from "react-player"; @@ -50,7 +51,9 @@ const VideoPlayers: React.FC<{ maxHeightInPixel = 300, }) => { - const videoURLs = useAppSelector(selectVideoURL); + const videos = useAppSelector(selectVideos); + let primaryIndex = videos.findIndex(e => e.audio_stream.available === true); + primaryIndex = primaryIndex < 0 ? 0 : primaryIndex; const videoCount = useAppSelector(selectVideoCount); const videoPlayerAreaStyle = css({ @@ -71,8 +74,8 @@ const VideoPlayers: React.FC<{