From 037ef691255a81eef14f1712c7f8f03773abba87 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 cd2fc6cba..47c0fc475 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"; @@ -36,6 +37,7 @@ interface StreamSettings { fps: StreamFps; audio: boolean; audioSource?: string; + audioDevice?: string; } export interface StreamPick extends StreamSettings { @@ -109,6 +111,9 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { await VesktopNative.virtmic.start([v.audioSource]); } } + + patchAudioWithDevice(v.audioDevice); + resolve(v); }} close={() => { @@ -211,6 +216,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 && ( +