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.
Syntax
var trackEvent = new MediaStreamTrackEvent(type, {track: aMediaStreamTrack});
Parameters
The MediaStreamTrackEvent() constructor also inherits arguments from Event().
type- A
DOMStringrepresenting the name of the type of theMediaStreamTrackEvent. It is case-sensitive and can be"oraddtrack"".removetrack" track- A
MediaStreamTrackobject representing the track which was added to or removed from the stream.
Return value
A new MediaStreamTrackEvent, initialized based on the provided options.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Media Capture and Streams The definition of 'MediaStreamTrackEvent()' in that specification. |
Candidate Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaStreamTrackEvent() constructor | Chrome Full support 55 | Edge Full support ≤79 | Firefox Full support 50 | IE No support No | Opera Full support 42 | Safari ? | WebView Android Full support 55 | Chrome Android Full support 55 | Firefox Android Full support 50 | Opera Android Full support 42 | Safari iOS ? | Samsung Internet Android Full support 6.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
