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 |
---|
Media Capture and Streams # event-mediastream-addtrack |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
addtrack_event |
Yes |
12 |
50 |
No |
No |
Yes |
Yes |
Yes |
50 |
No |
Yes |
Yes |
See also
- Related events:
removetrack
- This event on
AudioTrackList
targets:addtrack
- This event on
VideoTrackList
targets:addtrack
- Media Streams API
- WebRTC
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/addtrack_event