MediaTrackConstraints
dictionary's
displaySurface
特性为
ConstrainDOMString
describing the requested or mandatory constraints placed upon the value of the
displaySurface
constrainable property.
This is used to specify the type or types of display surfaces which
getDisplayMedia()
will let the user select among for sharing purposes.
If needed, you can determine whether or not this constraint is supported by checking the value of
MediaTrackSupportedConstraints.displaySurface
as returned by a call to
MediaDevices.getSupportedConstraints()
. However, typically this is unnecessary since browsers will simply ignore any constraints they're unfamiliar with.
var constraintsObject = { displaySurface: constraint };
constraintsObject.displaySurface = constraint;
A
ConstrainDOMString
which specifies the type of display surface that's being captured. This value
does not
affect the list of display sources in the browser's user interface.
见 How constraints are defined in Capabilities, constraints, and settings for an explanation of how to define constraints.
You can check the setting selected by the user agent after the display media has been created by
getDisplayMedia()
通过调用
getSettings()
on the display media's video
MediaStreamTrack
, then checking the value of the returned
MediaTrackSettings
对象的
displaySurface
对象。
For example, if your app needs to know that the surface being shared is a monitor or application—meaning that there's possibly a non-content backdrop—it can use code similar to this:
let mayHaveBackdropFlag = false;
let displaySurface = displayStream.getVideoTracks()[0].getSettings().displaySurface;
if (displaySurface === "monitor" || displaySurface ==="application") {
mayHaveBackdropFlag = true;
}
Following this code,
mayHaveBackdrop
is
true
if the display surface contained in the stream is of type
monitor
or
application
; either of these
may
have non-content backdrop areas. Later code can use this flag to determine whether or not to perform special processing, such as to remove or replace the backdrop, or to "cut" the individual display areas out of the received frames of video.
Here are some example constraints objects for
getDisplayMedia()
that make use of the
displaySurface
property. In addition, see
Example: Constraint exerciser
in
Capabilities, constraints, and settings
for a complete example showing how constraints are used.
TBD
| 规范 | 状态 | 注释 |
|---|---|---|
|
Screen Capture
The definition of 'MediaTrackConstraints.displaySurface' in that specification. |
未知 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
displaySurface
|
Chrome No | Edge No | Firefox No | IE No | Opera Yes | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
完整支持
不支持
兼容性未知
MediaTrackConstraints
MediaDevices.getSupportedConstraints()
MediaTrackSupportedConstraints
MediaTrackConstraints
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackSettings
MediaTrackSupportedConstraints
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()