Fix: Screen Capture in Electron App aktivieren
setDisplayMediaRequestHandler hinzugefügt damit getDisplayMedia in der Electron App funktioniert (Streaming/Bildschirmfreigabe). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0646a1b46e
commit
c8799710ac
1 changed files with 8 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
const { app, BrowserWindow, session, shell } = require('electron');
|
const { app, BrowserWindow, session, shell, desktopCapturer } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { setupAdBlocker } = require('./ad-blocker');
|
const { setupAdBlocker } = require('./ad-blocker');
|
||||||
|
|
||||||
|
|
@ -33,6 +33,13 @@ function createWindow() {
|
||||||
// Setup ad blocker BEFORE loading URL
|
// Setup ad blocker BEFORE loading URL
|
||||||
setupAdBlocker(session.defaultSession);
|
setupAdBlocker(session.defaultSession);
|
||||||
|
|
||||||
|
// Enable screen capture (getDisplayMedia) in Electron
|
||||||
|
session.defaultSession.setDisplayMediaRequestHandler((_request, callback) => {
|
||||||
|
desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => {
|
||||||
|
callback({ video: sources[0], audio: 'loopback' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Custom User-Agent to identify Electron app
|
// Custom User-Agent to identify Electron app
|
||||||
const currentUA = mainWindow.webContents.getUserAgent();
|
const currentUA = mainWindow.webContents.getUserAgent();
|
||||||
mainWindow.webContents.setUserAgent(currentUA + ' GamingHubDesktop/1.5.0');
|
mainWindow.webContents.setUserAgent(currentUA + ' GamingHubDesktop/1.5.0');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue