MediaTrackConstraints: restrictOwnAudio property
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheMediaTrackConstraints dictionary'srestrictOwnAudio property is aConstrainBoolean that specifies the requested or mandatory constraints placed on the value of therestrictOwnAudio constrainable property.
This property controls whether system audio originating from the capturing tab is filtered out of screen capture, allowing for cleaner screen recordings in some cases. For example, if the capturing web page itself is playing embedded audio or video, that audio would be included in the capture. Since this could lead to an undesirable echo or interfere with the intended audio sources from other tabs or applications, removing it from the capture is desirable.
If needed, you can determine whether or not this constraint is supported by checkingthe value ofMediaTrackSupportedConstraints.restrictOwnAudio, as returnedbyMediaDevices.getSupportedConstraints(). However,this is rarely necessary since browsers typically ignore any constraints they don't recognize.
In this article
Value
AConstrainBoolean value.
If the value istrue, the user agent will attempt to remove any audio originating from the tab that calledMediaDevices.getDisplayMedia() to initiate screen capture. If removal of audio via processing fails, the user agent may exclude all audio originating from the capturing tab.
Note:If the captured display surface doesn't include system audio, this setting will have no effect.
If the value is given asexact, that field's boolean value indicates an exact requirement for therestrictOwnAudio feature; if the user agent can't meet this requirement, the request will result in an error.
If the value isfalse, the user agent will not attempt to restrict any system audio originating from the capturing tab.
Examples
let isCapturingTabSystemAudioRestricted = displayStream .getAudioTracks()[0] .getSettings().restrictOwnAudio;TheConstraint exerciser example shows how to use media track constraints.
Specifications
| Specification |
|---|
| Screen Capture> # dom-mediatrackconstraintset-restrictownaudio> |