Example 1 — Empty MediaStream
A stream with no tracks is inactive.
const stream = new MediaStream();
console.log(stream.getTracks().length); // 0
console.log(stream.active); // false How It Works
- Construct an empty stream. No tracks attached.
- No live tracks. Nothing with
readyState !== "ended". activeisfalse. Matches MDN’s definition.- No permissions needed. Safe classroom demo.

