feat: promisify desktopCapturer.getSources (#16427)
* feat: promisify desktopCapturer.getSources * fix doc * fix docs lint error
This commit is contained in:
parent
902c239fdf
commit
441c9ce376
4 changed files with 92 additions and 76 deletions
|
@ -12,8 +12,7 @@ title is `Electron`:
|
|||
// In the renderer process.
|
||||
const { desktopCapturer } = require('electron')
|
||||
|
||||
desktopCapturer.getSources({ types: ['window', 'screen'] }, async (error, sources) => {
|
||||
if (error) throw error
|
||||
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
|
||||
for (const source of sources) {
|
||||
if (source.name === 'Electron') {
|
||||
try {
|
||||
|
@ -99,3 +98,20 @@ objects, each `DesktopCapturerSource` represents a screen or an individual windo
|
|||
captured.
|
||||
|
||||
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
||||
|
||||
**[Deprecated Soon](promisification.md)**
|
||||
|
||||
### `desktopCapturer.getSources(options)`
|
||||
|
||||
* `options` Object
|
||||
* `types` String[] - An array of Strings that lists the types of desktop sources
|
||||
to be captured, available types are `screen` and `window`.
|
||||
* `thumbnailSize` [Size](structures/size.md) (optional) - The size that the media source thumbnail
|
||||
should be scaled to. Default is `150` x `150`.
|
||||
* `fetchWindowIcons` Boolean (optional) - Set to true to enable fetching window icons. The default
|
||||
value is false. When false the appIcon property of the sources return null. Same if a source has
|
||||
the type screen.
|
||||
|
||||
Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`DesktopCapturerSource`](structures/desktop-capturer-source.md) objects, each `DesktopCapturerSource` represents a screen or an individual window that can be captured.
|
||||
|
||||
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue