Guest User

Untitled

a guest
Jul 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /*
  2. * This file exposes the desktopCapturer module of electron to the renderer
  3. */
  4. const { desktopCapturer } = require('electron')
  5.  
  6. /**
  7. * getSources - List the sources avaliable according to options
  8. *
  9. * @param {Object} options The type of source to capture
  10. * @return {Promise} A promise that resolves into an array of DesktopCapturerSources or rejects an error
  11. */
  12. function getSources(options) {
  13. return new Promise(function(resolve, reject) {
  14. desktopCapturer.getSources(options, (error, sources) => {
  15. if(error) reject(error)
  16. sources.map(source => {
  17. return {
  18. id: source.id,
  19. name: source.name,
  20. thumbnail: source.thumbnail.toDataURL()
  21. }
  22. })
  23. resolve(sources)
  24. })
  25. })
  26. }
  27. module.exports = getSources
Add Comment
Please, Sign In to add comment