Web/API/MediaTrackSupportedConstraints/logicalSurface
The 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()
.
Syntax
isLogicalSurfaceSupported = supportedConstraints.logicalSurface;
Value
A Boolean value which is true
if the logicalSurface
constraint is supported by the device and user agent.
Example
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 */
}
}
Specifications
Specification | Status | Comment |
Screen CaptureThe definition of 'MediaTrackSupportedConstraints.logicalSurface' in that specification. | Working Draft | Initial definition |
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
logicalSurface
|
Chrome
No support No |
Edge
No support No |
Firefox
No support No |
IE
No support No |
Opera
Full support Yes |
Safari
? |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
? |
Safari iOS
? |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
- Screen Capture API
- Using the screen capture API
- Capabilities, constraints, and settings
MediaDevices.getDisplayMedia()
MediaStreamTrack.getConstraints()
MediaStreamTrack.applyConstraints()
MediaStreamTrack.getSettings()
MediaTrackSupportedConstraints.logicalSurface by Mozilla Contributors is licensed under CC-BY-SA 2.5.