Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaTrackSupportedConstraints
  4. aspectRatio

MediaTrackSupportedConstraints: aspectRatio property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

TheMediaTrackSupportedConstraints dictionary'saspectRatio property is a read-only Boolean value which is present (and set totrue) in the object returned byMediaDevices.getSupportedConstraints() if and only if theuser agent supports theaspectRatio constraint.If the constraint isn't supported, it's not included in the list, so this value will never befalse.

You can access the supported constraints dictionary by callingnavigator.mediaDevices.getSupportedConstraints().

Value

This property is present in the dictionary (and its value is alwaystrue)if the user agent supports theaspectRatio constraint. If the propertyisn't present, this property is missing from the supported constraints dictionary, andyou'll getundefined if you try to look at its value.

Examples

<div></div>
#result {  font:    14px "Arial",    sans-serif;}
js
const result = document.getElementById("result");const supported = navigator.mediaDevices.getSupportedConstraints().aspectRatio;result.textContent = supported ? "Supported!" : "Not supported!";

Result

Specifications

Specification
Media Capture and Streams
# dom-mediatrackconstraintset-aspectratio

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp