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.
Some combination—but not necessarily all—of the following properties will exist on the object.
deviceId
ConstrainDOMString
object specifying a device ID or an array of device IDs which are acceptable and/or required.groupId
ConstrainDOMString
object specifying a group ID or an array of group IDs which are acceptable and/or required.autoGainControl
ConstrainBoolean
object which specifies whether automatic gain control is preferred and/or required.channelCount
ConstrainLong
specifying the channel count or range of channel counts which are acceptable and/or required.echoCancellation
ConstrainBoolean
object specifying whether or not echo cancellation is preferred and/or required.latency
ConstrainDouble
specifying the latency or range of latencies which are acceptable and/or required.noiseSuppression
ConstrainBoolean
which specifies whether noise suppression is preferred and/or required.sampleRate
ConstrainLong
specifying the sample rate or range of sample rates which are acceptable and/or required.sampleSize
ConstrainLong
specifying the sample size or range of sample sizes which are acceptable and/or required.volume
ConstrainDouble
specifying the volume or range of volumes which are acceptable and/or required.whiteBalanceMode
String
specifying one of "none"
, "manual"
, "sigle-shot"
, or "continuous"
.exposureMode
String
specifying one of "none"
, "manual"
, "sigle-shot"
, or "continuous"
.focusMode
String
specifying one of "none"
, "manual"
, "sigle-shot"
, or "continuous"
.pointsOfInterest
exposureCompensation
ConstrainDouble
(a double-precision integer) specifying f-stop adjustment by up to ±3. colorTemperature
ConstrainDouble
(a double-precision integer) specifying a desired color temperature in degrees kelvin.iso
ConstrainDouble
(a double-precision integer) specifying a desired iso setting.brightness
ConstrainDouble
(a double-precision integer) specifying a desired brightness setting.contrast
ConstrainDouble
(a double-precision integer) specifying the degree of difference between light and dark.saturation
ConstrainDouble
(a double-precision integer) specifying the degree of color intensity.sharpness
ConstrainDouble
(a double-precision integer) specifying the intensity of edges.focusDistance
ConstrainDouble
(a double-precision integer) specifying distance to a focused object.zoom
ConstrainDouble
(a double-precision integer) specifying the desired focal length.torch
Boolean
whter the fill light continuously connected, meaning it stays on as long as the track is active.aspectRatio
ConstrainDouble
specifying the video aspect ratio or range of aspect ratios which are acceptable and/or required.facingMode
ConstrainDOMString
object specifying a facing or an array of facings which are acceptable and/or required.frameRate
ConstrainDouble
specifying the frame rate or range of frame rates which are acceptable and/or required.height
ConstrainLong
specifying the video height or range of heights which are acceptable and/or required.width
ConstrainLong
specifying the video width or range of widths which are acceptable and/or required.Specification | Status | Comment |
---|---|---|
Media Capture and Streams The definition of 'applyConstraints()' in that specification. | Editor's Draft | Initial definition. |
MediaStream Image Capture The definition of 'applyConstraints()' in that specification. | Working Draft | Adds image constraints. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 59 | ? | ? | 46 | ? |
deviceId | 59 | ? | ? | 46 | ? |
groupId | 59 | ? | ? | 46 | ? |
Audio track properties | No support | ? | ? | No support | ? |
Image track properties | 63 | ? | ? | 50 | ? |
Video track properties | 59 | ? | ? | 46 | ? |
Feature | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 59 | 59 | ? | ? | 46 | ? |
deviceId | 59 | 59 | ? | ? | 46 | ? |
groupId | 59 | 59 | ? | ? | 46 | ? |
Audio track properties | No support | No support | ? | ? | No support | ? |
Image track properties | 63 | 63 | ? | ? | 50 | ? |
Video track properties | 59 | 59 | ? | ? | 46 | ? |
MediaDevices.getUserMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaDevices.getSupportedConstraints()
MediaTrackSupportedConstraints
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/MediaTrackConstraints