MediaStream: addtrack event

The addtrack event is fired when a new MediaStreamTrack object has been added to a MediaStream.

Bubbles No
Cancelable No
Interface MediaStreamTrackEvent
Event handler property onaddtrack


Using addEventListener():

let stream = new MediaStream();

stream.addEventListener('addtrack', (event) => {
  console.log(`New ${event.track.kind} track added`);

Using the onaddtrack event handler property:

let stream = new MediaStream();

stream.onaddtrack = (event) => {
  console.log(`New ${event.track.kind} track added`);


Specification Status
Media Capture and Streams
The definition of 'addtrack' in that specification.
Candidate Recommendation

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
addtrack eventChrome Full support YesEdge Full support 12Firefox Full support 50IE No support NoOpera No support NoSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 50Opera Android No support NoSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support  
Full support
No support  
No support

See also