CaptureController
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Giao diện CaptureController cung cấp các phương thức có thể dùng để thao tác thêm trên một bề mặt hiển thị đang được chụp lại (được chụp qua MediaDevices.getDisplayMedia())
Một đối tượng CaptureController được liên kết với một bề mặt hiển thị đang được chụp bằng cách truyền nó vào lời gọi getDisplayMedia() làm giá trị của thuộc tính controller trong đối tượng tùy chọn.
Constructor
CaptureController()Experimental-
Tạo một thể hiện đối tượng
CaptureControllermới.
Instance properties
zoomLevelExperimental-
Mức thu phóng hiện tại của bề mặt hiển thị đang được chụp.
Instance methods
decreaseZoomLevel()Experimental-
Giảm mức thu phóng của bề mặt hiển thị đang được chụp xuống một nấc.
forwardWheel()Experimental-
Bắt đầu chuyển tiếp các sự kiện
wheelphát ra trên phần tử được tham chiếu tới viewport của một bề mặt hiển thị đang được chụp có liên kết. getSupportedZoomLevels()Experimental-
Trả về các mức thu phóng khác nhau mà bề mặt hiển thị đang được chụp hỗ trợ.
increaseZoomLevel()Experimental-
Tăng mức thu phóng của bề mặt hiển thị đang được chụp lên một nấc.
resetZoomLevel()Experimental-
Đặt lại mức thu phóng của bề mặt hiển thị đang được chụp về mức ban đầu là
100. setFocusBehavior()Experimental-
Kiểm soát việc tab hoặc cửa sổ đang được chụp có được nhận tiêu điểm hay tiêu điểm sẽ vẫn nằm ở tab chứa ứng dụng chụp.
Events
zoomlevelchangeExperimental-
Phát ra khi mức thu phóng của bề mặt hiển thị đang được chụp thay đổi.
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
| Specification |
|---|
| Screen Capture> # dom-capturecontroller> |