MediaTrackConstraints: aspectRatio property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheMediaTrackConstraints dictionary'saspectRatio property is aConstrainDouble describing the requested or mandatory constraints placed upon the value of theaspectRatio constrainable property.
If needed, you can determine whether or not this constraint is supported by checkingthe value ofMediaTrackSupportedConstraints.aspectRatio as returned by acall toMediaDevices.getSupportedConstraints(). However, typically thisis unnecessary since browsers will ignore any constraints they're unfamiliar with.
In this article
Value
AConstrainDouble describing the acceptable or required value(s) for avideo track'saspect ratio. The value is the width divided by the height and is roundedto ten decimal places. For example, the standard high-definition video aspect ratio of16:9 can be computed as 1920/1080, or 1.7777777778.
If this value is a number, the user agent will attempt to obtain media whose aspectratio is as close as possible to this number given the capabilities of the hardware andthe other constraints specified. Otherwise, the value of thisConstrainDouble will guide the user agent in its efforts to provide anexact match to the required aspect ratio (ifexact is specified or bothmin andmax are provided and have the same value) or to abest-possible value.
Examples
See theConstraint exerciser example.
Specifications
| Specification |
|---|
| Media Capture and Streams> # dom-mediatrackconstraintset-aspectratio> |