MediaTrackSupportedConstraints
dictionary's
displaySurface
property indicates whether or not the
displaySurface
constraint is supported by the user agent and the device on which the content is being used.
The supported constraints list is obtained by calling
navigator.mediaDevices.getSupportedConstraints()
.
isDisplaySurfaceSupported = supportedConstraints.displaySurface;
A Boolean value which is
true
若
displaySurface
constraint is supported by the device and user agent.
This method sets up the constraints object specifying the options for the call to
getDisplayMedia()
. It adds the
displaySurface
constraint (requesting that only full-screen sharing be allowed) only if it is known to be supported by the browser. Capturing is then started by calling
getDisplayMedia()
and attaching the returned stream to the video element referenced by the variable
videoElem
.
async function capture() {
let supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
let displayMediaOptions = {
video: {
},
audio: false;
};
if (supportedConstraints.displaySurface) {
displayMediaOptions.video.displaySurface = "monitor";
}
try {
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
} catch(err) {
/* handle the error */
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Screen Capture
The definition of 'MediaTrackSupportedConstraints.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 |
完整支持
不支持
兼容性未知
MediaDevices.getDisplayMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaStreamTrack.getSettings()
MediaTrackSupportedConstraints
AudioStreamTrack
BlobEvent
CanvasCaptureMediaStream
ConstrainBoolean
ConstrainDOMString
ConstrainDouble
ConstrainLong
DoubleRange
HTMLCanvasElement.captureStream()
LongRange
MediaDevices
MediaStream
MediaStreamTrack
MediaStreamTrackEvent
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackSettings
Navigator.mediaDevices
NavigatorUserMedia
NavigatorUserMediaError
VideoStreamTrack
navigator.mediaDevices.getUserMedia()