MediaStreamTrack.getConstraints()
The getConstraints()
method of the MediaStreamTrack
interface returns a MediaTrackConstraints
object containing the set of constraints most recently established for the track using a prior call to applyConstraints()
. These constraints indicate values and ranges of values that the Web site or application has specified are acceptable for the included constrainable properties.
Constraints can be used to ensure that the media meets certain guidelines you prefer. For example, you may prefer high density video but require that the frame rate be a little low to help keep the data rate low enough not overtax the network. Constraints can also specify ideal and/or acceptable sizes or ranges of sizes. See "Capabilities and constraints" in Media Capture and Streams API (Media Streams) for details on how to work with constrainable properties.
Syntax
var constraints = MediaStreamTrack.getConstraints();
Parameters
None.
Return value
A MediaTrackConstraints
object which indicates the constrainable properties the Web site or app most recently set using applyConstraints()
. The properties in the returned object are listed in the same order as when they were set, and no properties not specifically set by the site or app are included.
The returned set of constraints may not actually match those in effect; if any of the constraints couldn't be met, they are still included in the returned object as originally set by the site's code. To get the currently active settings for all constrainable properties, you should instead call getSettings()
.
Specifications
Specification | Status | Comment |
---|---|---|
Media Capture and Streams The definition of 'getConstraints()' in that specification. |
Editor's Draft | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 53.0 | 50 (50) | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | No support | 53.0 | 50.0 (50) | ? | ? | ? | 52.0 |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/mediastreamtrack/getconstraints