Skip to content

Add HTMLMediaElement.removeTextTrack() method - #12735

Open
danae404 wants to merge 1 commit into
whatwg:mainfrom
danae404:add-removetexttrack
Open

Add HTMLMediaElement.removeTextTrack() method#12735
danae404 wants to merge 1 commit into
whatwg:mainfrom
danae404:add-removetexttrack

Conversation

@danae404

@danae404 danae404 commented Jul 29, 2026

Copy link
Copy Markdown

Adds a removeTextTrack(track) method that undoes addTextTrack(), mirroring its algorithm and phrasing. Only text tracks added via addTextTrack() can be removed this way; removing a track corresponding to a track element or an in-band track throws a NotFoundError.

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
  • Corresponding HTML AAM & ARIA in HTML issues & PRs:
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


/acknowledgements.html ( diff )
/media.html ( diff )

Adds a removeTextTrack(track) method that undoes addTextTrack(), mirroring
its algorithm and phrasing. Only text tracks added via addTextTrack() can be
removed this way; removing a track corresponding to a track element or an
in-band track throws a NotFoundError.
@jstenback jstenback added the agenda+ To be discussed at a triage meeting label Jul 31, 2026
@noamr

noamr commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@dalecurtis WDYT?

@padenot

padenot commented Aug 6, 2026

Copy link
Copy Markdown

Mozilla likes this, thanks for proposing it.

Now that real-time Speech Recognition (using e.g. the Web Speech API) is a reality, this can help to implement neat auto-captioning systems, potentially with translations in different languages, since this is also a reality, while being able to clean up when e.g. the audio track / language of the subtitles is changed by the user or website.

https://bugzilla.mozilla.org/enter_bug.cgi?component=Audio%2FVideo%3A%20Playback&product=Core will let you file a bug on our BMO instance in the right component when it's time to file.

@dalecurtis

Copy link
Copy Markdown
Contributor

Generally sgtm. Do we need to restrict removal to just added tracks? Sometimes tracking state like that can be unnecessarily complicated and a surprising edge case to a user.

@jstenback jstenback removed the agenda+ To be discussed at a triage meeting label Aug 6, 2026
@annevk annevk added the agenda+ To be discussed at a triage meeting label Aug 20, 2026
@danae404

Copy link
Copy Markdown
Author

Generally sgtm. Do we need to restrict removal to just added tracks? Sometimes tracking state like that can be unnecessarily complicated and a surprising edge case to a user.

That's a good point- I can see it being confusing for the user if it is restricted to added tracks.

@eric-carlson

Copy link
Copy Markdown

Generally sgtm. Do we need to restrict removal to just added tracks? Sometimes tracking state like that can be unnecessarily complicated and a surprising edge case to a user.

If by "user" you mean the page author, they should know if a track has been added with JS or not so they will know if it can be removed.

Allowing removal of tracks not created with addTextTrack seems like a foot-gun:

  • having a element in the DOM but no object in the TextTrackList is strange
  • while you could restore a track created from a <track> element by manipulating the DOM, there is no way to restore an in-band track

Comment thread source
<p>The <dfn method for="HTMLMediaElement"><code
data-x="dom-media-removeTextTrack">removeTextTrack(<var>track</var>)</code></dfn> method of
<span data-x="media element">media elements</span>, when invoked, must run the following
steps:</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the modern way of phrasing this:

"The X method steps are:"

Comment thread source

<li><p><var>track</var> was not added to <span>this</span>'s <span>list of text
tracks</span> by a call to <span>this</span>'s <code
data-x="dom-media-addTextTrack">addTextTrack()</code> method,</p></li>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd handle this as state on track so we don't need COMEFROM wording.

Comment thread source
</li>

<li>
<p>Remove <var>track</var> from <span>this</span>'s <span>list of text tracks</span>.</p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the removal is synchronous, is there a reason to fire the event from a task?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agenda+ To be discussed at a triage meeting topic: media

Development

Successfully merging this pull request may close these issues.

8 participants