The MediaStreamTrack interface represents a single media track within a stream; typically, these are audio or video tracks, but other track types may exist as well.

Properties

In addition to the properties listed below, MediaStreamTrack has constrainable properties which can be set using applyConstraints() and accessed using getConstraints() and getSettings(). See Capabilities, constraints, and settings to learn how to correctly work with constrainable properties. Not doing so correctly will result in your code being unreliable.

MediaStreamTrack.contentHint
A string that may be used by the web application to provide a hint as to what type of content the track contains to guide how it should be treated by API consumers.
MediaStreamTrack.enabled
A Boolean whose value of true if the track is enabled, that is allowed to render the media source stream; or false if it is disabled, that is not rendering the media source stream but silence and blackness. If the track has been disconnected, this value can be changed but has no more effect.
Note: You can implement standard "mute" functionality by setting enabled to false. The muted property refers to a condition in which there's no media because of a technical issue.
MediaStreamTrack.id Read only
Returns a DOMString containing a unique identifier (GUID) for the track; it is generated by the browser.
MediaStreamTrack.isolated Read only
Returns a Boolean value which is true if the track is isolated; that is, the track cannot be accessed by the document that owns the MediaStreamTrack. This happens when the peerIdentity property is set, or if the track comes from a cross-origin source.
MediaStreamTrack.kind Read only
Returns a DOMString set to "audio" if the track is an audio track and to "video", if it is a video track. It doesn't change if the track is deassociated from its source.
MediaStreamTrack.label Read only
Returns a DOMString containing a user agent-assigned label that identifies the track source, as in "internal microphone". The string may be left empty and is empty as long as no source has been connected. When the track is deassociated from its source, the label is not changed.
MediaStreamTrack.muted Read only
Returns a Boolean value indicating whether the track is unable to provide media data due to a technical issue.
Note: You can implement standard "mute" functionality by setting enabled to false, and unmute the media by setting it back to true again.
MediaStreamTrack.readonly Read only
Returns a Boolean value with a value of true if the track is readonly (such a video file source or a camera that settings can't be modified), false otherwise.
MediaStreamTrack.readyState Read only
Returns an enumerated value giving the status of the track. This will be one of the following values:
  • "live" which indicates that an input is connected and does its best-effort in providing real-time data. In that case, the output of data can be switched on or off using the enabled attribute.
  • "ended" which indicates that the input is not giving any more data and will never provide new data.
MediaStreamTrack.remote  Read only
Returns a Boolean with a value of true if the track is sourced by a RTCPeerConnection, false otherwise.

Event handlers

MediaStreamTrack.onstarted
An EventHandler containing the action to perform when an started event is fired on the object, that is when a new MediaStreamTrack object is added.
MediaStreamTrack.onended
An EventHandler containing the action to perform when an ended event is fired on the object, that is when a  MediaStreamTrack object is removed from it.
MediaStreamTrack.onisolationchange
An event handler that is called when the isolationchange event is fired at the track object. This occurs whenever the value of the isolated property changes due to the document gaining or losing permission to access the track.
MediaStreamTrack.onmute
An EventHandler containing the action to perform when an mute event is fired on the object, that is when the streaming is terminating.
MediaStreamTrack.onunmute
An EventHandler containing the action to perform when an unmute event is fired on the object, that is when a  MediaStreamTrack object is removed from it.
MediaStreamTrack.onoverconstrained
An EventHandler containing the action to perform when an overconstrained event is fired on the object, that is when a  MediaStreamTrack object is removed from it.

Methods

MediaStreamTrack.applyConstraints()
Lets the application specify the ideal and/or ranges of acceptable values for any number of the available constrainable properties of the MediaStreamTrack.
MediaStreamTrack.clone()
Returns a duplicate of the MediaStreamTrack.
MediaStreamTrack.getCapabilities()
Returns the a list of constrainable properties available for the MediaStreamTrack.
MediaStreamTrack.getConstraints()
Returns a MediaTrackConstraints object containing the currently set constraints for the track; the returned value matches the constraints last set using applyConstraints().
MediaStreamTrack.getSettings()
Returns a MediaTrackSettings object containing the current values of each of the MediaStreamTrack's constrainable properties.
MediaStreamTrack.stop()
Stops playing the source associated to the track, both the source and the track are deassociated. The track state is set to ended.

Specifications

Specification Status Comment
Media Capture and Streams
The definition of 'MediaStreamTrack' in that specification.
Candidate Recommendation Initial definition
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'Isolated tracks' in that specification.
Candidate Recommendation Additional properties for isolated track support

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 22IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 22Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
applyConstraints
Deprecated
Chrome Full support 63Edge Full support 12Firefox Full support 50IE ? Opera Full support 46Safari ? WebView Android Full support 63Chrome Android Full support 63Edge Mobile ? Firefox Android Full support 50Opera Android Full support 46Safari iOS ? Samsung Internet Android Full support 7.0
clone
Deprecated
Chrome Full support 45Edge Full support 12Firefox Full support 48IE ? Opera Full support 32Safari ? WebView Android Full support 45Chrome Android Full support 45Edge Mobile ? Firefox Android ? Opera Android Full support 32Safari iOS ? Samsung Internet Android Full support 5.0
contentHintChrome Full support 60Edge ? Firefox ? IE ? Opera Full support 47Safari ? WebView Android Full support 60Chrome Android Full support 60Edge Mobile ? Firefox Android ? Opera Android Full support 47Safari iOS ? Samsung Internet Android No support No
enabledChrome Full support YesEdge Full support 12Firefox Full support 24IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 24Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
getCapabilities
Deprecated
Chrome Full support 66Edge Full support 12Firefox No support NoIE ? Opera Full support 53Safari ? WebView Android Full support 66Chrome Android Full support 66Edge Mobile ? Firefox Android No support NoOpera Android Full support 53Safari iOS ? Samsung Internet Android No support No
getConstraints
Deprecated
Chrome Full support 53Edge Full support 12Firefox Full support 50IE ? Opera Full support YesSafari ? WebView Android Full support 53Chrome Android Full support 52Edge Mobile ? Firefox Android Full support 50Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 6.0
getSettings
Deprecated
Chrome Full support 61Edge Full support 12Firefox Full support 50IE ? Opera Full support 48Safari ? WebView Android Full support 61Chrome Android Full support 61Edge Mobile ? Firefox Android Full support 50Opera Android Full support 48Safari iOS Full support 11Samsung Internet Android No support No
getSources
Deprecated
Chrome No support ? — 56Edge ? Firefox No support NoIE ? Opera No support ? — 43Safari ? WebView Android No support ? — 56Chrome Android Full support 56Edge Mobile ? Firefox Android ? Opera Android No support ? — 43Safari iOS ? Samsung Internet Android Full support 6.0
idChrome Full support YesEdge Full support 12Firefox Full support YesIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android ? Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
isolatedChrome ? Edge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
kindChrome Full support YesEdge Full support 12Firefox Full support YesIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android ? Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
labelChrome Full support YesEdge Full support 12Firefox Full support YesIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android ? Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
mutedChrome Full support YesEdge Full support 12Firefox Full support 59IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 59Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
onended
Deprecated
Chrome Full support YesEdge Full support 12Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 50Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
onisolationchangeChrome ? Edge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
onmute
DeprecatedNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support 59IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 59Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
onoverconstrained
Deprecated
Chrome Full support YesEdge Full support 12Firefox Full support YesIE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
onunmute
Deprecated
Chrome Full support YesEdge Full support 12Firefox Full support 59IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 59Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
readonly
Deprecated
Chrome ? Edge Full support 12Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
readyStateChrome Full support YesEdge Full support 12Firefox Full support 50IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
remote
DeprecatedNon-standard
Chrome No support 48 — 59Edge Full support 12Firefox Full support YesIE No support NoOpera No support 35 — 46Safari ? WebView Android No support 48 — 59Chrome Android No support 48 — 59Edge Mobile Full support YesFirefox Android Full support YesOpera Android No support 35 — 46Safari iOS ? Samsung Internet Android Full support 5.0
stop
Deprecated
Chrome Full support 61Edge Full support 12Firefox Full support 34IE No support NoOpera Full support 45Safari ? WebView Android Full support 61Chrome Android Full support 61Edge Mobile Full support YesFirefox Android Full support 34Opera Android Full support 45Safari iOS ? Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also

Document Tags and Contributors

Last updated by: Sheppy,