desktopCapturer
Process: Main,
The following example shows how to capture video from a desktop window whose title is Electron
:
To capture both audio and video from the entire desktop the constraints passed to navigator.mediaDevices.getUserMedia must include chromeMediaSource: 'desktop'
, for both audio
and video
, but should not include a chromeMediaSourceId
constraint.
const constraints = {
audio: {
chromeMediaSource: 'desktop'
}
},
video: {
mandatory: {
}
}
}
The desktopCapturer
module has the following methods:
options
Objecttypes
String[] - An array of Strings that lists the types of desktop sources to be captured, available types arescreen
andwindow
.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.
Note Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher, which can detected by .
Caveats
does not work on macOS for audio capture due to a fundamental limitation whereby apps that want to access the system’s audio require a . Chromium, and by extension Electron, does not provide this.