MediaStream Redirect 1

« WebRTC « MediaStream API

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The MediaStream interface represents a stream of media content. A stream consists of several tracks, like video or audio tracks.

Attributes

MediaStream.ended Read only
Is a Boolean value with a value of true if the ended event has been fired on the object, meaning that the stream has been completely read, or false if the end of hte stream has not been reached.
MediaStream.id Read only
Is a DOMString containing 36 characters denoting a unique identifier (GUID) for the object.

Event handlers

MediaStream.onaddtrack
Is a EventHandler containing the action to perform when an addtrack event is fired on the object, that is when a new MediaStreamTrack object is added.
MediaStream.onended
Is a EventHandler containing the action to perform when an ended event is fired on the object, that is when the streaming is terminating.
MediaStream.onremovetrack
Is a EventHandler containing the action to perform when an removetrack event is fired on the object, that is when a  MediaStreamTrack object is removed from it.

Methods

MediaStream.addTrack()
Stores a copy of the MediaStreamTrack given as argument. If the track has already been added to the MediaStream object, nothing happens; if the track is in the finished state, that is has already reached its end, the exception INVALID_STATE_RAISE is raised.
MediaStream.clone()
Return a clone of the MediaStream objet. The clone will have a new id value.
Returns the track whose id corresponds to the one given in parameters, trackid. If no parameter is given, or if no track with that id does exists, it returns null. If several tracks have the same id, it returns the first one.
MediaStream.getAudioTracks()
Returns a list of the MediaStreamTrack stored in the MediaStream object that have their kind attribute set to "audio". The order is not defined, and may vary from one browser to an other, but also from one call to the method to another.
MediaStream.getTrackById()
Returns the track whose id corresponds to the one given in parameters, trackid. If no parameter is given, or if no track with that id does exists, it returns null. If several tracks have the same id, it returns the first one.
MediaStream.getVideoTracks()
Returns a list of the MediaStreamTrack stored in the MediaStream object that have their kind attribute set to "video". The order is not defined, and may vary from one browser to an other, but also from one call to the method to another.
MediaStream.removeTrack()
Removes the MediaStreamTrack given as argument. If the track is not part of the MediaStream object, nothing happens; if the track is in the finished state, that is has already reached its end, the exception INVALID_STATE_RAISE is raised.

Examples

 

Specifications

Specification Status Comment
Media Capture and Streams Candidate Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) Not supported Not supported ?
getAudioTracks() and getVideoTracks() ? 23.0 (23.0) Not supported Not supported ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) Not supported Not supported ?
getAudioTracks() and getVideoTracks() ? 23.0 (23.0) Not supported Not supported ?

See also

  • Using the MediaStream API

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,