Limited availability
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.
The clone()
method of the BrowserCaptureMediaStreamTrack
interface returns a clone of the original BrowserCaptureMediaStreamTrack
.
This method is functionally identical to MediaStreamTrack.clone()
, except that it handles cases where cropping or restriction have been applied to the track. The returned clone is identical to the original BrowserCaptureMediaStreamTrack
, but with any cropping or restriction removed.
Note: In Chromium, if a track has clones, its cropTo()
and restrictTo()
methods will reject (see Chrome issue 41482026).
None.
Return valueA BrowserCaptureMediaStreamTrack
instance.
// Options for getDisplayMedia()
const displayMediaOptions = {
preferCurrentTab: true,
};
// Create crop target from DOM element
const demoElem = document.querySelector("#demo");
const cropTarget = await CropTarget.fromElement(demoElem);
// Capture video stream from user's webcam and isolate video track
const stream =
await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
const [track] = stream.getVideoTracks();
// Crop video track
await track.cropTo(cropTarget);
// Create uncropped clone of the track
const clonedTrack = track.clone();
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4