RestrictionTarget

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.

Das RestrictionTarget-Interface der Screen Capture API stellt eine statische Methode fromElement() bereit, die eine RestrictionTarget-Instanz zurückgibt, welche verwendet werden kann, um eine aufgezeichnete Videospur auf ein bestimmtes DOM-Element zu beschränken.

Statische Methoden

fromElement() Experimentell

Gibt eine RestrictionTarget-Instanz zurück, die verwendet werden kann, um eine aufgezeichnete Videospur auf ein spezifisches DOM-Element (einschließlich seiner Nachfahren) zu beschränken.

Beispiele

js
// Options for getDisplayMedia()
const displayMediaOptions = {
  preferCurrentTab: true,
};

// Create restriction target from DOM element
const demoElem = document.querySelector("#demo");
const restrictionTarget = await RestrictionTarget.fromElement(demoElem);

// Capture video stream from user's webcam and isolate video track
const stream =
  await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
const [track] = stream.getVideoTracks();

// Restrict video track
await track.restrictTo(restrictionTarget);

// Broadcast restricted stream in <video> element
videoElem.srcObject = stream;

Siehe Verwendung der Element Capture- und Region Capture-APIs für Beispielcode im Kontext.

Spezifikationen

Specification
Element Capture
# dom-restrictiontarget

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
RestrictionTarget
Experimental
fromElement() static method
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Experimental. Expect behavior to change in the future.

Siehe auch