MediaTrackSupportedConstraints

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.

autoGainControl
A Boolean whose value is true autoGainControl constraint is supported in the current environment.
width
A Boolean value whose value is true width constraint is supported in the current environment.
height
A Boolean value whose value is true height constraint is supported in the current environment.
aspectRatio
A Boolean value whose value is true aspectRatio constraint is supported in the current environment.
frameRate
A Boolean value whose value is true frameRate constraint is supported in the current environment.
facingMode
A Boolean value whose value is true facingMode constraint is supported in the current environment.
resizeMode
A Boolean value whose value is true resizeMode constraint is supported in the current environment.
volume
A Boolean value whose value is true volume constraint is supported in the current environment.
sampleRate
A Boolean value whose value is true sampleRate constraint is supported in the current environment.
sampleSize
A Boolean value whose value is true sampleSize constraint is supported in the current environment.
echoCancellation
A Boolean value whose value is true echoCancellation constraint is supported in the current environment.
latency
A Boolean value whose value is true latency constraint is supported in the current environment.
noiseSuppression
A Boolean whose value is true noiseSuppression constraint is supported in the current environment.
channelCount
A Boolean value whose value is true channelCount constraint is supported in the current environment.
deviceId
A Boolean value whose value is true deviceId constraint is supported in the current environment.
groupId
A Boolean value whose value is true groupId constraint is supported in the current environment.

Properties specific to shared screen tracks

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.

cursor

A Boolean value which is true cursor constraint is supported in the current environment.

displaySurface

A Boolean value which is true cursor constraint is supported in the current environment.

logicalSurface
A Boolean value which is true logicalSurface constraint is supported in the current environment.

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
MediaTrackSupportedConstraints Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
aspectRatio Chrome 52 Edge ≤79 Firefox No IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
autoGainControl Chrome 69 Edge ≤79 Firefox 55
55
不支持 ? — 55
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE ? Opera Yes Safari ? WebView Android 69 Chrome Android 69 Firefox Android 55
55
不支持 ? — 55
Prefixed
Prefixed Implemented with the vendor prefix: moz
Opera Android Yes Safari iOS ? Samsung Internet Android 10.0
channelCount Chrome 52 Edge ≤79 Firefox 56 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 56 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
cursor Chrome No Edge No Firefox No IE No Opera Yes Safari ? WebView Android No Chrome Android No Firefox Android No Opera Android ? Safari iOS ? Samsung Internet Android No
deviceId Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
displaySurface Chrome No Edge No Firefox No IE No Opera Yes Safari ? WebView Android No Chrome Android No Firefox Android No Opera Android ? Safari iOS ? Samsung Internet Android No
echoCancellation Chrome 52 Edge ≤79 Firefox 46 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 46 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
facingMode Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
frameRate Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
groupId Chrome 52 Edge ≤79 Firefox 70 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
height Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
latency Chrome 52 Edge ≤79 Firefox No IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
logicalSurface Chrome No Edge No Firefox No IE No Opera Yes Safari ? WebView Android No Chrome Android No Firefox Android No Opera Android ? Safari iOS ? Samsung Internet Android No
noiseSuppression Chrome 69 Edge ≤79 Firefox 55
55
不支持 ? — 55
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE ? Opera Yes Safari ? WebView Android 69 Chrome Android 69 Firefox Android 55
55
不支持 ? — 55
Prefixed
Prefixed Implemented with the vendor prefix: moz
Opera Android Yes Safari iOS ? Samsung Internet Android 10.0
resizeMode Chrome No Edge No Firefox No IE ? Opera No Safari ? WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS ? Samsung Internet Android No
sampleRate Chrome 52 Edge ≤79 Firefox No IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
sampleSize Chrome 52 Edge ≤79 Firefox No IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
volume
弃用 非标
Chrome 52 Edge ≤79 Firefox No IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android No Opera Android Yes Safari iOS ? Samsung Internet Android 6.0
width Chrome 52 Edge ≤79 Firefox 42 IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android 42 Opera Android Yes Safari iOS ? Samsung Internet Android 6.0

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅