Screen Capture API
The zoomLevel read-only property of the CaptureController interface returns the captured display surface's current zoom level.
Value
A number representing the current zoom level of the captured display surface.
Examples
Basic zoomLevel usage
In our live demo, shown in Using the Captured Surface Control API, we use the zoomLevel property inside an event handler function for the controller's CaptureController.zoomlevelchange_event event. When the event fires, the updated zoomLevel is written to an <output> element.
// Create controller and start capture
const controller = new CaptureController();
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia({
controller,
});
// ...
controller.addEventListener(
"zoomlevelchange",
() => (outputElem.textContent = `${controller.zoomLevel}%`),
);
See Using the Captured Surface Control API for a full working example.
Specifications
Browser compatibility
See also
- Screen Capture API
- MediaDevices.getDisplayMedia()
- Using the Captured Surface Control API
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
