MediaStream.getTracks() returns an array of everyMediaStreamTrack in the stream’s track set — audio and video alike. Per MDN, kind does not matter; you get the full list.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call stream.getTracks. Start with this line.
JavaScript
mediaStream.getTracks()
Call
What it does
mediaStream.getTracks()
Primary signature.
stream.getTracks(...)
Call with the arguments your case needs.
Built into the browser. Call getTracks(...) on a MediaStream — no import required.
Library declarations
JavaScript
mediaStream.getTracks()
Parameters
This member has no parameters beyond those shown in the signature.
MediaStream.getTracks() is Baseline Widely available (MDN: since September 2017). It is part of the Media Capture and Streams specification. It is a browser Web API — not available in Node.js, Bun, or Deno.
✓ Baseline · Widely available
MediaStream.getTracks()
Supported across modern Chrome, Firefox, Safari, and Edge for listing every track in a stream.
98%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
getTracks()Excellent
Bottom line: Browser only — not a Node.js API. Safe for production. Use it whenever you need the full track list or to stop every track.
Frequently Asked Questions
An array of every MediaStreamTrack in the stream — both audio and video — regardless of track.kind. Empty streams return [].
No. MDN marks MediaStream.getTracks() as Baseline Widely available (since September 2017). It is not Deprecated, Experimental, or Non-standard.
No. Call it on a MediaStream with no arguments: stream.getTracks().
getTracks() returns all tracks. getAudioTracks() and getVideoTracks() return only audio or only video tracks.
Call stream.getTracks().forEach((track) => track.stop()) to release camera, microphone, and any other tracks at once.
No. It is a snapshot of the track set at call time. Adding or removing tracks later does not update an array you already stored.