MediaStreamTrack
Summary
Represents a media source in the user agent.
Properties
- enabled
- Enables the track if the new value is true, and disable it otherwise.
- id
- A globally unique identifier string, initialized when the MediaStreamTrack object is created.
- kind
- Returns the string “audio” if the object represents an audio track or “video” if object represents a video track.
- label
- Returns the label of the object’s corresponding track, if any. If the corresponding track has or had no label, it returns the empty string.
- muted
- Returns true if the track is muted, and false otherwise.
- onended
- Handles the ended event when fired on the MediaStreamTrack object.
- onmute
- Handles the mute event when fired on the MediaStreamTrack object.
- onoverconstrained
- Handles the overcontrained event when fired on the MediaStreamTrack object.
- onstarted
- Handles the started event when fired on the MediaStreamTrack object.
- onunmute
- Handles the unmute event when fired on the MediaStreamTrack object.
- readonly
- Returns true If the track (audio or video) is backed by a read-only source such as a file, or the track source is a local microphone or camera, but is shared so that this track cannot modify any of the source’s settings. Returns false otherwise.
- readyState
- Returns the state of the track.
- remote
- Returns true if the track is sourced by an RTCPeerConnection. Returns false otherwise.
Methods
- applyConstraints
- Replaces all existing constraints with the provided constraints, if existing constraints exist. Otherwise, it applies the newly provided constraints to the track.
- capabilities
- Returns a dictionary with all of the capabilities for the track type.
- clone
- Clones the given MediaStreamTrack.
- constraints
- Returns the complete constraints object associated with the track. If no mandatory constraints have been defined, the mandatory field will not be present (it will be undefined). If no optional constraints have been defined, the optional field will not be present (it will be undefined). If neither optional, nor mandatory constraints have been created, the value null is returned.
- states
- Returns an object containing all the state variables associated with the allowed constraints.
- stop
- Permanently stop the generation of data for track’s source.
Events
- mute
- This event fires when the MediaStreamTrack object’s source is temporarily unable to provide data.
- overconstrained
- This event fires asynchronously for each affected track (when multiple tracks share the same source) after the user agent has evaluated the current constraints against a given sourceId and is not able to configure the source within the limitations established by the union of imposed constraints.
- started
- This event fires when the MediaStreamTrack object has just transitioned from the “new” readyState to another state.
- unmute
- This event fires when the MediaStreamTrack object’s source is live again after having been temporarily unable to provide data.
Related specifications
- Media Capture and Streams
- W3C Working Draft