CaptureController: phương thức resetZoomLevel()
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.
Phương thức resetZoomLevel() của giao diện CaptureController đặ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.
Phương thức resetZoomLevel() phải được gọi thông qua kích hoạt tạm thời. Ngoài ra, người dùng sẽ được hỏi quyền chia sẻ tab khi lần đầu cố gắng chụp màn hình; nếu người dùng từ chối cấp quyền thì mức thu phóng sẽ không thể thay đổi ngay cả khi có kích hoạt tạm thời.
Syntax
resetZoomLevel()
Parameters
Không có.
Return value
Exceptions
InvalidStateErrorDOMException-
Có một nỗ lực gọi
resetZoomLevel()mà không có kích hoạt tạm thời. NotAllowedErrorDOMException-
Được ném ra khi:
- Permissions Policy
của trang không cho phép trang sử dụng Captured Surface Control API.captured-surface-control - Người dùng đã từ chối rõ ràng quyền chụp bề mặt hiển thị.
- Permissions Policy
Examples
>Cách dùng resetZoomLevel() cơ bản
Đoạn mã sau thêm một trình lắng nghe sự kiện vào một nút để khi nút được nhấn, hàm resetZoom() được gọi. Hàm này sẽ gọi phương thức resetZoomLevel(), đặt lại mức thu phóng của bề mặt đang được chụp về 100.
// Create controller and start capture
const controller = new CaptureController();
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia({
controller,
});
// ...
resetBtn.addEventListener("click", resetZoom);
async function resetZoom() {
await controller.resetZoomLevel();
}
Xem Using the Captured Surface Control API để có ví dụ đầy đủ đang hoạt động.
Specifications
| Specification |
|---|
| Captured Surface Control> # dom-capturecontroller-resetzoomlevel> |