The MediaStreamTrackEvent() constructor returns a newly created MediaStreamTrackEvent object, which represents an event announcing that a MediaStreamTrack has been added to or removed from a MediaStream.


var trackEvent = new MediaStreamTrackEvent(type, {track: aMediaStreamTrack});


The MediaStreamTrackEvent() constructor also inherits arguments from Event().

A DOMString representing the name of the type of the MediaStreamTrackEvent. It is case-sensitive and can be "addtrack" or "removetrack".
A MediaStreamTrack object representing the track which was added to or removed from the stream.

Return value

A new MediaStreamTrackEvent, initialized based on the provided options.


Specification Status Comment
Media Capture and Streams
The definition of 'MediaStreamTrackEvent()' in that specification.
Candidate Recommendation

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MediaStreamTrackEvent() constructorChrome Full support 55Edge Full support ≤79Firefox Full support 50IE No support NoOpera Full support 42Safari ? WebView Android Full support 55Chrome Android Full support 55Firefox Android Full support 50Opera Android Full support 42Safari iOS ? Samsung Internet Android Full support 6.0


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also