-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Editorial review: Add docs for restrictOwnAudio constraint #41437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisdavidmills
merged 24 commits into
mdn:main
from
chrisdavidmills:restrictOwnAudio-constraint
Oct 15, 2025
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1b2a22c
Add docs for restrictOwnAudio constraint
chrisdavidmills 557cc76
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills b7c0720
Update ideal description to exact
chrisdavidmills 40b6b96
Merge branch 'restrictOwnAudio-constraint' of github.com:chrisdavidmi…
chrisdavidmills 4c645e6
Merge branch 'main' into restrictOwnAudio-constraint
chrisdavidmills 818d034
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills a3ba24b
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills 8a92af6
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills df12398
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills c361d8b
Update files/en-us/web/api/mediatrackconstraints/index.md
chrisdavidmills 00b815c
Update files/en-us/web/api/mediatrackconstraints/index.md
chrisdavidmills 5fab0b0
Update files/en-us/web/api/mediatracksettings/index.md
chrisdavidmills 7017b3b
Update files/en-us/web/api/mediatracksettings/index.md
chrisdavidmills 4452c15
Update files/en-us/web/api/mediatracksupportedconstraints/index.md
chrisdavidmills de413f0
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills 20365c0
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills c748060
Update files/en-us/web/api/mediatracksettings/restrictownaudio/index.md
chrisdavidmills fa99d03
Update files/en-us/web/api/mediatracksettings/restrictownaudio/index.md
chrisdavidmills db330ad
Update files/en-us/web/api/mediatracksupportedconstraints/restrictown…
chrisdavidmills e36a5ae
Update files/en-us/web/api/mediatracksupportedconstraints/restrictown…
chrisdavidmills 99527fd
Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/ind…
chrisdavidmills 3d5ea88
Merge branch 'main' into restrictOwnAudio-constraint
chrisdavidmills 3738a82
Last few bits of cleanup
chrisdavidmills c5866de
Merge branch 'main' into restrictOwnAudio-constraint
chrisdavidmills File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| title: "MediaTrackConstraints: restrictOwnAudio property" | ||
| short-title: restrictOwnAudio | ||
| slug: Web/API/MediaTrackConstraints/restrictOwnAudio | ||
| page-type: web-api-instance-property | ||
| status: | ||
| - experimental | ||
| browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint | ||
| --- | ||
|
|
||
| {{APIRef("Media Capture and Streams")}}{{SeeCompatTable}} | ||
|
|
||
| The {{domxref("MediaTrackConstraints")}} dictionary's **`restrictOwnAudio`** property is a [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) that specifies the requested or mandatory constraints placed on the value of the {{domxref("MediaTrackSettings.restrictOwnAudio","restrictOwnAudio")}} 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 checking | ||
| the value of {{domxref("MediaTrackSupportedConstraints.restrictOwnAudio")}}, as returned | ||
| by {{domxref("MediaDevices.getSupportedConstraints()")}}. However, | ||
| this is rarely necessary since browsers typically ignore any constraints they don't recognize. | ||
|
|
||
| ## Value | ||
|
|
||
| A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) value. | ||
|
|
||
| If the value is `true`, the user agent will attempt to remove any audio originating from the tab that called {{domxref("MediaDevices.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 as `exact`, that field's boolean value indicates an exact requirement for the `restrictOwnAudio` feature; if the user agent can't meet this requirement, the request will result in an error. | ||
|
|
||
| If the value is `false`, the user agent will not attempt to restrict any system audio originating from the capturing tab. | ||
|
|
||
| ## Examples | ||
|
|
||
| ```js | ||
| let isCapturingTabSystemAudioRestricted = displayStream | ||
| .getAudioTracks()[0] | ||
| .getSettings().restrictOwnAudio; | ||
| ``` | ||
|
|
||
| The [Constraint exerciser](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints#example_constraint_exerciser) example shows how to use media track constraints. | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) | ||
| - [Capabilities, constraints, and settings](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints) | ||
| - {{domxref("MediaTrackConstraints")}} | ||
| - {{domxref("MediaDevices.getSupportedConstraints()")}} | ||
| - {{domxref("MediaTrackSupportedConstraints")}} | ||
| - {{domxref("MediaStreamTrack")}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
files/en-us/web/api/mediatracksettings/restrictownaudio/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| --- | ||
| title: "MediaTrackSettings: restrictOwnAudio property" | ||
| short-title: restrictOwnAudio | ||
| slug: Web/API/MediaTrackSettings/restrictOwnAudio | ||
| page-type: web-api-instance-property | ||
| status: | ||
| - experimental | ||
| browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint | ||
| --- | ||
|
|
||
| {{APIRef("Media Capture and Streams")}}{{SeeCompatTable}} | ||
|
|
||
| The {{domxref("MediaTrackSettings")}} dictionary's **`restrictOwnAudio`** 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. | ||
|
|
||
| ## Value | ||
|
|
||
| A boolean value, where `true` enables the capturing tab's system audio restriction and `false` disables it. | ||
|
|
||
| If the value is `true`, the user agent will attempt to remove any audio originating from the captured audio produced by the tab that called {{domxref("MediaDevices.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. | ||
|
|
||
| ## Examples | ||
|
|
||
| The following function sets up a constraints object that specifies the options for a call to {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}}. | ||
| It adds the `restrictOwnAudio` constraint (requesting that system audio originating from the capturing tab be filtered out of the screen capture) only if it is known to be supported by the browser. | ||
| Capture then starts by calling `getDisplayMedia()` and attaching the returned stream to the {{htmlelement("video")}} element referenced by the variable `videoElem`. | ||
|
|
||
| ```js | ||
| async function capture() { | ||
| const supportedConstraints = navigator.mediaDevices.getSupportedConstraints(); | ||
| const displayMediaOptions = { | ||
| audio: {}, | ||
| }; | ||
|
|
||
| if (supportedConstraints.restrictOwnAudio) { | ||
| displayMediaOptions.audio.restrictOwnAudio = true; | ||
| } | ||
|
|
||
| try { | ||
| videoElem.srcObject = | ||
| await navigator.mediaDevices.getDisplayMedia(displayMediaOptions); | ||
| } catch (err) { | ||
| /* handle the error */ | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API) | ||
| - [Using the screen capture API](/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture) | ||
| - [Capabilities, constraints, and settings](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints) | ||
| - {{domxref("MediaDevices.getDisplayMedia()")}} | ||
| - {{domxref("MediaStreamTrack.getConstraints()")}} | ||
| - {{domxref("MediaStreamTrack.applyConstraints()")}} | ||
| - {{domxref("MediaStreamTrack.getSettings()")}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
files/en-us/web/api/mediatracksupportedconstraints/restrictownaudio/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| --- | ||
| title: "MediaTrackSupportedConstraints: restrictOwnAudio property" | ||
| short-title: restrictOwnAudio | ||
| slug: Web/API/MediaTrackSupportedConstraints/restrictOwnAudio | ||
| page-type: web-api-instance-property | ||
| browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint | ||
| --- | ||
|
|
||
| {{APIRef("Media Capture and Streams")}} | ||
|
|
||
| The {{domxref("MediaTrackSupportedConstraints")}} dictionary's **`restrictOwnAudio`** property is a read-only boolean value which is present (and set to `true`) in the object returned by {{domxref("MediaDevices.getSupportedConstraints()")}} if and only if the {{Glossary("user agent")}} supports the `restrictOwnAudio` constraint. If the constraint isn't supported, it's not included in the list, so this value will never be `false`. | ||
|
|
||
| You can access the supported constraints dictionary by calling {{domxref("MediaDevices.getSupportedConstraints()", "navigator.mediaDevices.getSupportedConstraints()")}}. | ||
|
|
||
| ## Value | ||
|
|
||
| This property is present in the dictionary (and its value is always `true`) if the user agent supports the `restrictOwnAudio` constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get {{jsxref("undefined")}} if you try to access its value. | ||
|
|
||
| ## Examples | ||
|
|
||
| ```html hidden | ||
| <div id="result"></div> | ||
| ``` | ||
|
|
||
| ```css hidden | ||
| #result { | ||
| font: | ||
| 14px "Arial", | ||
| sans-serif; | ||
| } | ||
| ``` | ||
|
|
||
| ```js | ||
| const result = document.getElementById("result"); | ||
| const supported = | ||
| navigator.mediaDevices.getSupportedConstraints().restrictOwnAudio; | ||
| result.textContent = supported ? "Supported!" : "Not supported!"; | ||
| ``` | ||
|
|
||
| ### Result | ||
|
|
||
| {{EmbedLiveSample('Examples', 600, 80)}} | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) | ||
| - {{domxref("MediaDevices.getSupportedConstraints()")}} | ||
| - {{domxref("MediaTrackSupportedConstraints")}} | ||
| - {{domxref("MediaStreamTrack")}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.