From 897f127fbdaaf59075c0237c2456ca3da160921a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 14 Aug 2022 09:01:16 +0200 Subject: [PATCH] Check for audio track count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/video-grid/AudioContainer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video-grid/AudioContainer.tsx b/src/video-grid/AudioContainer.tsx index 067d088..79d2cd0 100644 --- a/src/video-grid/AudioContainer.tsx +++ b/src/video-grid/AudioContainer.tsx @@ -18,6 +18,7 @@ import React, { useEffect, useRef } from "react"; import { Participant } from "../room/InCallView"; import { useCallFeed } from "./useCallFeed"; +import { useMediaStreamTrackCount } from "./useMediaStream"; // XXX: These in fact do not render anything but to my knowledge this is the // only way to a hook on an array @@ -34,12 +35,13 @@ export function AudioForParticipant({ audioDestination, }: AudioForParticipantProps): JSX.Element { const { stream, localVolume, audioMuted } = useCallFeed(item.callFeed); + const [audioTrackCount] = useMediaStreamTrackCount(stream); const gainNodeRef = useRef(); const sourceRef = useRef(); useEffect(() => { - if (!item.isLocal && audioContext && !audioMuted) { + if (!item.isLocal && audioContext && !audioMuted && audioTrackCount > 0) { if (!gainNodeRef.current) { gainNodeRef.current = new GainNode(audioContext, { gain: localVolume,