The addtrack event on MediaStream fires when a new MediaStreamTrack is added to the stream. Learn MDN’s addEventListener and onaddtrack patterns, the MediaStreamTrackEvent.track property, pairing with addTrack(), and how this differs from the removetrack event—with five examples and try-it labs.
01
Kind
Instance event
02
Type
TrackEvent
03
Property
event.track
04
Bubble
no
05
Trigger
addTrack
06
Status
Baseline widely
Fundamentals
Introduction
Streams change over time—tracks arrive from WebRTC peers, screen shares start, or you compose streams manually with addTrack(). The addtrack event tells you when a new track joined the stream so you can update UI, attach to a <video> element, or log diagnostics.
MDN: the event is a MediaStreamTrackEvent with a read-only track property. It is not cancelable and does not bubble. Listen with stream.addEventListener("addtrack", handler) or stream.onaddtrack = handler.
💡
Beginner tip
Register the listener before calling addTrack() so you do not miss the event.
Concept
Understanding the addtrack Event
An instance event on MediaStream that signals a track was added to the stream’s track set.
Event name — "addtrack" (lowercase, one word).
Event type — MediaStreamTrackEvent (inherits Event).
Key property — event.track: the MediaStreamTrack that was added.
The MediaStreamaddtrack event 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 addtrack event
Fires when a MediaStreamTrack is added to a MediaStream.
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 addtrack
Not supported
MediaStream addtrackExcellent
Bottom line: Listen for addtrack to react when new tracks join a MediaStream.
Wrap Up
Conclusion
The addtrack event fires on a MediaStream when a new MediaStreamTrack is added. Listen with addEventListener or onaddtrack, then read event.track in your handler. MDN: the event is not cancelable and does not bubble—pair it with addTrack() for manual stream composition.
Try to cancel or prevent track addition via this event
Confuse addtrack (event) with addTrack() (method)
Register the listener after tracks are already added
Forget to call track.stop() when cleaning up hardware
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about addtrack
React when tracks join a MediaStream.
5
Core concepts
🔔01
Name
addtrack
Event
🔗02
Type
TrackEvent
Object
📦03
Track
event.track
Property
📄04
No bubble
not cancel
Rules
🎯05
Baseline
since Sep 2017
Status
❓ Frequently Asked Questions
When a new MediaStreamTrack is added to a MediaStream—for example after calling addTrack(track) on that stream.
No. MDN marks the addtrack event as Baseline Widely available (since September 2017). It is not Deprecated, Experimental, or Non-standard.
A MediaStreamTrackEvent. It inherits from Event and includes a read-only track property with the MediaStreamTrack that was added.
No. MDN says the event is not cancelable and does not bubble.
addTrack() is the method that adds a track to the stream. addtrack is the event that fires after a track has been added—you listen with addEventListener or onaddtrack.
removetrack fires when a track is removed from a MediaStream—for example after removeTrack(track). It is the counterpart to addtrack.
Did you know?
MDN documents the same addtrack event name on AudioTrackList and VideoTrackList targets for HTML media elements—but on MediaStream it fires when tracks join the stream’s track set.