diff --git a/src/video-grid/useMediaStream.ts b/src/video-grid/useMediaStream.ts index 236361f..d6a7e41 100644 --- a/src/video-grid/useMediaStream.ts +++ b/src/video-grid/useMediaStream.ts @@ -34,8 +34,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);