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

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 of MediaStreamTrack 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 Streams
The definition of 'MediaStream' in that specification.
Candidate Recommendation  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MediaStream() constructorChrome Full support 19Edge Full support YesFirefox Full support 44IE No support NoOpera Full support 42Safari No support NoWebView Android Full support 37Chrome Android Full support 25Edge Mobile Full support YesFirefox Android Full support 42Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No support

See also

Document Tags and Contributors

Contributors to this page: mdnwebdocs-bot, mfuji09, Sheppy, fscholz, jpmedley, david_ross, Jib
Last updated by: mdnwebdocs-bot,