Mozilla's getting a new look. What do you think? https://mzl.la/brandsurvey

MediaTrackConstraints

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 specify one or both of the following:

  • An exact value or range of values which the corresponding property must fall into in order to be acceptable. No configurations of media in which this property fails to match this value or range will be accepted.
  • An ideal value or range of values which the corresponding property should ideally fall into. Configurations outside this range may be accepted as a fallback if none that meet all the constraints can be found.

To learn more about how constraints work, see "Capabilities and constraints" in Media Capture and Streams API (Media Streams).

Properties

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

width
A ConstrainLongRange specifying the video width or range of widths which are acceptable and/or required.
height
A ConstrainLongRange specifying the video height or range of heights which are acceptable and/or required.
aspectRatio
A ConstrainLDoubleRange specifying the video aspect ratio or range of aspect ratios which are acceptable and/or required.
frameRate
A ConstrainLDoubleRange specifying the frame rate or range of frame rates which are acceptable and/or required.
facingMode
A ConstrainDOMString specifying a facing or an array of facings which are acceptable and/or required.
volume
A ConstrainLDoubleRange specifying the volume or range of volumes which are acceptable and/or required.
sampleRate
A ConstrainLongRange specifying the sample rate or range of sample rates which are acceptable and/or required.
sampleSize
A ConstrainLongRange specifying the sample size or range of sample sizes which are acceptable and/or required.
echoCancellation
A ConstrainBoolean specifying whether or not echo cancellation is required or preferred and/or required.
latency
A ConstrainLDoubleRange specifying the latency or range of latencies which are acceptable and/or required.
channelCount
A ConstrainLongRange specifying the channel count or range of channel counts which are acceptable and/or required.
deviceId
A ConstrainDOMString specifying a device ID or an array of device IDs which are acceptable and/or required.
groupId
A ConstrainDOMString specifying a group ID or an array of group IDs which are acceptable and/or required.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy
 Last updated by: Sheppy,