Baseline Widely available
The getVideoTracks()
method of the MediaStream
interface returns a sequence of MediaStreamTrack
objects representing the video tracks in this stream.
None.
Return valueAn array of MediaStreamTrack
objects, one for each video track contained in the media stream. Video tracks are those tracks whose kind
property is video
. The array is empty if the stream contains no video tracks.
Note: The order of the tracks is not defined by the specification, and may not be the same from one call to getVideoTracks()
to another.
The following example, extracted from Chrome's Image Capture / Photo Resolution Sample, uses getVideoTracks()
to retrieve a track for passing to the ImageCapture()
constructor.
let imageCapture;
navigator.mediaDevices.getUserMedia({ video: true }).then((mediaStream) => {
document.querySelector("video").srcObject = mediaStream;
const track = mediaStream.getVideoTracks()[0];
imageCapture = new ImageCapture(track);
return imageCapture.getPhotoCapabilities();
});
Specifications Browser compatibility
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