MediaStream()
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
new MediaStream(); new MediaStream(stream); 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 |
---|
Media Capture and Streams # dom-mediastream-constructor |
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 | |
MediaStream |
55
21
|
12
79
|
44 |
No |
42
15
|
11 |
55
≤37
|
55
25
|
42 |
42
14
|
11 |
6.0
1.5
|
See also
© 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/MediaStream