Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This file exposes the desktopCapturer module of electron to the renderer
- */
- const { desktopCapturer } = require('electron')
- /**
- * getSources - List the sources avaliable according to options
- *
- * @param {Object} options The type of source to capture
- * @return {Promise} A promise that resolves into an array of DesktopCapturerSources or rejects an error
- */
- function getSources(options) {
- return new Promise(function(resolve, reject) {
- desktopCapturer.getSources(options, (error, sources) => {
- if(error) reject(error)
- sources.map(source => {
- return {
- id: source.id,
- name: source.name,
- thumbnail: source.thumbnail.toDataURL()
- }
- })
- resolve(sources)
- })
- })
- }
- module.exports = getSources
Add Comment
Please, Sign In to add comment