W3cubDocs

/DOM

MediaStream.getVideoTracks

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

The getVideoTracks() property of the MediaStream interface returns a sequence of MediaStreamTrack objects representing the video tracks in this stream.

Syntax

var mediaStreamTracks[] = mediaStream.getVideoTracks()

Parameters

None.

Return value

An array of MediaStreamTrack.

Exceptions

Example

The following example, extracted from Chrome's Image Capture / Photo Resolution Sample, uses getVideoTracks() to retrieve a track for passing to the ImageCapture() constructor.

const input = document.querySelector('input[type="range"]');

var 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

Specification Status Comment
Media Capture and Streams
The definition of 'getVideoTracks()' in that specification.
Editor's Draft Initial definition.

Browser Compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) ? ? (Yes) ?
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) ? ? ? (Yes) ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/getVideoTracks