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 .
Some combination—but not necessarily all—of the following properties will exist on the object.
audio
MediaTrackConstraints
object providing the constraints which must be met by the audio track included in the returned
MediaStream
. If constraints are specified, an audio track is inherently requested.
视频
MediaTrackConstraints
object providing the constraints which must be met by the video track included in the returned
MediaStream
. If constraints are specified, a video track is inherently requested.
peerIdentity
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 their
isolated
flag set to
true
.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaStreamConstraints
|
Chrome 53 | Edge ≤79 | Firefox 38 | IE No | Opera Yes | Safari ? | WebView Android 53 | Chrome Android 53 | Firefox Android 38 | Opera Android Yes | Safari iOS ? | Samsung Internet Android 6.0 |
audio
|
Chrome Yes | Edge ≤79 | Firefox 38 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 38 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
视频
|
Chrome Yes | Edge ≤79 | Firefox 38 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 38 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
MediaDevices.getUserMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaDevices.getSupportedConstraints()
MediaTrackSupportedConstraints
MediaStreamTrack.getSettings()
MediaStreamConstraints
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
MediaTrackSupportedConstraints
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()