MediaStreamTrack Class

A track of media (https://w3c.github.io/mediacapture-main/#mediastreamtrack): the audio or the video of a source (a camera, a microphone, a screen, a canvas, a media element...), with its constraints and its settings.

public class MediaStreamTrack : EventTarget
Inheritance
EventTarget MediaStreamTrack

Properties

NameDescription
ContentHintGets or sets the hint of the content of the track (https://w3c.github.io/mst-content-hint/): for an audio track, speech, speech-recognition or music; for a video track, motion, detail or text; or an empty string. Another value is ignored.
EnabledGets or sets whether the track is enabled. A disabled track produces silence or black frames (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-enabled).
IdGets the identifier of the track (a UUID).
KindGets the kind of the track: audio or video.
LabelGets the label of the source of the track (e.g. the name of the camera), or an empty string.
MutedGets whether the source of the track is muted (it produces no media for now).
OnCaptureHandleChangeGets or sets the event handler of the capturehandlechange event.
OnConfigurationChangeGets or sets the event handler of the configurationchange event.
OnEndedGets or sets the event handler of the ended event.
OnMuteGets or sets the event handler of the mute event.
OnUnmuteGets or sets the event handler of the unmute event.
ReadyStateGets the state of the track.
StatsGets the statistics of the track (https://w3c.github.io/mediacapture-extensions/#dom-mediastreamtrack-stats): a MediaStreamTrackVideoStats for a video track, a MediaStreamTrackAudioStats for an audio track.

Gets or sets the hint of the content of the track (https://w3c.github.io/mst-content-hint/): for an audio track, speech, speech-recognition or music; for a video track, motion, detail or text; or an empty string. Another value is ignored.

public string ContentHint { get; set; }

Gets or sets whether the track is enabled. A disabled track produces silence or black frames (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-enabled).

public bool Enabled { get; set; }

Gets the identifier of the track (a UUID).

public string Id { get; }

Gets the kind of the track: audio or video.

public string Kind { get; }

Gets the label of the source of the track (e.g. the name of the camera), or an empty string.

public string Label { get; }

Gets whether the source of the track is muted (it produces no media for now).

public bool Muted { get; }

OnCaptureHandleChange

CaptureHandle.cs

Gets or sets the event handler of the capturehandlechange event.

public Action<Event>? OnCaptureHandleChange { get; set; }

OnConfigurationChange

MediaStreamTrack.cs

Gets or sets the event handler of the configurationchange event.

public Action<Event>? OnConfigurationChange { get; set; }

Gets or sets the event handler of the ended event.

public Action<Event>? OnEnded { get; set; }

Gets or sets the event handler of the mute event.

public Action<Event>? OnMute { get; set; }

Gets or sets the event handler of the unmute event.

public Action<Event>? OnUnmute { get; set; }

Gets the state of the track.

public MediaStreamTrackState ReadyState { get; }

Gets the statistics of the track (https://w3c.github.io/mediacapture-extensions/#dom-mediastreamtrack-stats): a MediaStreamTrackVideoStats for a video track, a MediaStreamTrackAudioStats for an audio track.

public object? Stats { get; }

Methods

NameDescription
ApplyConstraints(MediaTrackConstraints?)Applies constraints to the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-applyconstraints): the settings that satisfy them best are selected. The task fails with an OverconstrainedError when a required constraint cannot be satisfied (the current constraints remain). The task of an ended track succeeds.
Clone()Creates a track of the same source, with the same constraints, settings, state and content hint (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone).
GetCapabilities()Returns the capabilities of the source of the track: the values or the ranges of values of its constrainable properties (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getcapabilities).
GetCaptureHandle()Returns the capture handle of the captured page (https://w3c.github.io/mediacapture-handle/identity/#dom-mediastreamtrack-getcapturehandle): null, as the capture backend captures no page of the library.
GetConstraints()Returns the constraints applied by the most recent successful MediaStreamTrack.ApplyConstraints (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getconstraints).
GetSettings()Returns the current settings of the constrainable properties of the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getsettings).
Stop()Stops the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-stop): it ends, and its source stops when it was its last track. No ended event is fired.

ApplyConstraints(MediaTrackConstraints?)

MediaStreamTrack.cs

Applies constraints to the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-applyconstraints): the settings that satisfy them best are selected. The task fails with an OverconstrainedError when a required constraint cannot be satisfied (the current constraints remain). The task of an ended track succeeds.

public Task ApplyConstraints(MediaTrackConstraints? constraints = null)

Parameters

constraints MediaTrackConstraints?
The new constraints, which replace the current ones.

Returns

Task

See also

Creates a track of the same source, with the same constraints, settings, state and content hint (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone).

public MediaStreamTrack Clone()

GetCapabilities()

MediaStreamTrack.cs

Returns the capabilities of the source of the track: the values or the ranges of values of its constrainable properties (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getcapabilities).

public MediaTrackCapabilities GetCapabilities()

GetCaptureHandle()

CaptureHandle.cs

Returns the capture handle of the captured page (https://w3c.github.io/mediacapture-handle/identity/#dom-mediastreamtrack-getcapturehandle): null, as the capture backend captures no page of the library.

public CaptureHandle? GetCaptureHandle()

GetConstraints()

MediaStreamTrack.cs

Returns the constraints applied by the most recent successful MediaStreamTrack.ApplyConstraints (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getconstraints).

public MediaTrackConstraints GetConstraints()

GetSettings()

MediaStreamTrack.cs

Returns the current settings of the constrainable properties of the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getsettings).

public MediaTrackSettings GetSettings()

Stops the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-stop): it ends, and its source stops when it was its last track. No ended event is fired.

public void Stop()