Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaTrackSupportedConstraints
  4. logicalSurface

MediaTrackSupportedConstraints: logicalSurface property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

TheMediaTrackSupportedConstraints dictionary'slogicalSurface property indicates whether or not thelogicalSurface constraint is supported by the user agent and the device on which the content is being used.

The supported constraints list is obtained by callingnavigator.mediaDevices.getSupportedConstraints().

Value

A boolean value which istrue if thelogicalSurface constraint is supported by the device and user agent.

Example

This method sets up the constraints object specifying the options for the call togetDisplayMedia(). It adds thelogicalSurface constraint (requesting that only logical displaysurfaces—those which may not be entirely visible onscreen—be included among the optionsavailable to the user) only if it is known to be supported by the browser. Capturing isthen started by callinggetDisplayMedia() and attaching the returned streamto the video element referenced by the variablevideoElem.

js
async function capture() {  const supportedConstraints = navigator.mediaDevices.getSupportedConstraints();  const 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
Screen Capture
# dom-mediatrackconstraintset-logicalsurface

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp