Repository navigation
docs: improve desktop capture example - #42957
Conversation
|
cc @electron/docs |
|
No Release Notes |
|
I have automatically backported this PR to "30-x-y", please check out #43004 |
|
I have automatically backported this PR to "31-x-y", please check out #43005 |
|
I have automatically backported this PR to "32-x-y", please check out #43006 |
| 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. | ||
| See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information. | ||
|
|
||
| ```js | ||
| const constraints = { | ||
| audio: { | ||
| mandatory: { | ||
| chromeMediaSource: 'desktop' | ||
| } | ||
| }, | ||
| video: { | ||
| mandatory: { | ||
| chromeMediaSource: 'desktop' | ||
| } | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
This option is still available in Electron, but not mentioned in the docs anymore. As far as I know, this is the only way to capture an entire desktop with multiple screens.
Was it removed intentionally? If it was - what it the recommended way to capture an entire screen? I know, it doesn't work on macOS, but it does on Windows and Linux (except Wayland).
There was a problem hiding this comment.
@codebytere I'm here from reading #42605. I'm trying to understand the state of capturing loopback audio in Electron on macOS right now.
Many others are in a similar state of confusion. It's a frequent question on the /r/electron subreddit, on the Electron Discord server, and on StackOverflow, for example. I think the docs leave users lost as to the best practices for handling macOS. Has the situation improved recently? I noticed that there is some ScreenCaptureKit-based code for recording audio loopback in the Chromium macOS source code, so I am wondering what that means for Electron as of today.
Would love any information you can spare! Particularly interested in whether it's possible to record just the desktop audio without capturing video.
There was a problem hiding this comment.
Update: I checked for myself and I'm happy to report some success, so my questions are answered.
- The
getUserMedia()example given in this older commit of the docs:- works on Windows.
- throws an error on macOS:
main_window#/recording:1 The AudioContext encountered an error from the audio device or the WebAudio renderer.
- The
getDisplayMedia()example given in the current PR (committed in this commit):- I didn't test on Windows.
- Does work on macOS! 🥳 I was able to succesfully record both microphone and desktop audio.
Description of Change
Closes #42605.
Updates desktopCapturer example to reflect our current recommendations - this wasn't updated after we added support for
navigator.mediaDevices.requestDisplayMediavia #30702Checklist
Release Notes
Notes: none