CaptureController: thuộc tính zoomLevel

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Thuộc tính chỉ đọc zoomLevel của giao diện CaptureController trả về mức thu phóng hiện tại của bề mặt hiển thị đang được chụp.

Value

Một số biểu diễn mức thu phóng hiện tại của bề mặt hiển thị đang được chụp.

Examples

Cách dùng zoomLevel cơ bản

Trong bản demo trực tiếp của chúng tôi, được trình bày trong Using the Captured Surface Control API, chúng tôi dùng thuộc tính zoomLevel bên trong hàm xử lý sự kiện cho sự kiện zoomlevelchange của controller. Khi sự kiện phát ra, giá trị zoomLevel đã cập nhật sẽ được ghi vào một phần tử <output>.

js
// Create controller and start capture
const controller = new CaptureController();
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia({
  controller,
});

// ...

controller.addEventListener(
  "zoomlevelchange",
  () => (outputElem.textContent = `${controller.zoomLevel}%`),
);

Xem Using the Captured Surface Control API để có ví dụ đầy đủ đang hoạt động.

Specifications

Specification
Captured Surface Control
# dom-capturecontroller-zoomlevel

Browser compatibility

See also