MediaTrackSupportedConstraints: displaySurface property

The MediaTrackSupportedConstraints dictionary's displaySurface property indicates whether or not the displaySurface constraint is supported by the user agent and the device on which the content is being used.

The supported constraints list is obtained by calling navigator.mediaDevices.getSupportedConstraints().


A Boolean value which is true if the displaySurface constraint is supported by the device and user agent.


This method sets up the constraints object specifying the options for the call to getDisplayMedia(). It adds the displaySurface constraint (requesting that only fullscreen sharing be allowed) only if it is known to be supported by the browser. Capturing is then started by calling getDisplayMedia() and attaching the returned stream to the video element referenced by the variable videoElem.

async function capture() {
  let supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
  let displayMediaOptions = {
    video: {},
    audio: false,

  if (supportedConstraints.displaySurface) { = "monitor";

  try {
    videoElem.srcObject =
      await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
  } catch (err) {
    /* handle the error */


No specification found

No specification data found for api.MediaStreamTrack.applyConstraints.displaySurface_constraint.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

BCD tables only load in the browser

See also