fix: use getMediaSourceId() for exact window capture

Instead of enumerating all sources and matching by title (which falls
back to full screen capture), use BrowserWindow.getMediaSourceId() to
get the exact media source ID for the app window.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Administrator 2026-03-12 08:52:22 +01:00
parent c9d038d588
commit b4211a7d50
2 changed files with 8 additions and 3 deletions

View File

@ -1090,11 +1090,16 @@ ipcMain.handle('remote:get-capture-source-id', async () => {
debugLog('remote: capture source - mainWindow not available'); debugLog('remote: capture source - mainWindow not available');
return null; return null;
} }
// Use getMediaSourceId() for exact window capture without enumeration
const sourceId = mainWindow.getMediaSourceId();
debugLog('remote: capture source - getMediaSourceId:', sourceId);
if (sourceId) return sourceId;
// Fallback: enumerate sources
const { desktopCapturer } = require('electron'); const { desktopCapturer } = require('electron');
const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] }); const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] });
const title = mainWindow.getTitle(); const title = mainWindow.getTitle();
debugLog('remote: capture source - looking for title:', title, 'available:', sources.map(s => s.name).join(', ')); debugLog('remote: capture source - fallback, looking for title:', title);
// Try exact title match first, then partial match, then fall back to first screen
let source = sources.find(s => s.name === title); let source = sources.find(s => s.name === title);
if (!source) source = sources.find(s => s.name.includes('Multi-Hoster')); if (!source) source = sources.find(s => s.name.includes('Multi-Hoster'));
if (!source) source = sources.find(s => s.id.startsWith('screen:')); if (!source) source = sources.find(s => s.id.startsWith('screen:'));

View File

@ -1,6 +1,6 @@
{ {
"name": "multi-hoster-uploader", "name": "multi-hoster-uploader",
"version": "2.1.6", "version": "2.1.7",
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously", "description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {