MediaStream Class
A stream of media (https://w3c.github.io/mediacapture-main/#mediastream): a set of audio and video tracks, played by the media elements (HtmlMediaElement.SrcObject), the Web Audio API and the other sinks.
public sealed class MediaStream : EventTarget- Inheritance
EventTargetMediaStream
Constructors
| Name | Description |
|---|---|
| MediaStream() | Creates a stream without track (https://w3c.github.io/mediacapture-main/#dom-mediastream-constructor). |
| MediaStream(MediaStream) | Creates a stream with the tracks of another stream (the same track objects). |
| MediaStream(IEnumerable<MediaStreamTrack>) | Creates a stream with tracks (a track given several times is added once). |
MediaStream overloads
MediaStream()
MediaStream.csCreates a stream without track (https://w3c.github.io/mediacapture-main/#dom-mediastream-constructor).
public MediaStream()MediaStream(MediaStream)
MediaStream.csCreates a stream with the tracks of another stream (the same track objects).
public MediaStream(MediaStream stream)MediaStream(IEnumerable<MediaStreamTrack>)
MediaStream.csCreates a stream with tracks (a track given several times is added once).
public MediaStream(IEnumerable<MediaStreamTrack> tracks)Properties
| Name | Description |
|---|---|
| Active | Gets whether the stream has a track that is not ended. |
| Id | Gets the identifier of the stream (a UUID). |
| OnAddTrack | Gets or sets the event handler of the addtrack event. |
| OnRemoveTrack | Gets or sets the event handler of the removetrack event. |
Active
MediaStream.csGets whether the stream has a track that is not ended.
public bool Active { get; }Gets the identifier of the stream (a UUID).
public string Id { get; }OnAddTrack
MediaStream.csGets or sets the event handler of the addtrack event.
Property value
See also
OnRemoveTrack
MediaStream.csGets or sets the event handler of the removetrack event.
Property value
See also
Methods
| Name | Description |
|---|---|
| AddTrack(MediaStreamTrack) | Adds a track to the stream, unless it is already in the stream. No event is fired. |
| Clone() | Creates a stream with the clones of the tracks of the stream (https://w3c.github.io/mediacapture-main/#dom-mediastream-clone). |
| GetAudioTracks() | Returns the audio tracks of the stream. |
| GetTrackById(string) | Returns the track of the stream with an identifier, or null. |
| GetTracks() | Returns the tracks of the stream. |
| GetVideoTracks() | Returns the video tracks of the stream. |
| RemoveTrack(MediaStreamTrack) | Removes a track from the stream. No event is fired. |
AddTrack(MediaStreamTrack)
MediaStream.csAdds a track to the stream, unless it is already in the stream. No event is fired.
public void AddTrack(MediaStreamTrack track)Clone()
MediaStream.csCreates a stream with the clones of the tracks of the stream (https://w3c.github.io/mediacapture-main/#dom-mediastream-clone).
public MediaStream Clone()GetAudioTracks()
MediaStream.csReturns the audio tracks of the stream.
public IReadOnlyList<MediaStreamTrack> GetAudioTracks()GetTrackById(string)
MediaStream.csReturns the track of the stream with an identifier, or null.
public MediaStreamTrack? GetTrackById(string trackId)GetTracks()
MediaStream.csReturns the tracks of the stream.
public IReadOnlyList<MediaStreamTrack> GetTracks()GetVideoTracks()
MediaStream.csReturns the video tracks of the stream.
public IReadOnlyList<MediaStreamTrack> GetVideoTracks()RemoveTrack(MediaStreamTrack)
MediaStream.csRemoves a track from the stream. No event is fired.
public void RemoveTrack(MediaStreamTrack track)