From 471d90982261e086cc1d04bc06427900d2d93497 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Tue, 9 Apr 2024 13:35:14 +0200 Subject: [PATCH] fix: updated mic-mute toggle --- src/components/production-line/production-line.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/production-line/production-line.tsx b/src/components/production-line/production-line.tsx index 8bc509b1..475625fa 100644 --- a/src/components/production-line/production-line.tsx +++ b/src/components/production-line/production-line.tsx @@ -22,7 +22,8 @@ const UserControlBtn = styled.button` export const ProductionLine: FC = () => { // const { productionId, lineId } = useParams(); - const [{ joinProductionOptions, audioInput }, dispatch] = useGlobalState(); + const [{ joinProductionOptions, mediaStreamInput }, dispatch] = + useGlobalState(); const navigate = useNavigate(); const audioContainerRef = useRef(null); const [micMute, setMicMute] = useState(true); @@ -83,10 +84,13 @@ export const ProductionLine: FC = () => { }; useEffect(() => { - if (audioInput) { - audioInput.enabled = !micMute; + if (mediaStreamInput) { + mediaStreamInput.getTracks().forEach((track) => { + // eslint-disable-next-line no-param-reassign + track.enabled = !micMute; + }); } - }, [audioInput, micMute]); + }, [mediaStreamInput, micMute]); // Mute/Unmute speaker // Show active sink and mic