From 88962641c4ca2ed78fafb3c392403a14d399d305 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Mon, 8 Apr 2024 14:18:05 +0200 Subject: [PATCH] feat: added mic mute and unmute functionality --- .../production-line/production-line.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/production-line/production-line.tsx b/src/components/production-line/production-line.tsx index f6620d0a..9f004012 100644 --- a/src/components/production-line/production-line.tsx +++ b/src/components/production-line/production-line.tsx @@ -10,15 +10,25 @@ import { useAudioElement } from "./use-audio-element.ts"; import { UserList } from "./user-list.tsx"; import { API } from "../../api/api.ts"; import { noop } from "../../helpers.ts"; +import { MicMuted, MicUnmuted } from "../../icons/icon.tsx"; const TempDiv = styled.div` padding: 1rem; `; + +const UserControlBtn = styled.button` + background-color: transparent; + border-color: transparent; + z-index: 100; + position: relative; +`; + export const ProductionLine: FC = () => { // const { productionId, lineId } = useParams(); const [{ joinProductionOptions }, dispatch] = useGlobalState(); const navigate = useNavigate(); const audioContainerRef = useRef(null); + const [micMute, setMicMute] = useState(true); const [participants, setParticipants] = useState< { name: string; sessionid: string }[] | null >(null); @@ -80,7 +90,18 @@ export const ProductionLine: FC = () => { navigate("/"); }; - // Mute/Unmute mic + useEffect(() => { + const audioTracks = + inputAudioStream !== "no-device" && inputAudioStream !== null + ? inputAudioStream.getAudioTracks() + : null; + + audioTracks?.forEach((track) => { + // eslint-disable-next-line no-param-reassign + track.enabled = !micMute; + }); + }, [inputAudioStream, micMute]); + // Mute/Unmute speaker // Show active sink and mic // Exit button (link to /, clear production from state) @@ -90,6 +111,11 @@ export const ProductionLine: FC = () => { Exit Production View + + setMicMute(!micMute)}> + {micMute ? : } + + {playbackState && ( Audio Playback State: {playbackState}