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
EventTargetMediaStreamTrack
Properties
| Name | Description |
|---|---|
| ContentHint | 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. |
| Enabled | 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). |
| Id | Gets the identifier of the track (a UUID). |
| Kind | Gets the kind of the track: audio or video. |
| Label | Gets the label of the source of the track (e.g. the name of the camera), or an empty string. |
| Muted | Gets whether the source of the track is muted (it produces no media for now). |
| OnCaptureHandleChange | Gets or sets the event handler of the capturehandlechange event. |
| OnConfigurationChange | Gets or sets the event handler of the configurationchange event. |
| OnEnded | Gets or sets the event handler of the ended event. |
| OnMute | Gets or sets the event handler of the mute event. |
| OnUnmute | Gets or sets the event handler of the unmute event. |
| ReadyState | Gets the state of the track. |
| Stats | 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. |
ContentHint
MediaStreamTrack.csGets 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; }Property value
See also
Enabled
MediaStreamTrack.csGets 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; }Label
MediaStreamTrack.csGets the label of the source of the track (e.g. the name of the camera), or an empty string.
public string Label { get; }Muted
MediaStreamTrack.csGets whether the source of the track is muted (it produces no media for now).
public bool Muted { get; }OnCaptureHandleChange
CaptureHandle.csGets or sets the event handler of the capturehandlechange event.
OnConfigurationChange
MediaStreamTrack.csGets or sets the event handler of the configurationchange event.
OnEnded
MediaStreamTrack.csGets or sets the event handler of the ended event.
Property value
See also
OnMute
MediaStreamTrack.csGets or sets the event handler of the mute event.
Property value
See also
OnUnmute
MediaStreamTrack.csGets or sets the event handler of the unmute event.
Property value
See also
ReadyState
MediaStreamTrack.csGets 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; }Property value
See also
Methods
| Name | Description |
|---|---|
| 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.csApplies 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
constraintsMediaTrackConstraints?- The new constraints, which replace the current ones.
Returns
See also
Clone()
MediaStreamTrack.csCreates 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.csReturns 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.csReturns 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.csReturns the constraints applied by the most recent successful MediaStreamTrack.ApplyConstraints (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getconstraints).
public MediaTrackConstraints GetConstraints()GetSettings()
MediaStreamTrack.csReturns the current settings of the constrainable properties of the track (https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-getsettings).
public MediaTrackSettings GetSettings()Stop()
MediaStreamTrack.csStops 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()