mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import {BrowserWindow, desktopCapturer, DesktopCapturerSource, ipcMain, session, shell} from "electron";
|
|
import path from "path";
|
|
import {iconPath} from "../main";
|
|
var capturerWindow: BrowserWindow;
|
|
function registerCustomHandler() {
|
|
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
|
console.log(request);
|
|
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, width: 9999, height: 9999};
|
|
callback({video: result});
|
|
});
|
|
capturerWindow.loadURL(`file://${__dirname}/picker.html`);
|
|
capturerWindow.webContents.send("getSources", sources);
|
|
});
|
|
}
|
|
registerCustomHandler();
|