VideoTrackList: removetrack event
The removetrack
event is fired when a video track is removed from a VideoTrackList
.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("removetrack", (event) => {});
onremovetrack = (event) => {};
Event type
A TrackEvent
. Inherits from Event
.
Event properties
In addition to the properties listed below, properties from the parent interface, Event
, are available.
track
Read only-
The newly-removed
VideoTrack
the event is in reference to.
Examples
Using addEventListener()
:
js
const videoElement = document.querySelector("video");
videoElement.videoTracks.addEventListener("removetrack", (event) => {
console.log(`Video track: ${event.track.label} removed`);
});
Using the onremovetrack
event handler property:
js
const videoElement = document.querySelector("video");
videoElement.videoTracks.onremovetrack = (event) => {
console.log(`Video track: ${event.track.label} removed`);
};
Specifications
Specification |
---|
HTML Standard # event-media-removetrack |
HTML Standard # handler-tracklist-onremovetrack |
Browser compatibility
BCD tables only load in the browser
See also
- Related events:
addtrack
,change
- This event on
AudioTrackList
targets:removetrack
- This event on
MediaStream
targets:removetrack
- Media Capture and Streams API
- WebRTC