The MediaStreamConstraints
dictionary is used when calling getUserMedia()
to specify what kinds of tracks should be included in the returned MediaStream
, and, optionally, to establish constraints for those tracks' settings.
To learn more about how constraints work, see Capabilities, constraints, and settings.
Properties
Some combination—but not necessarily all—of the following properties will exist on the object.
Track constraints
audio
- Either a Boolean (which indicates whether or not an audio track is requested) or a
MediaTrackConstraints
object providing the constraints which must be met by the audio track included in the returnedMediaStream
. If constraints are specified, an audio track is inherently requested. video
- Either a Boolean (which indicates whether or not a video track is requested) or a
MediaTrackConstraints
object providing the constraints which must be met by the video track included in the returnedMediaStream
. If constraints are specified, a video track is inherently requested.
Security
peerIdentity
- A
DOMString
identifying the peer who has sole access to the stream. If this property is specified, only the indicated peer can receive and use the stream. Streams isolated in this way can only be displayed in a media element (<audio>
or<video>
) where the content is protected just as if CORS cross-origin rules were in effect. When a peer identity is set,MediaStreamTrack
s from that peer have theirisolated
flag set totrue
.
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.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaStreamConstraints | Chrome Full support 53 | Edge Full support ≤79 | Firefox Full support 38 | IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support 53 | Chrome Android Full support 53 | Firefox Android Full support 38 | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support 6.0 |
audio | Chrome Full support Yes | Edge Full support ≤79 | Firefox Full support 38 | IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 38 | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support Yes |
video | Chrome Full support Yes | Edge Full support ≤79 | Firefox Full support 38 | IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 38 | 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