大网数据广告活动
Web 标准与前端开发

CaptureController

· 52CE 我爱测

The **`CaptureController`** interface provides methods that can be used to further manipulate a captured display surface (captured via MediaDevices.getDisplayMedia())

Screen Capture API

The CaptureController interface provides methods that can be used to further manipulate a captured display surface (captured via MediaDevices.getDisplayMedia())

A CaptureController object is associated with a captured display surface by passing it into a getDisplayMedia() call as the value of the options object's controller property.

Constructor

  • CaptureController.CaptureController
    • : Creates a new CaptureController object instance.

Instance properties

  • CaptureController.zoomLevel
    • : The captured display surface's current zoom level.

Instance methods

  • CaptureController.decreaseZoomLevel
    • : Decreases the captured display surface's zoom level by one increment.
  • CaptureController.forwardWheel
    • : Starts forwarding Element.wheel_event events fired on the referenced element to the viewport of an associated captured display surface.
  • CaptureController.getSupportedZoomLevels
    • : Returns the different zoom levels supported by the captured display surface.
  • CaptureController.increaseZoomLevel
    • : Increases the captured display surface's zoom level by one increment.
  • CaptureController.resetZoomLevel
    • : Resets the captured display surface's zoom to its initial level, which is 100.
  • CaptureController.setFocusBehavior
    • : Controls whether the captured tab or window will be focused or whether the focus will remain with the tab containing the capturing app.

Events

  • CaptureController.zoomlevelchange_event
    • : Fires when the captured display surface's zoom level changes.

Examples

// Create a new CaptureController instance
const controller = new CaptureController();

// Prompt the user to share a tab, window, or screen.
const stream = await navigator.mediaDevices.getDisplayMedia({ controller });

// Query the displaySurface value of the captured video track
const [track] = stream.getVideoTracks();
const displaySurface = track.getSettings().displaySurface;

if (displaySurface === "browser") {
  // Focus the captured tab.
  controller.setFocusBehavior("focus-captured-surface");
} else if (displaySurface === "window") {
  // Do not move focus to the captured window.
  // Keep the capturing page focused.
  controller.setFocusBehavior("no-focus-change");
}

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。