Skip to content

Commit

Permalink
feat: added speaker-mute as a hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 authored and martinstark committed Apr 26, 2024
1 parent 49854f0 commit de8b4dc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -151,6 +151,11 @@ export const ProductionLine: FC = () => {
setIsOutputMuted(!isOutputMuted);
}, [audioElements, isOutputMuted]);

useSpeakerHotkeys({
muteOutput,
isOutputMuted,
});

const line = useLinePolling({ joinProductionOptions });

const { production, error: fetchProductionError } = useFetchProduction(
Expand Down Expand Up @@ -289,6 +294,9 @@ export const ProductionLine: FC = () => {
<TempDiv>
<strong>M:</strong> Toggle Input Mute
</TempDiv>
<TempDiv>
<strong>N:</strong> Toggle Output Mute
</TempDiv>
<TempDiv>
<strong>T:</strong> Push to Talk
</TempDiv>
Expand Down
21 changes: 19 additions & 2 deletions src/components/production-line/use-line-hotkeys.ts
Original file line number Diff line number Diff line change
@@ -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);
});
Expand All @@ -25,3 +33,12 @@ export const useLineHotkeys = ({ muteInput, isInputMuted }: TProps) => {
}
);
};

export const useSpeakerHotkeys = ({
muteOutput,
isOutputMuted,
}: TuseSpeakerHotkeys) => {
useHotkeys("n", () => {
muteOutput(!isOutputMuted);
});
};

0 comments on commit de8b4dc

Please sign in to comment.