The MediaStream.addTrack() method adds a new track to the stream. The track is specified as a parameter of type MediaStreamTrack.
If the specified track is already in the stream's track set, this method has no effect.
Syntax
stream.addTrack(track);
Parameters
track- A
MediaStreamTrackto add to the stream.
Return value
Example
Specifications
| Specification | Status | Comment |
|---|---|---|
| Media Capture and StreamsThe definition of 'addTrack()' in that specification. | Candidate Recommendation | Initial specification. |
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.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
addTrack
|
Chrome
Full support 26 |
Edge
Full support 12 |
Firefox
Full support 44 |
IE
No support No |
Opera
No support No |
Safari
Full support Yes |
WebView Android
Full support 37 |
Chrome Android
Full support 26 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support 1.5 |
Legend
- Full support
- Full support
- No support
- No support
See also
MediaStream, the interface it belongs to.
MediaStream.addTrack() by Mozilla Contributors is licensed under CC-BY-SA 2.5.