ConstrainBoolean
dictionary is used to specify a constraint for a property whose value is a Boolean value. You can specify an exact value which must be matched, an ideal value that should be matched if at all possible, and a fallback value to attempt to match once all more specific constraints have been applied.
exact
A Boolean which indicates a value the property must have.
ideal
A Boolean value indicating the ideal, but not required, value the property should ideally have. If possible, this value will be used, but the user agent will use the other value if it needs to in order to come up with a workable configuration.
You can also specify the value of the property as simply
true
or
false
, in which case the user agent will use that value if possible once all efforts have been made to match the
exact
and
ideal
values for other properties.
| 规范 | 状态 | 注释 |
|---|---|---|
|
媒体捕获和流
The definition of 'ConstrainBoolean' in that specification. |
候选推荐 | 初始定义 |
Technically,
ConstrainBoolean
is actually based on an intermediary dictionary named
ConstrainBooleanParameters
, which adds
exact
and
ideal
to the simple Boolean type. However, for the sake of documentation clarity, the intermediate type (present only because of quirks in
WebIDL
syntax) is ignored here.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConstrainBoolean
|
Chrome Yes | Edge ≤79 | Firefox 50 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 50 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
MediaTrackConstraints
MediaTrackCapabilities
MediaTrackSupportedConstraints
ConstrainBoolean
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
MediaTrackSupportedConstraints
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()