CaptureController
Khả dụng hạn chế
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()Thử nghiệm-
Tạo một thể hiện đối tượng
CaptureControllermới.
Instance properties
zoomLevelThử nghiệm-
Mức thu phóng hiện tại của bề mặt hiển thị đang được chụp.
Instance methods
decreaseZoomLevel()Thử nghiệm-
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()Thử nghiệm-
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()Thử nghiệm-
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()Thử nghiệm-
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()Thử nghiệm-
Đặ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()Thử nghiệm-
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
zoomlevelchangeThử nghiệm-
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
| Thông số kỹ thuật |
|---|
| Screen Capture> # dom-capturecontroller> |