The MediaStream()
constructor returns a newly-created MediaStream
, which serves as a collection of media tracks, each represented by a MediaStreamTrack
object. If any parameters are given, the specified tracks are added to the new stream. Otherwise, the stream has no tracks.
Syntax
newStream = new MediaStream(); newStream = new MediaStream(stream); newStream = new MediaStream(tracks[]);
Parameters
stream
- A different
MediaStream
object whose tracks are added to the newly-created stream automatically. The tracks are not removed from the original stream, so they're shared by the two streams. tracks
- An
Array
ofMediaStreamTrack
objects, one for each track to add to the stream.
Return value
A newly-created MediaStream
object, either empty, or containing the tracks provided, if any.
Specifications
Specification | Status | Comment |
---|---|---|
Media Capture and StreamsThe definition of 'MediaStream' 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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaStream() constructor
|
Chrome
Full support 21 |
Edge
Full support ≤18 |
Firefox
Full support 44 |
IE
No support No |
Opera
Full support 42 |
Safari
No support No |
WebView Android
Full support 37 |
Chrome Android
Full support 25 |
Firefox Android
Full support 42 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 6.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
MediaStream() by Mozilla Contributors is licensed under CC-BY-SA 2.5.