MediaTrackSupportedConstraints: suppressLocalAudioPlayback property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The MediaTrackSupportedConstraints dictionary's suppressLocalAudioPlayback property indicates whether or not the suppressLocalAudioPlayback 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().

Value

A boolean value which is true if the suppressLocalAudioPlayback constraint is supported by the device and user agent.

Examples

The function below sets up the options object for the call to getDisplayMedia(). It adds the suppressLocalAudioPlayback constraint (requesting that captured audio is not played out of the user's local speakers) 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.

js

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

  if (supportedConstraints.suppressLocalAudioPlayback) {
    displayMediaOptions.audio.suppressLocalAudioPlayback = true;
  }

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

Specifications

Specification
Screen Capture
# dom-mediatracksupportedconstraints-suppresslocalaudioplayback

Browser compatibility

BCD tables only load in the browser

See also