fix: Add microphone permission handlers for Electron
Added session.setPermissionRequestHandler and setPermissionCheckHandler to automatically grant media/audio capture permissions. This fixes the "could not start audio source" error when trying to start recording. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
const { app, BrowserWindow, ipcMain } = require("electron");
|
const { app, BrowserWindow, ipcMain, session } = require("electron");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { spawn } = require("child_process");
|
const { spawn } = require("child_process");
|
||||||
@@ -445,6 +445,24 @@ app.whenReady().then(async () => {
|
|||||||
// Load configuration first
|
// Load configuration first
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
|
// Grant microphone permission automatically
|
||||||
|
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||||
|
const allowedPermissions = ['media', 'mediaKeySystem', 'audioCapture'];
|
||||||
|
if (allowedPermissions.includes(permission)) {
|
||||||
|
console.log(`Granting permission: ${permission}`);
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
console.log(`Denying permission: ${permission}`);
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Also handle permission check (for some Electron versions)
|
||||||
|
session.defaultSession.setPermissionCheckHandler((webContents, permission) => {
|
||||||
|
const allowedPermissions = ['media', 'mediaKeySystem', 'audioCapture'];
|
||||||
|
return allowedPermissions.includes(permission);
|
||||||
|
});
|
||||||
|
|
||||||
// Start backend sidecar if embedded mode is enabled
|
// Start backend sidecar if embedded mode is enabled
|
||||||
startBackendSidecar();
|
startBackendSidecar();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user