Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

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 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

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 required or preferred and/or required.
latency
A ConstrainDouble specifying the latency or range of latencies which are acceptable 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 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.

See also

文档标签和贡献者

 此页面的贡献者: Sheppy
 最后编辑者: Sheppy,