Skip to content

Commit f64b012

Browse files
committed
fix microphone permission issue
1 parent fa20815 commit f64b012

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/platform/mac/permissions.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,28 @@ export const permissions: Permissions = {
8585
async requestMicrophone(): Promise<boolean> {
8686
logger.info('Requesting microphone permission...');
8787
try {
88-
const granted = await systemPreferences.askForMediaAccess('microphone');
89-
logger.info(`Microphone permission request result: ${granted ? 'granted' : 'denied'}`);
90-
return granted;
88+
// Check current status first
89+
const status = systemPreferences.getMediaAccessStatus('microphone');
90+
logger.info(`Current microphone permission status: ${status}`);
91+
92+
if (status === 'granted') {
93+
return true;
94+
}
95+
96+
if (status === 'not-determined') {
97+
// First time request - system dialog will appear
98+
const granted = await systemPreferences.askForMediaAccess('microphone');
99+
logger.info(`Microphone permission request result: ${granted ? 'granted' : 'denied'}`);
100+
return granted;
101+
}
102+
103+
// Status is 'denied' or 'restricted' - must open System Preferences
104+
// askForMediaAccess won't show a dialog in this case
105+
logger.info('Microphone permission denied/restricted, opening System Preferences...');
106+
await execAsync(
107+
'open "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone"'
108+
);
109+
return false;
91110
} catch (error) {
92111
logger.error('Failed to request microphone permission:', error);
93112
return false;

src/renderer/renderer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type RendererElectronAPI = {
66
checkPermissions: () => Promise<{
77
screenRecording: boolean;
88
accessibility: boolean;
9+
microphone: boolean;
910
}>;
1011
requestPermissions: () => Promise<void>;
1112
startRecording: (config: RecordingConfig) => Promise<{ success: boolean }>;

0 commit comments

Comments
 (0)