diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 9842afe..86c85ed 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 { patchDisplayMedia } from "renderer/patches/screenSharePatch"; import { addPatch } from "renderer/patches/shared"; import { isLinux, isWindows } from "renderer/utils"; @@ -37,10 +38,12 @@ interface StreamSettings { audio: boolean; audioSource?: string; workaround?: boolean; + audioDevice?: string; } export interface StreamPick extends StreamSettings { id: string; + cameraId?: string; } interface Source { @@ -49,6 +52,11 @@ interface Source { url: string; } +interface Camera { + id: string; + name: string; +} + let currentSettings: StreamSettings | null = null; addPatch({ @@ -98,6 +106,7 @@ if (isLinux) { export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { let didSubmit = false; + return new Promise((resolve, reject) => { const key = openModal( props => ( @@ -106,14 +115,24 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { modalProps={props} submit={async v => { didSubmit = true; + if (v.audioSource && v.audioSource !== "None") { - if (v.audioSource === "Entire System") { - await VesktopNative.virtmic.startSystem(v.workaround); - } else { - await VesktopNative.virtmic.start([v.audioSource], v.workaround); + if (!v.audioDevice && v.audioSource && v.audioSource !== "None") { + if (v.audioSource === "Entire System") { + await VesktopNative.virtmic.startSystem(v.workaround); + } else { + await VesktopNative.virtmic.start([v.audioSource], v.workaround); + } } + + patchDisplayMedia({ + audioId: v.audioDevice, + venmic: !!v.audioSource && v.audioSource !== "None", + videoId: v.cameraId + }); + + resolve(v); } - resolve(v); }} close={() => { props.onClose(); @@ -132,12 +151,26 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { }); } -function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScreen: (id: string) => void }) { +function ScreenPicker({ + screens, + chooseScreen, + isDisabled = false +}: { + screens: Source[]; + chooseScreen: (id: string) => void; + isDisabled?: boolean; +}) { return (
{screens.map(({ id, name, url }) => (