The MediaTrackSupportedConstraints dictionary establishes the list of constrainable properties recognized by the user agent or browser in its implementation of the MediaStreamTrack object. An object conforming to MediaTrackSupportedConstraints is returned by MediaDevices.getSupportedConstraints().
Because of the way interface definitions in WebIDL work, if a constraint is requested but not supported, no error will occur. Instead, the specified constraints will be applied, with any unrecognized constraints stripped from the request.That can lead to confusing and hard to debug errors, so be sure to use getSupportedConstraints() to retrieve this information before attempting to establish constraints if you need to know the difference between silently ignoring a constraint and a constraint being accepted.
An actual constraint set is described using an object based on the MediaTrackConstraints dictionary.
To learn more about how constraints work, see Capabilities, constraints, and settings.
Some combination—but not necessarily all—of the following properties will exist on the object.
autoGainControltrue if the autoGainControl constraint is supported in the current environment.widthtrue if the width constraint is supported in the current environment.heighttrue if the height constraint is supported in the current environment.aspectRatiotrue if the aspectRatio constraint is supported in the current environment.frameRatetrue if the frameRate constraint is supported in the current environment.facingModetrue if the facingMode constraint is supported in the current environment.resizeModetrue if the resizeMode constraint is supported in the current environment.volumetrue if the volume constraint is supported in the current environment.sampleRatetrue if the sampleRate constraint is supported in the current environment.sampleSizetrue if the sampleSize constraint is supported in the current environment.echoCancellationtrue if the echoCancellation constraint is supported in the current environment.latencytrue if the latency constraint is supported in the current environment.noiseSuppressiontrue if the noiseSuppression constraint is supported in the current environment.channelCounttrue if the channelCount constraint is supported in the current environment.deviceIdtrue if the deviceId constraint is supported in the current environment.groupIdtrue if the groupId constraint is supported in the current environment.| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 52 | ? | 42 | ? | Yes | ? |
width |
52 | ? | 42 | ? | Yes | ? |
height |
52 | ? | 42 | ? | Yes | ? |
aspectRatio |
52 | ? | No | ? | Yes | ? |
frameRate |
52 | ? | 42 | ? | Yes | ? |
facingMode |
52 | ? | 42 | ? | Yes | ? |
resizeMode |
No | ? | No | ? | No | ? |
volume |
52 | ? | No | ? | Yes | ? |
sampleRate |
52 | ? | No | ? | Yes | ? |
sampleSize |
52 | ? | No | ? | Yes | ? |
echoCancellation |
52 | ? | 46 | ? | Yes | ? |
autoGainControl |
69 | ? | 55
|
? | Yes | ? |
noiseSuppression |
69 | ? | 55
|
? | Yes | ? |
latency |
52 | ? | No | ? | Yes | ? |
channelCount |
52 | ? | 56 | ? | Yes | ? |
deviceId |
52 | ? | 42 | ? | Yes | ? |
groupId |
52 | ? | No | ? | Yes | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | ? | 52 | ? | 42 | Yes | ? | ? |
width |
? | 52 | ? | 42 | Yes | ? | ? |
height |
? | 52 | ? | 42 | Yes | ? | ? |
aspectRatio |
? | 52 | ? | No | Yes | ? | ? |
frameRate |
? | 52 | ? | 42 | Yes | ? | ? |
facingMode |
? | 52 | ? | 42 | Yes | ? | ? |
resizeMode |
? | No | ? | No | No | ? | ? |
volume |
? | 52 | ? | No | Yes | ? | ? |
sampleRate |
? | 52 | ? | No | Yes | ? | ? |
sampleSize |
? | 52 | ? | No | Yes | ? | ? |
echoCancellation |
? | 52 | ? | 46 | Yes | ? | ? |
autoGainControl |
? | 69 | ? | 55
|
Yes | ? | ? |
noiseSuppression |
? | 69 | ? | 55
|
Yes | ? | ? |
latency |
? | 52 | ? | No | Yes | ? | ? |
channelCount |
? | 52 | ? | 56 | Yes | ? | ? |
deviceId |
? | 52 | ? | 42 | Yes | ? | ? |
groupId |
? | 52 | ? | No | Yes | ? | ? |
MediaTrackConstraintsMediaDevices.getUserMedia()MediaStreamTrack.getConstraints()MediaStreamTrack.applyConstraints()MediaStreamTrack.getSettings()
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints