mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Tweak screensharing
This commit is contained in:
parent
8e16371521
commit
334d28542f
2 changed files with 32 additions and 35 deletions
|
@ -2,36 +2,35 @@ import {BrowserWindow, desktopCapturer, ipcMain, session, shell} from "electron"
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {iconPath} from "../main";
|
import {iconPath} from "../main";
|
||||||
var capturerWindow: BrowserWindow;
|
var capturerWindow: BrowserWindow;
|
||||||
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
function registerCustomHandler() {
|
||||||
const sources = await desktopCapturer.getSources({
|
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
||||||
types: ["screen", "window"]
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ["screen", "window"]
|
||||||
|
});
|
||||||
|
console.log(sources);
|
||||||
|
capturerWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
title: "ArmCord Screenshare",
|
||||||
|
darkTheme: true,
|
||||||
|
icon: iconPath,
|
||||||
|
frame: true,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
webPreferences: {
|
||||||
|
sandbox: false,
|
||||||
|
spellcheck: false,
|
||||||
|
preload: path.join(__dirname, "preload.js")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ipcMain.once("selectScreenshareSource", (event, id, name) => {
|
||||||
|
console.log(sources[id]);
|
||||||
|
console.log(id);
|
||||||
|
capturerWindow.close();
|
||||||
|
var result = {id, name};
|
||||||
|
callback({video: result});
|
||||||
|
});
|
||||||
|
capturerWindow.loadURL(`file://${__dirname}/picker.html`);
|
||||||
|
capturerWindow.webContents.send("getSources", sources);
|
||||||
});
|
});
|
||||||
console.log(sources);
|
}
|
||||||
capturerWindow = new BrowserWindow({
|
registerCustomHandler();
|
||||||
width: 800,
|
|
||||||
height: 600,
|
|
||||||
title: "ArmCord Screenshare",
|
|
||||||
darkTheme: true,
|
|
||||||
icon: iconPath,
|
|
||||||
frame: true,
|
|
||||||
autoHideMenuBar: true,
|
|
||||||
webPreferences: {
|
|
||||||
sandbox: false,
|
|
||||||
spellcheck: false,
|
|
||||||
preload: path.join(__dirname, "preload.js")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ipcMain.on("selectScreenshareSource", (event, id, name) => {
|
|
||||||
console.log(sources[id]);
|
|
||||||
console.log(id);
|
|
||||||
callback({video: {id, name}});
|
|
||||||
|
|
||||||
capturerWindow.close();
|
|
||||||
});
|
|
||||||
capturerWindow.webContents.setWindowOpenHandler(({url}) => {
|
|
||||||
shell.openExternal(url);
|
|
||||||
return {action: "deny"};
|
|
||||||
});
|
|
||||||
capturerWindow.loadURL(`file://${__dirname}/picker.html`);
|
|
||||||
capturerWindow.webContents.send("getSources", sources);
|
|
||||||
});
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ interface IPCSources {
|
||||||
thumbnail: HTMLCanvasElement;
|
thumbnail: HTMLCanvasElement;
|
||||||
}
|
}
|
||||||
async function addDisplays() {
|
async function addDisplays() {
|
||||||
ipcRenderer.on("getSources", (event, arg) => {
|
ipcRenderer.once("getSources", (event, arg) => {
|
||||||
var sources: IPCSources[] = arg;
|
var sources: IPCSources[] = arg;
|
||||||
console.log(sources);
|
console.log(sources);
|
||||||
const selectionElem = document.createElement("div");
|
const selectionElem = document.createElement("div");
|
||||||
|
@ -45,8 +45,6 @@ async function addDisplays() {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} finally {
|
|
||||||
ipcRenderer.sendSync("closeScreenshareWindow");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue