-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Closed
Labels
10-x-y11-x-y12-x-y13-x-ybug 🪲has-repro-gistIssue can be reproduced with code at https://gist.github.com/Issue can be reproduced with code at https://gist.github.com/platform/linuxplatform/windows
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 10.1.2
- Operating System:
- Ubuntu 18.04.5 LTS
Expected Behavior
desktopCapturer.getSources().then
should be resolved
Actual Behavior
desktopCapturer.getSources().then
is not resolved after 1 minute
To Reproduce
const { app, desktopCapturer, screen } = require('electron');
const fs = require('fs')
const path = require('path')
function takeScreenshot() {
console.log('Gathering screens...')
const thumbSize = determineScreenShotSize()
const options = { types: ['screen'], thumbnailSize: thumbSize }
desktopCapturer.getSources(options).then((sources) => {
console.log('Sources received:'+sources.length);
sources.forEach(function (source) {
const sourceName = source.name.toLowerCase();
console.log(sourceName);
if ( ['entire screen', 'screen 1'].includes(sourceName)) {
const screenshotPath = path.join(app.getPath('pictures'), 'screenshot-' + new Date().toJSON() + '.png')
fs.writeFile(screenshotPath, source.thumbnail.toPNG(), function (error) {
if (error) return console.log(error)
console.log('Saved screenshot to: ' + screenshotPath);
})
}
})
}).catch(console.error);
}
function determineScreenShotSize() {
var screenSize = screen.getPrimaryDisplay().workAreaSize
return {
width: screenSize.width,
height: screenSize.height
}
}
setInterval(takeScreenshot, 15000);
git clone git@bitbucket.org:praveen-knackforge/electron-boilerplate.git -b screenshot
npm install
npm start || electron .
Screenshots
Additional Information
I used desktopCapturer
API from the main process
lmcarreiro
Metadata
Metadata
Assignees
Labels
10-x-y11-x-y12-x-y13-x-ybug 🪲has-repro-gistIssue can be reproduced with code at https://gist.github.com/Issue can be reproduced with code at https://gist.github.com/platform/linuxplatform/windows