The removetrack
event is used by the following APIs.
<audio>
or <video>
element when a track is removed from the element's media. The event is sent to the track list corresponding to the type of track being removed from the media: HTMLMediaElement.audioTracks
, videoTracks
, or textTracks
.MediaStream
when a MediaStreamTrack
is removed from it.TrackEvent
(HTML DOM)MediaStreamTrackEvent
(Media Capture and Streams)AudioTrackList
(HTML DOM)MediaStream
(Media Capture and Streams)This event implements the properties of TrackEvent
(HTML DOM) or MediaStreamTrackEvent
(Media Capture and Streams).
This event implements the methods of TrackEvent
(HTML DOM) or MediaStreamTrackEvent
(Media Capture and Streams).
The removetrack
event is delivered to an AudioTrackList
, VideoTrackList
, or TextTrackList
element when a MediaStreamTrack
of the corresponding type is removed from the media element whose tracks the track list object represents.
You can detect when tracks are removed from a media element by either setting the track's onremovetrack
event handler directly, or by using AudioTrackList.addEventListener()
on the track list object. For example, to watch for audio tracks to be removed from a video element:
var trackList = document.querySelector("video").audioTracks; audioTracks.onremovetrack = function(evt) { myTrackCount = trackList.length; }
This snippet of code sets up an event handler for removetrack
that simply records the current number of audio tracks remaining in the media element every time one is removed.
A removetrack
event is fired when the browser removes a track from a MediaStream
(such as when an RTCPeerConnection
is renegotiated or a stream being captured using HTMLMediaElement.captureStream()
gets a new set of tracks because the media element being captured loaded a new source.
An event handler for this event can be added by setting the MediaStream.onremovetrack
property, or by calling addEventListener()
on the MediaStream
which you want to monitor for track removals.
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'removetrack' in that specification. | Unknown | |
Media Capture and Streams The definition of 'removetrack' in that specification. | Candidate Recommendation |
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 50 (50) | No support | (Yes) | ? |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | ? | (Yes) | (Yes) | 50.0 (50) | No support | ? | ? |
HTMLMediaElement
: <audio>
and <video>
AudioTrackList
and AudioTrack
VideoTrackList
and VideoTrack
TextTrackList
and TextTrack
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/Events/removetrack