MediaTrackSettings: suppressLocalAudioPlayback property

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

The MediaTrackSettings dictionary's suppressLocalAudioPlayback property controls whether the audio playing in a tab will continue to be played out of a user's local speakers when the tab is captured.

For example, in cases where you broadcast a video call to an external AV system in a conference room, you will want the audio to play out of the AV system, and not the local speakers. This way, the audio will be louder and clearer, and also in sync with the conference video.

Value

The value of suppressLocalAudioPlayback is a boolean — true enables local audio playback suppression, and false disables it.

Examples

The below function sets up the constraints object specifying the options 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-mediatrackconstraintset-suppresslocalaudioplayback

Browser compatibility

BCD tables only load in the browser

See also