0

I am working on an Electron app that utilizes the desktopCapturer module to fetch sources (both windows and screens), I now need assistance in detecting when new sources are added or existing ones are removed dynamically.

Here's a snippet of my current implementation:

app.on('ready', async () => {
  createWindow()

  win?.webContents.on('did-finish-load', () => {
    try {
      desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
        win?.webContents.send('sources', sources);
      })
    } catch (error) {
      console.log('error getting sources', error);
    }
  });

});

Any help or code examples would be immensely beneficial. Thanks in advance!

0

Browse other questions tagged or ask your own question.