Re: Lack of removeTextTrack?

On Fri, 27 Feb 2015 08:58:19 +0100, Ian Devlin <ian@iandevlin.com> wrote:

> Thanks for this.
>
> As for why I needed it, I wrote a short article on dynamically adding  
> text
> tracks to video (
> http://www.iandevlin.com/blog/2015/02/javascript/dynamically-adding-text-tracks-to-html5-video)
> and as part of that I built a demo (
> http://iandevlin.com/html5/dynamic-track/) that allows you to switch
> between the two methods using buttons.
> I wanted to use the buttons to remove the existing text track on each  
> click
> and replace it with the new one, and was unable to. In the end I tried to
> hide all the text tracks which were already there, with varying success.  
> Of
> course this means that depending on how often you click the buttons, many
> text tracks get added!

OK, thanks. In general, a demo is not enough reason on its own to add an  
API. It would be more convincing if the functionality is needed on a real  
site.

When the track is associated with a <track> element, you can remove the  
<track> element to remove the text track.

[[
When a track element's parent element changes and the old parent was a  
media element, then the user agent must remove the track element's  
corresponding text track from the media element's list of text tracks, and  
then queue a task to fire a trusted event with the name removetrack, that  
does not bubble and is not cancelable, and that uses the TrackEvent  
interface, with the track attribute initialised to the text track's  
TextTrack object, at the media element's textTracks attribute's  
TextTrackList object.
]]

https://html.spec.whatwg.org/multipage/embedded-content.html#sourcing-out-of-band-text-tracks

For API-added tracks (and in-band tracks), you can set .mode to "disabled"  
to turn off rendering and events. If you need to re-add it, you can change  
.mode again instead of using addTextTrack().

-- 
Simon Pieters
Opera Software

Received on Friday, 27 February 2015 08:47:14 UTC