getSupportedConstraints
()
方法在
MediaDevices
interface returns an object based on the
MediaTrackSupportedConstraints
dictionary, whose member fields each specify one of the constrainable properties the
用户代理
understands.
var supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
None.
A new object based on the
MediaTrackSupportedConstraints
dictionary listing the constraints supported by the user agent. Because only constraints supported by the user agent are included in the list, each of these Boolean properties has the value
true
.
This example outputs a list of the constraints supported by your browser.
<p>The following media constraints are supported by your browser:</p> <ul id="constraintList"> </ul>
body {
font: 15px Arial, sans-serif;
}
let constraintList = document.getElementById("constraintList");
let supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
for (let constraint in supportedConstraints) {
if (supportedConstraints.hasOwnProperty(constraint)) {
let elem = document.createElement("li");
elem.innerHTML = "<code>" + constraint + "</code>";
constraintList.appendChild(elem);
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
媒体捕获和流
The definition of 'getSupportedConstraints()' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getSupportedConstraints
|
Chrome 53 | Edge 12 | Firefox 44 | IE No | Opera 40 | Safari 11 | WebView Android 53 | Chrome Android 52 | Firefox Android 50 | Opera Android 41 | Safari iOS 11 | Samsung Internet Android 6.0 |
完整支持
不支持
MediaDevices
enumerateDevices()
getDisplayMedia()
getSupportedConstraints()
getUserMedia()
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
MediaTrackSupportedConstraints
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()