媒体追踪约束 - Web API 接口参考 编辑

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", "sigle-shot", or "continuous".
exposureMode
A String specifying one of "none", "manual", "sigle-shot", or "continuous".
focusMode
A String specifying one of "none", "manual", "sigle-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 whter the fill light 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.

Specifications

SpecificationStatusComment
Media Capture and Streams
applyConstraints()
Candidate RecommendationInitial definition.
MediaStream Image Capture
applyConstraints()
Working DraftAdds image constraints.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support59??46?
deviceId59??46?
groupId59??46?
Audio track properties未实现??未实现?
Image track properties63??50?
Video track properties59??46?
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support5959??46?
deviceId5959??46?
groupId5959??46?
Audio track properties未实现未实现??未实现?
Image track properties6363??50?
Video track properties5959??46?

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:132 次

字数:18525

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文