The read-only active property on a MediaStream tells you whether the stream still has at least one track that has not ended. Learn the MDN getUserMedia pattern, how track.stop() flips active to false, the inactive event, and a permission-free canvas.captureStream() demo—with five examples and try-it labs.
01
Kind
Instance property
02
Returns
Boolean
03
Read-only
no setter
04
Rule
any track live
05
Use case
UI state
06
Status
Baseline widely
Fundamentals
Introduction
A MediaStream is a bundle of MediaStreamTrack objects—audio, video, or both. You get one from APIs such as getUserMedia(), captureStream() on a canvas, or WebRTC peer connections.
The active property answers a simple question: is this stream still going? It is true while at least one track has a readyState other than "ended". When you stop every track, MDN says active becomes false.
💡
Beginner tip
Think of active as a stream-level light switch. Each track can be "live" or "ended"; the stream stays active until all lights are off.
Concept
Understanding the active Property
A read-only instance property on MediaStream that reports whether the stream still has usable tracks.
Type — boolean (true or false).
Read-only — you cannot assign to stream.active.
true — at least one track’s readyState is not "ended".
false — every track in the stream has readyState === "ended".
Typical source — return value of navigator.mediaDevices.getUserMedia().
Related event — inactive fires when active becomes false.
Baseline Widely available on MDN (since September 2017).
Foundation
📝 Syntax
Read active on any MediaStream object:
JavaScript
mediaStream.active
Return value
A boolean: true if the stream has at least one track that is not ended; otherwise false.
MediaStream.active is marked Baseline Widely available on MDN (since September 2017). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
MediaStream.active
Read-only boolean—true while any track in the stream is not ended.
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerNo MediaStream.active
Not supported
MediaStream.activeExcellent
Bottom line: Check stream.active before UI actions; stop all tracks to end the stream.
Wrap Up
Conclusion
MediaStream.active is a read-only boolean that is true while at least one track is not ended. Use it after getUserMedia() for UI state, pair it with track.stop() for cleanup, and listen for inactive when the stream fully shuts down.
Check stream.active before starting duplicate captures
Stop every track with getTracks().forEach(t => t.stop())
Use inactive for cleanup when the stream ends
Pair with secure-context checks before getUserMedia
Use canvas.captureStream() to learn without hardware
❌ Don’t
Try to assign stream.active = false
Assume one stopped track means the whole stream ended
Forget to stop tracks when leaving a page (memory & privacy)
Confuse active with track.enabled (mute vs end)
Call getUserMedia on plain HTTP (blocked in modern browsers)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about active
Stream-level live status for media tracks.
5
Core concepts
🔗01
Type
boolean
API
⚙️02
Read-only
no setter
Access
⚠️03
Rule
any track live
Logic
📄04
Stop
track.stop()
Cleanup
🎯05
Baseline
since Sep 2017
Status
❓ Frequently Asked Questions
A read-only boolean. It is true when at least one MediaStreamTrack in the stream has a readyState other than "ended". When every track has ended, active becomes false.
No. MDN marks MediaStream.active as Baseline Widely available (since September 2017). It is not Deprecated, Experimental, or Non-standard.
Call stop() on every track in the stream. When all tracks end, active flips to false and the inactive event fires.
No. Each track has its own readyState ("live" or "ended"). active is a stream-level summary: true if any track is still not ended.
Immediately after a successful getUserMedia() call, the returned MediaStream usually has live audio and/or video tracks, so active is typically true.
The active property itself works on any MediaStream object. Getting streams from getUserMedia() requires a secure context (HTTPS or localhost).
Did you know?
MDN’s active example disables the start button with startBtn.disabled = stream.active right after getUserMedia succeeds—a one-line UI guard for live camera streams.