From 6a7bffc76a4c29f4e530ec8adb4a868e1de46009 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 28 Oct 2023 15:41:54 +0800 Subject: [PATCH] feat: allow patching screenshare with any audio device --- src/renderer/components/ScreenSharePicker.tsx | 42 +++++++++++++++++++ src/renderer/patches/screenShareAudio.ts | 22 +++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 9842afe..4531943 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -20,6 +20,7 @@ import { useState } from "@vencord/types/webpack/common"; import type { Dispatch, SetStateAction } from "react"; +import { patchAudioWithDevice } from "renderer/patches/screenShareAudio"; import { addPatch } from "renderer/patches/shared"; import { isLinux, isWindows } from "renderer/utils"; @@ -37,6 +38,7 @@ interface StreamSettings { audio: boolean; audioSource?: string; workaround?: boolean; + audioDevice?: string; } export interface StreamPick extends StreamSettings { @@ -113,6 +115,9 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { await VesktopNative.virtmic.start([v.audioSource], v.workaround); } } + + patchAudioWithDevice(v.audioDevice); + resolve(v); }} close={() => { @@ -215,6 +220,11 @@ function StreamSettings({ + setSettings(s => ({ ...s, audioDevice: source }))} + /> + {isWindows && ( + navigator.mediaDevices + .enumerateDevices() + .then(devices => devices.filter(device => device.kind === "audioinput")), + { fallbackValue: [] } + ); + + return ( +
+ Audio + {loading && Loading audio devices...} + + {sources.length > 0 && ( +