MediaTrackConstraints.displaySurface - Web APIs 编辑

The MediaTrackConstraints dictionary's displaySurface property is a 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 ignore any constraints they're unfamiliar with.

Syntax

var constraintsObject = { displaySurface: constraint };

constraintsObject.displaySurface = constraint;

Value

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.

See How constraints are defined in Capabilities, constraints, and settings for an explanation of how to define constraints.

Usage notes

You can check the setting selected by the user agent after the display media has been created by getDisplayMedia() by calling getSettings() on the display media's video MediaStreamTrack, then checking the value of  the returned MediaTrackSettings object's displaySurface object.

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.

Examples

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

Specifications

SpecificationStatusComment
Screen Capture
The definition of 'MediaTrackConstraints.displaySurface' in that specification.
UnknownInitial specification.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:85 次

字数:5978

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文