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 |
瀏覽器相容性
載入中…