この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

The MediaTrackConstraints dictionary is used to describe a set of capabilities and the value or values each can take on. A constraints dictionary is passed into applyConstraints() to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling getConstraints().

For each constraint, you can typically specify an exact value you need, an ideal value you want, a range of acceptable values, and/or a value which you'd like to be as close to as possible. The specifics vary somewhat depending on the type of the constrainable property.

To learn more about how constraints work, see Capabilities, constraints, and settings.

Properties

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

Properties of all media tracks

deviceId
A ConstrainDOMString object specifying a device ID or an array of device IDs which are acceptable and/or required.
groupId
A ConstrainDOMString object specifying a group ID or an array of group IDs which are acceptable and/or required.

Properties of audio tracks

autoGainControl
A ConstrainBoolean object which specifies whether automatic gain control is preferred and/or required.
channelCount
A ConstrainLong specifying the channel count or range of channel counts which are acceptable and/or required.
echoCancellation
A ConstrainBoolean object specifying whether or not echo cancellation is preferred and/or required.
latency
A ConstrainDouble specifying the latency or range of latencies which are acceptable and/or required.
noiseSuppression
A ConstrainBoolean which specifies whether noise suppression is preferred and/or required.
sampleRate
A ConstrainLong specifying the sample rate or range of sample rates which are acceptable and/or required.
sampleSize
A ConstrainLong specifying the sample size or range of sample sizes which are acceptable and/or required.
volume
A ConstrainDouble specifying the volume or range of volumes which are acceptable and/or required.

Properties of image tracks

whiteBalanceMode
A String specifying one of "none", "manual", "single-shot", or "continuous".
exposureMode
A String specifying one of "none", "manual", "single-shot", or "continuous".
focusMode
A String specifying one of "none", "manual", "single-shot", or "continuous".
pointsOfInterest
The pixel coordinates on the sensor of one or more points of interest. This is either an object in the form { x:value, y:value } or an array of such objects, where value  is a double-precision integer.
exposureCompensation
A ConstrainDouble (a double-precision integer) specifying f-stop adjustment by up to ±3. 
colorTemperature
A ConstrainDouble (a double-precision integer) specifying a desired color temperature in degrees kelvin.
iso
A ConstrainDouble (a double-precision integer) specifying a desired iso setting.
brightness
A ConstrainDouble (a double-precision integer) specifying a desired brightness setting.
contrast
A ConstrainDouble (a double-precision integer) specifying the degree of difference between light and dark.
saturation
A ConstrainDouble (a double-precision integer) specifying the degree of color intensity.
sharpness
A ConstrainDouble (a double-precision integer) specifying the intensity of edges.
focusDistance
A ConstrainDouble (a double-precision integer) specifying distance to a focused object.
zoom
A ConstrainDouble (a double-precision integer) specifying the desired focal length.
torch
A Boolean defining whether the fill light is continuously connected, meaning it stays on as long as the track is active.

Properties of video tracks

aspectRatio
A ConstrainDouble specifying the video aspect ratio or range of aspect ratios which are acceptable and/or required.
facingMode
A ConstrainDOMString object specifying a facing or an array of facings which are acceptable and/or required.
frameRate
A ConstrainDouble specifying the frame rate or range of frame rates which are acceptable and/or required.
height
A ConstrainLong specifying the video height or range of heights which are acceptable and/or required.
width
A ConstrainLong specifying the video width or range of widths which are acceptable and/or required.
resizeMode
A ConstrainDOMString object specifying a mode or an array of modes the UA can use to derive the resolution of a video track. Allowed values are "none" and "crop-and-scale". "none" means that the UA uses the resolution provided by the camera, its driver or the OS. "crop-and-scale" means that the UA can use cropping and downscaling on the camera output  in order to satisfy other constraints that affect the resolution.

Specifications

Specification Status Comment
Media Capture and Streams
The definition of 'applyConstraints()' in that specification.
Candidate Recommendation Initial definition.
MediaStream Image Capture
The definition of 'applyConstraints()' in that specification.
Working Draft Adds image constraints.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 59Edge Full support YesFirefox ? IE ? Opera Full support 46Safari ? WebView Android Full support 59Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support 46Safari iOS ? Samsung Internet Android ?
aspectRatioChrome Full support YesEdge ? Firefox No support NoIE No support NoOpera Full support YesSafari ? WebView Android ? Chrome Android Full support YesEdge Mobile ? Firefox Android Full support 29Opera Android ? Safari iOS ? Samsung Internet Android ?
autoGainControlChrome Full support YesEdge ? Firefox Full support 55
Full support 55
Full support 46
Prefixed
Prefixed Requires the vendor prefix: moz
IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 55
Full support 55
Full support 46
Prefixed
Prefixed Requires the vendor prefix: moz
Opera Android ? Safari iOS ? Samsung Internet Android ?
channelCountChrome Full support YesEdge ? Firefox No support NoIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
deviceIdChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
echoCancellationChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
facingModeChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
frameRateChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
groupIdChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
heightChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
latencyChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?
noiseSuppressionChrome Full support YesEdge ? Firefox Full support 55
Full support 55
Full support 46
Prefixed
Prefixed Requires the vendor prefix: moz
IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 55
Full support 55
Full support 46
Prefixed
Prefixed Requires the vendor prefix: moz
Opera Android ? Safari iOS ? Samsung Internet Android ?
sampleRateChrome Full support YesEdge ? Firefox No support NoIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
sampleSizeChrome Full support YesEdge ? Firefox No support NoIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
volumeChrome Full support YesEdge ? Firefox No support NoIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
widthChrome Full support YesEdge ? Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

ドキュメントのタグと貢献者

最終更新者: guidou,