From fa0a8d30e7dea6c8e728a7b7bcd90035763c6abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 15 Aug 2022 15:11:20 +0200 Subject: [PATCH] Fix audio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/video-grid/useMediaStream.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video-grid/useMediaStream.ts b/src/video-grid/useMediaStream.ts index 75e6697..1c4aa07 100644 --- a/src/video-grid/useMediaStream.ts +++ b/src/video-grid/useMediaStream.ts @@ -35,8 +35,12 @@ declare global { export const useMediaStreamTrackCount = ( stream: MediaStream ): [number, number] => { - const [audioTrackCount, setAudioTrackCount] = useState(0); - const [videoTrackCount, setVideoTrackCount] = useState(0); + const [audioTrackCount, setAudioTrackCount] = useState( + stream.getAudioTracks().length + ); + const [videoTrackCount, setVideoTrackCount] = useState( + stream.getVideoTracks().length + ); const tracksChanged = useCallback(() => { setAudioTrackCount(stream.getAudioTracks().length);