From 76f69125118ebae51e48c64873ab63c143c2349a Mon Sep 17 00:00:00 2001 From: Masterjoona <69722179+Masterjoona@users.noreply.github.com> Date: Wed, 19 Jun 2024 21:04:39 +0300 Subject: [PATCH] VoiceMessages: properly respect user's microphone choice (#2602) --- src/plugins/voiceMessages/DesktopRecorder.tsx | 2 ++ src/plugins/voiceMessages/WebRecorder.tsx | 2 ++ src/plugins/voiceMessages/utils.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/plugins/voiceMessages/DesktopRecorder.tsx b/src/plugins/voiceMessages/DesktopRecorder.tsx index a69739a4..18581ad1 100644 --- a/src/plugins/voiceMessages/DesktopRecorder.tsx +++ b/src/plugins/voiceMessages/DesktopRecorder.tsx @@ -21,6 +21,7 @@ import { Button, showToast, Toasts, useState } from "@webpack/common"; import type { VoiceRecorder } from "."; import { settings } from "./settings"; +import { MediaEngineStore } from "./utils"; const Native = VencordNative.pluginHelpers.VoiceMessages as PluginNative; @@ -41,6 +42,7 @@ export const VoiceRecorderDesktop: VoiceRecorder = ({ setAudioBlob, onRecordingC { echoCancellation: settings.store.echoCancellation, noiseCancellation: settings.store.noiseSuppression, + deviceId: MediaEngineStore.getInputDeviceId(), }, (success: boolean) => { if (success) diff --git a/src/plugins/voiceMessages/WebRecorder.tsx b/src/plugins/voiceMessages/WebRecorder.tsx index 423a2699..eb77b199 100644 --- a/src/plugins/voiceMessages/WebRecorder.tsx +++ b/src/plugins/voiceMessages/WebRecorder.tsx @@ -20,6 +20,7 @@ import { Button, useState } from "@webpack/common"; import type { VoiceRecorder } from "."; import { settings } from "./settings"; +import { MediaEngineStore } from "./utils"; export const VoiceRecorderWeb: VoiceRecorder = ({ setAudioBlob, onRecordingChange }) => { const [recording, setRecording] = useState(false); @@ -40,6 +41,7 @@ export const VoiceRecorderWeb: VoiceRecorder = ({ setAudioBlob, onRecordingChang audio: { echoCancellation: settings.store.echoCancellation, noiseSuppression: settings.store.noiseSuppression, + deviceId: MediaEngineStore.getInputDeviceId() } }).then(stream => { const chunks = [] as Blob[]; diff --git a/src/plugins/voiceMessages/utils.ts b/src/plugins/voiceMessages/utils.ts index dcfd6f26..ef571bbf 100644 --- a/src/plugins/voiceMessages/utils.ts +++ b/src/plugins/voiceMessages/utils.ts @@ -17,5 +17,7 @@ */ import { classNameFactory } from "@api/Styles"; +import { findStoreLazy } from "@webpack"; +export const MediaEngineStore = findStoreLazy("MediaEngineStore"); export const cl = classNameFactory("vc-vmsg-");