MediaStream

The MediaStream interface of the Media Capture and Streams API represents a stream of media content. A stream consists of several tracks, such as video or audio tracks. Each track is specified as an instance of MediaStreamTrack.

MDN Reference

Constructors

Link copied to clipboard
constructor()
constructor(stream: MediaStream)
constructor(tracks: ReadonlyArray<MediaStreamTrack>)

Properties

Link copied to clipboard

The active read-only property of the MediaStream interface returns a Boolean value which is true if the stream is currently active; otherwise, it returns false. A stream is considered active if at least one of its MediaStreamTracks does not have its property MediaStreamTrack.readyState set to ended. Once every track has ended, the stream's active property becomes false.

Link copied to clipboard
val id: String

The id read-only property of the MediaStream interface is a string containing 36 characters denoting a unique identifier (GUID) for the object.

Functions

Link copied to clipboard

The addTrack() method of the MediaStream interface adds a new track to the stream. The track is specified as a parameter of type MediaStreamTrack.

Link copied to clipboard

The clone() method of the MediaStream interface creates a duplicate of the MediaStream. This new MediaStream object has a new unique id and contains clones of every MediaStreamTrack contained by the MediaStream on which clone() was called.

Link copied to clipboard
open fun dispatchEvent(event: Event): Boolean
Link copied to clipboard

The getAudioTracks() method of the MediaStream interface returns a sequence that represents all the MediaStreamTrack objects in this stream's track set where MediaStreamTrack.kind is audio.

Link copied to clipboard

The getTrackById() method of the MediaStream interface returns a MediaStreamTrack object representing the track with the specified ID string. If there is no track with the specified ID, this method returns null.

Link copied to clipboard

The getTracks() method of the MediaStream interface returns a sequence that represents all the MediaStreamTrack objects in this stream's track set, regardless of MediaStreamTrack.kind.

Link copied to clipboard

The getVideoTracks() method of the MediaStream interface returns a sequence of MediaStreamTrack objects representing the video tracks in this stream.

Link copied to clipboard

The removeTrack() method of the MediaStream interface removes a MediaStreamTrack from a stream.

Link copied to clipboard