From de8b4dcd8c9e36868b3ca2454819f4b7ed919949 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Fri, 26 Apr 2024 16:34:27 +0200 Subject: [PATCH] feat: added speaker-mute as a hotkey --- .../production-line/production-line.tsx | 10 ++++++++- .../production-line/use-line-hotkeys.ts | 21 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/production-line/production-line.tsx b/src/components/production-line/production-line.tsx index 3a64f328..ef194e9f 100644 --- a/src/components/production-line/production-line.tsx +++ b/src/components/production-line/production-line.tsx @@ -20,7 +20,7 @@ import { useHeartbeat } from "./use-heartbeat.ts"; import { JoinProduction } from "../landing-page/join-production.tsx"; import { useDeviceLabels } from "./use-device-labels.ts"; import { isMobile } from "../../bowser.ts"; -import { useLineHotkeys } from "./use-line-hotkeys.ts"; +import { useLineHotkeys, useSpeakerHotkeys } from "./use-line-hotkeys.ts"; import { LongPressToTalkButton } from "./long-press-to-talk-button.tsx"; import { useLinePolling } from "./use-line-polling.ts"; import { useFetchProduction } from "../landing-page/use-fetch-production.ts"; @@ -151,6 +151,11 @@ export const ProductionLine: FC = () => { setIsOutputMuted(!isOutputMuted); }, [audioElements, isOutputMuted]); + useSpeakerHotkeys({ + muteOutput, + isOutputMuted, + }); + const line = useLinePolling({ joinProductionOptions }); const { production, error: fetchProductionError } = useFetchProduction( @@ -289,6 +294,9 @@ export const ProductionLine: FC = () => { M: Toggle Input Mute + + N: Toggle Output Mute + T: Push to Talk diff --git a/src/components/production-line/use-line-hotkeys.ts b/src/components/production-line/use-line-hotkeys.ts index b4b468c4..48680349 100644 --- a/src/components/production-line/use-line-hotkeys.ts +++ b/src/components/production-line/use-line-hotkeys.ts @@ -1,11 +1,19 @@ import { useHotkeys } from "react-hotkeys-hook"; -type TProps = { +type TuseLineHotkeys = { muteInput: (mute: boolean) => void; isInputMuted: boolean; }; -export const useLineHotkeys = ({ muteInput, isInputMuted }: TProps) => { +type TuseSpeakerHotkeys = { + muteOutput: (mute: boolean) => void; + isOutputMuted: boolean; +}; + +export const useLineHotkeys = ({ + muteInput, + isInputMuted, +}: TuseLineHotkeys) => { useHotkeys("m", () => { muteInput(!isInputMuted); }); @@ -25,3 +33,12 @@ export const useLineHotkeys = ({ muteInput, isInputMuted }: TProps) => { } ); }; + +export const useSpeakerHotkeys = ({ + muteOutput, + isOutputMuted, +}: TuseSpeakerHotkeys) => { + useHotkeys("n", () => { + muteOutput(!isOutputMuted); + }); +};