Skip to content

Commit a439453

Browse files
chrisdavidmillsbeaufortfrancoisdipikabhgithub-actions[bot]
authored
Editorial review: Add docs for restrictOwnAudio constraint (#41437)
* Add docs for restrictOwnAudio constraint * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: François Beaufort <[email protected]> * Update ideal description to exact * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksettings/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksettings/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksupportedconstraints/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksettings/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksettings/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksupportedconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatracksupportedconstraints/restrictownaudio/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/api/mediatrackconstraints/restrictownaudio/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Last few bits of cleanup --------- Co-authored-by: François Beaufort <[email protected]> Co-authored-by: Dipika Bhattacharya <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 128747c commit a439453

File tree

6 files changed

+217
-24
lines changed

6 files changed

+217
-24
lines changed

files/en-us/web/api/mediatrackconstraints/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ These constraints apply to the `video` property of the object passed into {{domx
203203
- : A [`ConstrainBoolean`](#constrainboolean) value describing the requested or mandatory constraints placed upon the value of the {{domxref("MediaTrackSettings.suppressLocalAudioPlayback","suppressLocalAudioPlayback")}} constrainable property.
204204
This 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.
205205

206+
- {{domxref("MediaTrackConstraints.restrictOwnAudio", "restrictOwnAudio")}} {{Experimental_Inline}}
207+
- : A [`ConstrainBoolean`](#constrainboolean) value that specifies the requested or mandatory constraints placed on the value of the {{domxref("MediaTrackSettings.restrictOwnAudio","restrictOwnAudio")}} constrainable property.
208+
This property controls whether the system audio originating from the capturing tab is filtered out of the screen capture.
209+
206210
## Specifications
207211

208212
{{Specifications}}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "MediaTrackConstraints: restrictOwnAudio property"
3+
short-title: restrictOwnAudio
4+
slug: Web/API/MediaTrackConstraints/restrictOwnAudio
5+
page-type: web-api-instance-property
6+
status:
7+
- experimental
8+
browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint
9+
---
10+
11+
{{APIRef("Media Capture and Streams")}}{{SeeCompatTable}}
12+
13+
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.
14+
15+
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.
16+
17+
If needed, you can determine whether or not this constraint is supported by checking
18+
the value of {{domxref("MediaTrackSupportedConstraints.restrictOwnAudio")}}, as returned
19+
by {{domxref("MediaDevices.getSupportedConstraints()")}}. However,
20+
this is rarely necessary since browsers typically ignore any constraints they don't recognize.
21+
22+
## Value
23+
24+
A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) value.
25+
26+
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.
27+
28+
> [!NOTE]
29+
> If the captured display surface doesn't include system audio, this setting will have no effect.
30+
31+
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.
32+
33+
If the value is `false`, the user agent will not attempt to restrict any system audio originating from the capturing tab.
34+
35+
## Examples
36+
37+
```js
38+
let isCapturingTabSystemAudioRestricted = displayStream
39+
.getAudioTracks()[0]
40+
.getSettings().restrictOwnAudio;
41+
```
42+
43+
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.
44+
45+
## Specifications
46+
47+
{{Specifications}}
48+
49+
## Browser compatibility
50+
51+
{{Compat}}
52+
53+
## See also
54+
55+
- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API)
56+
- [Capabilities, constraints, and settings](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints)
57+
- {{domxref("MediaTrackConstraints")}}
58+
- {{domxref("MediaDevices.getSupportedConstraints()")}}
59+
- {{domxref("MediaTrackSupportedConstraints")}}
60+
- {{domxref("MediaStreamTrack")}}

files/en-us/web/api/mediatracksettings/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Some or all of the following will be included in the object, either because it's
3535
- {{domxref("MediaTrackSettings.latency", "latency")}}
3636
- : A double-precision floating point value indicating the current value of the {{domxref("MediaTrackConstraints.latency", "latency")}} property, specifying the audio latency, in seconds. Latency is the amount of time which elapses between the start of processing the audio and the data being available to the next stop in the audio utilization process. This value is a target value; actual latency may vary to some extent for various reasons.
3737
- {{domxref("MediaTrackSettings.noiseSuppression", "noiseSuppression")}}
38-
- : A Boolean which indicates the current value of the {{domxref("MediaTrackConstraints.noiseSuppression", "noiseSuppression")}} property, which is `true` if noise suppression is enabled and is `false` otherwise.
38+
- : A Boolean indicating the current value of the {{domxref("MediaTrackConstraints.noiseSuppression", "noiseSuppression")}} property: `true` if noise suppression is enabled, and is `false` otherwise.
39+
- {{domxref("MediaTrackSettings.restrictOwnAudio", "restrictOwnAudio")}}
40+
- : A Boolean indicating the current value of the {{domxref("MediaTrackConstraints.restrictOwnAudio", "restrictOwnAudio")}} property: `true` if the browser will attempt to filter out system audio originating from the capturing tab during screen capture, and `false` otherwise.
3941
- {{domxref("MediaTrackSettings.sampleRate", "sampleRate")}}
4042
- : A long integer value indicating the current value of the {{domxref("MediaTrackConstraints.sampleRate", "sampleRate")}} property, specifying the sample rate in samples per second of the audio data. Standard CD-quality audio, for example, has a sample rate of 41,000 samples per second.
4143
- {{domxref("MediaTrackSettings.sampleSize", "sampleSize")}}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: "MediaTrackSettings: restrictOwnAudio property"
3+
short-title: restrictOwnAudio
4+
slug: Web/API/MediaTrackSettings/restrictOwnAudio
5+
page-type: web-api-instance-property
6+
status:
7+
- experimental
8+
browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint
9+
---
10+
11+
{{APIRef("Media Capture and Streams")}}{{SeeCompatTable}}
12+
13+
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.
14+
15+
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.
16+
17+
## Value
18+
19+
A boolean value, where `true` enables the capturing tab's system audio restriction and `false` disables it.
20+
21+
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.
22+
23+
> [!NOTE]
24+
> If the captured display surface doesn't include system audio, this setting will have no effect.
25+
26+
## Examples
27+
28+
The following function sets up a constraints object that specifies the options for a call to {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}}.
29+
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.
30+
Capture then starts by calling `getDisplayMedia()` and attaching the returned stream to the {{htmlelement("video")}} element referenced by the variable `videoElem`.
31+
32+
```js
33+
async function capture() {
34+
const supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
35+
const displayMediaOptions = {
36+
audio: {},
37+
};
38+
39+
if (supportedConstraints.restrictOwnAudio) {
40+
displayMediaOptions.audio.restrictOwnAudio = true;
41+
}
42+
43+
try {
44+
videoElem.srcObject =
45+
await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
46+
} catch (err) {
47+
/* handle the error */
48+
}
49+
}
50+
```
51+
52+
## Specifications
53+
54+
{{Specifications}}
55+
56+
## Browser compatibility
57+
58+
{{Compat}}
59+
60+
## See also
61+
62+
- [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API)
63+
- [Using the screen capture API](/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture)
64+
- [Capabilities, constraints, and settings](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints)
65+
- {{domxref("MediaDevices.getDisplayMedia()")}}
66+
- {{domxref("MediaStreamTrack.getConstraints()")}}
67+
- {{domxref("MediaStreamTrack.applyConstraints()")}}
68+
- {{domxref("MediaStreamTrack.getSettings()")}}

files/en-us/web/api/mediatracksupportedconstraints/index.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,46 @@ To learn more about how constraints work, see [Capabilities, constraints, and se
1919

2020
Some combination—but not necessarily all—of the following properties will exist on the object.
2121

22-
- {{domxref("MediaTrackSupportedConstraints.autoGainControl", "autoGainControl")}}
23-
- : A Boolean that is `true` if the [`autoGainControl`](/en-US/docs/Web/API/MediaTrackConstraints/autoGainControl) constraint is supported in the current environment.
24-
- {{domxref("MediaTrackSupportedConstraints.width", "width")}}
25-
- : A Boolean that is `true` if the [`width`](/en-US/docs/Web/API/MediaTrackConstraints/width) constraint is supported in the current environment.
26-
- {{domxref("MediaTrackSupportedConstraints.height", "height")}}
27-
- : A Boolean that is `true` if the [`height`](/en-US/docs/Web/API/MediaTrackConstraints/height) constraint is supported in the current environment.
2822
- {{domxref("MediaTrackSupportedConstraints.aspectRatio", "aspectRatio")}}
2923
- : A Boolean that is `true` if the [`aspectRatio`](/en-US/docs/Web/API/MediaTrackConstraints/aspectRatio) constraint is supported in the current environment.
30-
- {{domxref("MediaTrackSupportedConstraints.frameRate", "frameRate")}}
31-
- : A Boolean that is `true` if the [`frameRate`](/en-US/docs/Web/API/MediaTrackConstraints/frameRate) constraint is supported in the current environment.
24+
- {{domxref("MediaTrackSupportedConstraints.autoGainControl", "autoGainControl")}}
25+
- : A Boolean that is `true` if the [`autoGainControl`](/en-US/docs/Web/API/MediaTrackConstraints/autoGainControl) constraint is supported in the current environment.
26+
- {{domxref("MediaTrackSupportedConstraints.channelCount", "channelCount")}}
27+
- : A Boolean that is `true` if the [`channelCount`](/en-US/docs/Web/API/MediaTrackConstraints/channelCount) constraint is supported in the current environment.
28+
- {{domxref("MediaTrackSupportedConstraints.deviceId", "deviceId")}}
29+
- : A Boolean that is `true` if the [`deviceId`](/en-US/docs/Web/API/MediaTrackConstraints/deviceId) constraint is supported in the current environment.
30+
- {{domxref("MediaTrackSupportedConstraints.echoCancellation", "echoCancellation")}}
31+
- : A Boolean that is `true` if the [`echoCancellation`](/en-US/docs/Web/API/MediaTrackConstraints/echoCancellation) constraint is supported in the current environment.
3232
- {{domxref("MediaTrackSupportedConstraints.facingMode", "facingMode")}}
3333
- : A Boolean that is `true` if the [`facingMode`](/en-US/docs/Web/API/MediaTrackConstraints/facingMode) constraint is supported in the current environment.
34+
- {{domxref("MediaTrackSupportedConstraints.frameRate", "frameRate")}}
35+
- : A Boolean that is `true` if the [`frameRate`](/en-US/docs/Web/API/MediaTrackConstraints/frameRate) constraint is supported in the current environment.
36+
- {{domxref("MediaTrackSupportedConstraints.groupId", "groupId")}}
37+
- : A Boolean that is `true` if the [`groupId`](/en-US/docs/Web/API/MediaTrackConstraints/groupId) constraint is supported in the current environment.
38+
- {{domxref("MediaTrackSupportedConstraints.height", "height")}}
39+
- : A Boolean that is `true` if the [`height`](/en-US/docs/Web/API/MediaTrackConstraints/height) constraint is supported in the current environment.
40+
- {{domxref("MediaTrackSupportedConstraints.latency", "latency")}}
41+
- : A Boolean that is `true` if the [`latency`](/en-US/docs/Web/API/MediaTrackConstraints/latency) constraint is supported in the current environment.
42+
- {{domxref("MediaTrackSupportedConstraints.noiseSuppression", "noiseSuppression")}}
43+
- : A Boolean that is `true` if the [`noiseSuppression`](/en-US/docs/Web/API/MediaTrackConstraints/noiseSuppression) constraint is supported in the current environment.
44+
- {{domxref("MediaTrackSupportedConstraints.restrictOwnAudio", "restrictOwnAudio")}}
45+
- : A Boolean that is `true` if the {{domxref("MediaTrackConstraints.restrictOwnAudio", "restrictOwnAudio")}} constraint is supported in the current environment.
3446
- {{domxref("MediaTrackSupportedConstraints.resizeMode", "resizeMode")}}
3547
- : A Boolean that is `true` if the [`resizeMode`](/en-US/docs/Web/API/MediaTrackConstraints/resizeMode) constraint is supported in the current environment.
36-
- {{domxref("MediaTrackSupportedConstraints.volume", "volume")}} {{Deprecated_Inline}} {{Non-standard_Inline}}
37-
- : A Boolean that is `true` if the [`volume`](/en-US/docs/Web/API/MediaTrackConstraints/volume) constraint is supported in the current environment.
3848
- {{domxref("MediaTrackSupportedConstraints.sampleRate", "sampleRate")}}
3949
- : A Boolean that is `true` if the [`sampleRate`](/en-US/docs/Web/API/MediaTrackConstraints/sampleRate) constraint is supported in the current environment.
4050
- {{domxref("MediaTrackSupportedConstraints.sampleSize", "sampleSize")}}
4151
- : A Boolean that is `true` if the [`sampleSize`](/en-US/docs/Web/API/MediaTrackConstraints/sampleSize) constraint is supported in the current environment.
42-
- {{domxref("MediaTrackSupportedConstraints.echoCancellation", "echoCancellation")}}
43-
- : A Boolean that is `true` if the [`echoCancellation`](/en-US/docs/Web/API/MediaTrackConstraints/echoCancellation) constraint is supported in the current environment.
44-
- {{domxref("MediaTrackSupportedConstraints.latency", "latency")}}
45-
- : A Boolean that is `true` if the [`latency`](/en-US/docs/Web/API/MediaTrackConstraints/latency) constraint is supported in the current environment.
46-
- {{domxref("MediaTrackSupportedConstraints.noiseSuppression", "noiseSuppression")}}
47-
- : A Boolean that is `true` if the [`noiseSuppression`](/en-US/docs/Web/API/MediaTrackConstraints/noiseSuppression) constraint is supported in the current environment.
4852
- {{domxref("MediaTrackSupportedConstraints.suppressLocalAudioPlayback", "suppressLocalAudioPlayback")}}
4953
- : A Boolean that is `true` if the [`suppressLocalAudioPlayback`](/en-US/docs/Web/API/MediaTrackConstraints/suppressLocalAudioPlayback) constraint is supported in the current environment.
50-
- {{domxref("MediaTrackSupportedConstraints.channelCount", "channelCount")}}
51-
- : A Boolean that is `true` if the [`channelCount`](/en-US/docs/Web/API/MediaTrackConstraints/channelCount) constraint is supported in the current environment.
52-
- {{domxref("MediaTrackSupportedConstraints.deviceId", "deviceId")}}
53-
- : A Boolean that is `true` if the [`deviceId`](/en-US/docs/Web/API/MediaTrackConstraints/deviceId) constraint is supported in the current environment.
54-
- {{domxref("MediaTrackSupportedConstraints.groupId", "groupId")}}
55-
- : A Boolean that is `true` if the [`groupId`](/en-US/docs/Web/API/MediaTrackConstraints/groupId) constraint is supported in the current environment.
54+
- {{domxref("MediaTrackSupportedConstraints.volume", "volume")}} {{Deprecated_Inline}} {{Non-standard_Inline}}
55+
- : A Boolean that is `true` if the [`volume`](/en-US/docs/Web/API/MediaTrackConstraints/volume) constraint is supported in the current environment.
56+
- {{domxref("MediaTrackSupportedConstraints.width", "width")}}
57+
- : A Boolean that is `true` if the [`width`](/en-US/docs/Web/API/MediaTrackConstraints/width) constraint is supported in the current environment.
5658

5759
### Instance properties specific to shared screen tracks
5860

59-
For tracks containing video sources from the user's screen contents, the following additional properties are may be included in addition to those available for video tracks.
61+
For tracks containing video sources from the user's screen, the following additional properties may be included, in addition to those available for video tracks:
6062

6163
- {{domxref("MediaTrackSupportedConstraints.displaySurface", "displaySurface")}}
6264
- : A Boolean that is `true` if the {{domxref("MediaTrackConstraints.displaySurface", "displaySurface")}} constraint is supported in the current environment.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: "MediaTrackSupportedConstraints: restrictOwnAudio property"
3+
short-title: restrictOwnAudio
4+
slug: Web/API/MediaTrackSupportedConstraints/restrictOwnAudio
5+
page-type: web-api-instance-property
6+
browser-compat: api.MediaStreamTrack.applyConstraints.restrictOwnAudio_constraint
7+
---
8+
9+
{{APIRef("Media Capture and Streams")}}
10+
11+
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`.
12+
13+
You can access the supported constraints dictionary by calling {{domxref("MediaDevices.getSupportedConstraints()", "navigator.mediaDevices.getSupportedConstraints()")}}.
14+
15+
## Value
16+
17+
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.
18+
19+
## Examples
20+
21+
```html hidden
22+
<div id="result"></div>
23+
```
24+
25+
```css hidden
26+
#result {
27+
font:
28+
14px "Arial",
29+
sans-serif;
30+
}
31+
```
32+
33+
```js
34+
const result = document.getElementById("result");
35+
const supported =
36+
navigator.mediaDevices.getSupportedConstraints().restrictOwnAudio;
37+
result.textContent = supported ? "Supported!" : "Not supported!";
38+
```
39+
40+
### Result
41+
42+
{{EmbedLiveSample('Examples', 600, 80)}}
43+
44+
## Specifications
45+
46+
{{Specifications}}
47+
48+
## Browser compatibility
49+
50+
{{Compat}}
51+
52+
## See also
53+
54+
- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API)
55+
- {{domxref("MediaDevices.getSupportedConstraints()")}}
56+
- {{domxref("MediaTrackSupportedConstraints")}}
57+
- {{domxref("MediaStreamTrack")}}

0 commit comments

Comments
 (0)