MediaTrackSupportedConstraints.aspectRatio
        
        
          Limited availability
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is not Baseline because it does not work in some of the most widely-used browsers.
MediaTrackSupportedConstraints 辞書の aspectRatio プロパティは読み取り専用の論理値で、 MediaDevices.getSupportedConstraints() が返すオブジェクトに存在(true に設定)するならば、ユーザーエージェントが aspectRatio 制約に対応しています。制約に対応していない場合、リストには含まれなくなりますので、この値が false になることはありません。
対応している制約の辞書は navigator.mediaDevices.getSupportedConstraints() を呼び出すことで取得できます。
値
ユーザーエージェントが aspectRatio 制約に対応している場合、このプロパティが辞書に現れます(値は常に trueです)。このプロパティがない場合は、対応している制約の辞書から欠落しており、その値を見ようとすると undefined が返されます。
例
js
let result = document.getElementById("result");
if (navigator.mediaDevices.getSupportedConstraints().aspectRatio) {
  result.textContent = "Supported!";
} else {
  result.textContent = "Not supported!";
}
結果
仕様書
| Specification | 
|---|
| Media Capture and Streams> # dom-mediatrackconstraintset-aspectratio> | 
ブラウザーの互換性
Loading…