whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.16k stars 2.69k forks source link

TextTrack should expose `readyState` and fire the appropriate events #2121

Open mounirlamouri opened 7 years ago

mounirlamouri commented 7 years ago

I'm working on implementing the Blink media controls on top of the web exposed APIs instead of implementing our own hook and the relationship between HTMLTrackElement and TextTrack is problematic.

As far as the developers are concerned, working on TextTrackList is the best solution but activating a TextTrack might fail if it is backed by a HTMLTrackElement that fails to load. This can be observed on the element with an error event and readyState. However, even if TextTrack has an internal notion of ready state, it is not exposed to web pages.

I would like to propose to fire the same events wrt to loading and expose the ready state via readyState on the TextTrack object in addition of HTMLTrackElement.

@foolip are you the right person to give feedback on this?

foolip commented 7 years ago

@zcorpan and @fsoder have also worked a lot on this.

Would the readyState on TextTrack be useful for in-band tracks and script-created tracks? Is there something that's impossible with the current API, or is it a matter of convenience?

fsoder commented 7 years ago

Mild overlap with #1290 here I guess? (The major difference seems to be whether you want to expose/proxy bits of the source or the source itself.)

mounirlamouri commented 7 years ago

If we add #1290, it will become convenience. However, if we want to abstract the element and the track representation, as far as I know, it's impossible to do efficiently.

FWIW, both Gecko and Blink have an internal readyState being used for TextTrack so I would assume finding a value for script-created and in-band tracks to be a solved issue (didn't check what they do but likely created as loaded).

fsoder commented 7 years ago

Yes, 'loaded' would be the reasonable value for non-HTMLTrackElement sourced tracks. It's speced already too - https://html.spec.whatwg.org/multipage/embedded-content.html#sourcing-in-band-text-tracks step 6, https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-addtexttrack step 2.

zcorpan commented 7 years ago

I would be OK with this proposal or #1290, or both. We need interest to implement from more than one browser engine though.

cc @eric-carlson @bechen