CaptureController
CaptureController 接口提供了可用于进一步操作已捕获显示表面(通过 MediaDevices.getDisplayMedia() 捕获)的方法。
通过将 CaptureController 对象作为选项对象中 controller 属性的值传递给 getDisplayMedia() 调用,可以将其与捕获的显示表面关联起来。
构造函数
CaptureController()Experimental-
创建一个新的
CaptureController对象实例。
实例属性
zoomLevelExperimental-
捕获的显示表面的当前缩放级别。
实例方法
decreaseZoomLevel()Experimental-
将捕获的显示表面的缩放级别降低一个增量。
forwardWheel()Experimental-
开始将引用元素上触发的
wheel事件转发到关联的捕获显示表面的视口。 getSupportedZoomLevels()Experimental-
返回捕获的显示表面支持的不同缩放级别。
increaseZoomLevel()Experimental-
将捕获的显示表面的缩放级别提高一个增量。
resetZoomLevel()Experimental-
将捕获的显示表面的缩放重置为其初始级别,即
100。 setFocusBehavior()Experimental-
控制捕获的选项卡或窗口是否会获得焦点,或者焦点是否会保留在包含捕获应用程序的选项卡上。
事件
zoomlevelchangeExperimental-
当捕获的显示表面的缩放级别发生变化时触发。
示例
js
// 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");
}
规范
| 规范 |
|---|
| 屏幕捕获 # dom-capturecontroller |
浏览器兼容性
加载中…