addtrack events are produced by the following APIs:

HTML DOM
Sent to an HTMLMediaElement (representing either a <video> or <audio> element) when a track is added to the element during loading of the media.
Media Capture and Streams
Sent to a MediaStream when a new MediaStreamTrack is added to it.

General info

Specifications
HTML Living Standard
The definition of 'addtrack' in that specification.
Media Capture and Streams
The definition of 'addtrack' in that specification.
Interface
TrackEvent (HTML DOM)
MediaStreamTrackEvent (Media Capture and Streams)
Bubbles
No
Cancelable
No
Target
AudioTrackList (HTML DOM)
MediaStream (Media Capture and Streams)
Default Action
None

Properties

This event implements the properties of TrackEvent (HTML DOM) or MediaStreamTrackEvent (Media Capture and Streams).

Methods

This event implements the methods of TrackEvent (HTML DOM) or MediaStreamTrackEvent (Media Capture and Streams).

Usage notes

HTML DOM (Media elements)

To detect when tracks are added to an HTML <audio> or <video> element, you can watch for addtrack events to be delivered to the element's AudioTrackList as obtained from its audioTracks property. Use either AudioTrackList.onaddtrack or AudioTrackList.addEventListener() to set the event handler.

Media Capture and Streams

An addtrack event is fired when the browser adds a track to a MediaStream (such as when a RTCPeerConnection is renegotiated or a stream being captured using HTMLMediaElement.captureStream() gets a new set of tracks because the media element being captured loaded a new source.

An event handler for this event can be added by setting the MediaStream.onaddtrack property, or by calling addEventListener() on the MediaStream which you want to monitor for track additions.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'addtrack' in that specification.
Unknown  
Media Capture and Streams
The definition of 'addtrack' in that specification.
Candidate Recommendation  

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

 

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) 50 (50) No support (Yes) ?
  
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) (Yes) 50.0 (50) No support ? ?

See also

Document Tags and Contributors

Contributors to this page: Sheppy, albinlarsson, teoli, erikadoyle
Last updated by: Sheppy,