fix: Windows audio mute fix
This commit is contained in:
@@ -210,6 +210,39 @@ export async function createWindow(): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
session.defaultSession.setDisplayMediaRequestHandler(
|
||||||
|
async (request, respond) => {
|
||||||
|
// On Windows the system picker (useSystemPicker: true) is preferred.
|
||||||
|
// This handler is only reached when the system picker is unavailable.
|
||||||
|
// Include loopback audio when the renderer requested it so that
|
||||||
|
// getDisplayMedia receives an audio track and the renderer-side
|
||||||
|
// restrictOwnAudio constraint can keep the app's own voice playback
|
||||||
|
// out of the captured stream.
|
||||||
|
try {
|
||||||
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ['window', 'screen'],
|
||||||
|
thumbnailSize: { width: 150, height: 150 }
|
||||||
|
});
|
||||||
|
const firstSource = sources[0];
|
||||||
|
|
||||||
|
if (firstSource) {
|
||||||
|
respond({
|
||||||
|
video: firstSource,
|
||||||
|
...(request.audioRequested ? { audio: 'loopback' } : {})
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// desktopCapturer also unavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
respond({});
|
||||||
|
},
|
||||||
|
{ useSystemPicker: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env['NODE_ENV'] === 'development') {
|
if (process.env['NODE_ENV'] === 'development') {
|
||||||
const devUrl = process.env['SSL'] === 'true'
|
const devUrl = process.env['SSL'] === 'true'
|
||||||
? 'https://localhost:4200'
|
? 'https://localhost:4200'
|
||||||
|
|||||||
@@ -49,9 +49,19 @@ export class DesktopElectronScreenShareCapture {
|
|||||||
|
|
||||||
const sources = await electronApi.getSources();
|
const sources = await electronApi.getSources();
|
||||||
const selection = await this.resolveSourceSelection(sources, options.includeSystemAudio);
|
const selection = await this.resolveSourceSelection(sources, options.includeSystemAudio);
|
||||||
|
|
||||||
|
// On Windows, electron-desktop loopback audio captures all system output
|
||||||
|
// including the app's voice playback, creating echo for watchers or
|
||||||
|
// requiring total voice muting for the sharer. The getDisplayMedia path
|
||||||
|
// handles this correctly via restrictOwnAudio — if we fell back here,
|
||||||
|
// share video only so voice chat stays functional.
|
||||||
|
const effectiveIncludeSystemAudio = this.isWindowsElectron()
|
||||||
|
? false
|
||||||
|
: selection.includeSystemAudio;
|
||||||
|
|
||||||
const captureOptions = {
|
const captureOptions = {
|
||||||
...options,
|
...options,
|
||||||
includeSystemAudio: selection.includeSystemAudio
|
includeSystemAudio: effectiveIncludeSystemAudio
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!selection.source) {
|
if (!selection.source) {
|
||||||
@@ -59,7 +69,7 @@ export class DesktopElectronScreenShareCapture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.info('Selected Electron desktop source', {
|
this.logger.info('Selected Electron desktop source', {
|
||||||
includeSystemAudio: selection.includeSystemAudio,
|
includeSystemAudio: effectiveIncludeSystemAudio,
|
||||||
sourceId: selection.source.id,
|
sourceId: selection.source.id,
|
||||||
sourceName: selection.source.name
|
sourceName: selection.source.name
|
||||||
});
|
});
|
||||||
@@ -73,7 +83,7 @@ export class DesktopElectronScreenShareCapture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
includeSystemAudio: selection.includeSystemAudio,
|
includeSystemAudio: effectiveIncludeSystemAudio,
|
||||||
stream: await navigator.mediaDevices.getUserMedia(constraints)
|
stream: await navigator.mediaDevices.getUserMedia(constraints)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user