1

I am working on a screen recorder application and wanted to see if it's possible to limit what options the user can pick to record?

Right now, I am calling navigator.mediaDevices.getDisplayMedia({}) which prompts the user to share either 1) Entire Screen, 2) Application Window or 3) Chrome Tab

However, I would like to limit the options to just which Chrome Tab. I thought the solution was to set the displaySurface: browser value:

navigator.mediaDevices.getDisplayMedia({
      video: {
        mediaSource: "screen",
        audio: true,
        cursor: ["motion"],
        displaySurface: "browser",
      },
    });

However, I am still being presented with the three options instead of just the tab. Does anyone know how I can limit which screens can be shared?

Thank you in advance!

John Grayson
  • 1,378
  • 3
  • 17
  • 30
  • It doesn't look like you're in luck. Check out [this answer](https://stackoverflow.com/a/57617381/7823264). – Geat Jul 02 '20 at 23:24
  • `displaySurface` as a constraint isn't shipping in any browser besides Opera. You can track it's availability [here](https://caniuse.com/#feat=mdn-api_mediatrackconstraints_displaysurface) and [here](https://caniuse.com/#feat=mdn-api_mediatracksupportedconstraints_displaysurface) – Uzair Sajid Jul 03 '20 at 09:55

2 Answers2

0

"displaySurface" is only supported by Opera and Safari.

For now, in Chrome, you can only present all three options or use "chrome.tabCapture" for tabs only.

There is also mediaDevices.getCurrentBrowsingContextMedia(), but now its's experimental

Yauhen
  • 401
  • 6
  • 7
0

This appears to be now semi-supported in Chrome. If you use the option displaySurface: "browser" it now shows the user the list of tabs first (instead of the 'Entire Screen' or 'Window' options).

However, the other options are still selectable (this is supposedly for security reasons, see here displaySurface constraint not restricting user share screen selection options)

Mijawel
  • 389
  • 2
  • 15