MediaStreamTrack.stop()

In short, the MediaStreamTrack.stop() method stops the track.

Syntax

MediaStreamTrack.stop();

Calling stop() tells the user agent that the track's source—whatever that source may be, including files, network streams, or a local camera or microphone—is no longer needed by the MediaStreamTrack.  Since multiple tracks may use the same source (for example, if two tabs are using the device's microphone), the source itself isn't necessarily immediately stopped. It is instead disassociated from the track and the track object is stopped. Once no media tracks are using the source, the source may actually be completely stopped.

Immediately after calling stop(), the track state is set to ended.

Specifications

Specification Status Comment
Media Capture and Streams
The definition of 'MediaStreamTrack.stop()' in that specification.
Editor's Draft Initial specification.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) 34 (34)[1] No support (Yes) ?
Feature Android Android Webview Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? (Yes) (Yes) 34.0 (34) No support ? ? (Yes)

[1] Prior to Firefox 52, only local tracks (that is, tracks obtained through getUserMedia()) could be stopped. Now all kinds of tracks can be stopped, including those on a MediaStream associated with a WebRTC connection, Web Audio API stream, or CanvasCaptureMediaStream.

See also

Document Tags and Contributors

 Contributors to this page: pehrsons, Sheppy, libbymc, jpmedley, fscholz, teoli
 Last updated by: pehrsons,