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

Examples

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`);
};

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox 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 YesEdge Mobile Full support YesFirefox Android Full support 50Opera Android No support NoSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support

See also

Document Tags and Contributors

Tags: 
Contributors to this page: wbamberg
Last updated by: wbamberg,