MediaTrackSupportedConstraints.logicalSurface - Web APIs 编辑
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 Capture The definition of 'MediaTrackSupportedConstraints.logicalSurface' in that specification. | Working Draft | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论