MediaTrackSettings: aspectRatio property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheMediaTrackSettings dictionary'saspectRatio property is a double-precision floating-point number indicating theaspect ratio of theMediaStreamTrack as currently configured.This lets you determine what value was selected to comply with your specified constraints for this property's value as described in theMediaTrackConstraints.aspectRatio property you provided when calling eithergetUserMedia() orMediaStreamTrack.applyConstraints().
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
A double-precision floating-point number indicating the current configuration of thetrack's aspect ratio. The aspect ratio is computed by taking the track's width, dividingby its height, and rounding the result to ten decimal places. For example, the standard16:9 high-definition aspect ratio can be computed as 1920/1080, or 1.7777777778.
Examples
See theConstraint exerciser example.
Specifications
| Specification |
|---|
| Media Capture and Streams> # dom-mediatrackconstraintset-aspectratio> |