The 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.
Properties
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.
Specifications
| Specification | Status | Comment |
| Media Capture and StreamsThe definition of 'ConstrainBoolean' in that specification. | Candidate Recommendation | Initial definition |
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.
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConstrainBoolean
|
Chrome
Full support Yes |
Edge
Full support ≤79 |
Firefox
Full support 50 |
IE
No support No |
Opera
Full support Yes |
Safari
? |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 50 |
Opera Android
Full support Yes |
Safari iOS
? |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
- Media Capture and Streams API
- Capabilities, constraints, and settings
MediaTrackConstraintsMediaTrackCapabilitiesMediaTrackSupportedConstraints
ConstrainBoolean by Mozilla Contributors is licensed under CC-BY-SA 2.5.