I am trying to make a video recording app using electron js as per this video from fireship - https://youtu.be/3yqDxhR2XxE and I'm stuck at building a selection menu of available video sources, as it turned out that the "remote" module has been deprecated. I have 2 js files, one is index.js which is the main electron js file and the other is the render.js file (in which I'm building functions for my app). I tried importing "remote" module in the index.js file but that didn't work. I even set the enableRemoteModule: true in webPreferences in index.js but that too didn't work. Now I am completely out of ideas as a newbie. I heard about the
ipcRenderer and ipcMain modules but not sure they will work.
Below is the code for my "app.js":
//Buttons
const videoElement = document.querySelector('Video');
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const videoSelectBtn = document.getElementById('videoSelectBtn');
videoSelectBtn.onclick = getVideoSources;
const {
desktopCapturer
} = require("electron");
const {
remote
} = require('@electron/remote')
const {
Menu
} = remote
//Getting all available Video Sources
async function getVideoSources() {
const inputSources = await desktopCapturer.getSources({
types: ['window', 'screen']
});
const videoOptionsMenu = Menu.buildFromTemplate(
inputSources.map(source => {
return {
label: source.name,
click: () => selectSource(source)
};
})
);
videoOptionsMenu.popup();
}