MediaTrackSupportedConstraints
dictionary's
logicalSurface
property indicates whether or not the
logicalSurface
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()
.
isLogicalSurfaceSupported = supportedConstraints.logicalSurface;
A Boolean value which is
true
若
logicalSurface
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
logicalSurface
constraint (requesting that only logical display surfaces—those which may not be entirely visible onscreen—be included among the options available to the user) 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.logicalSurface) {
displayMediaOptions.video.logicalSurface = "monitor";
}
try {
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
} catch(err) {
/* handle the error */
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Screen Capture
The definition of 'MediaTrackSupportedConstraints.logicalSurface' in that specification. |
工作草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
logicalSurface
|
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()