-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MacOs: properly request microphone and camera permission (#121)
Co-authored-by: V <[email protected]>
- Loading branch information
1 parent
e29d293
commit c445c61
Showing
4 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ dist | |
node_modules | ||
.env | ||
.DS_Store | ||
.idea/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0 | ||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience | ||
* Copyright (c) 2023 Vendicated and Vencord contributors | ||
*/ | ||
|
||
import { session, systemPreferences } from "electron"; | ||
|
||
export function registerMediaPermissionsHandler() { | ||
if (process.platform !== "darwin") return; | ||
|
||
session.defaultSession.setPermissionRequestHandler(async (_webContents, permission, callback, details) => { | ||
let granted = true; | ||
|
||
if (details.mediaTypes?.includes("audio")) { | ||
granted = await systemPreferences.askForMediaAccess("microphone"); | ||
} | ||
if (details.mediaTypes?.includes("video")) { | ||
granted &&= await systemPreferences.askForMediaAccess("camera"); | ||
} | ||
|
||
callback(granted); | ||
}); | ||
} |