New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show/Hide Subtitle/CC Text Track Events #60
Comments
Good writeup, thanks! I'm seeing some devils in the details. In general, I'm trying to think through the implications of multiple UI elements interacting with a track, a track with different potential modes, and also the difference between the track kinds. (While also trying not to overthink this) As a made up example, what if an external transcript element wants a captions track to be always active (at least hidden, showing ok, not disabled) while the user turns captions on and off (should a request to turn off captions disable them or make them hidden)? How should show/hide apply to chapters, descriptions, and metadata tracks, which don't really have a difference today between hidden and shown AFAIK? It feels a little inconsistent to be working with independent lists of track kinds at the attr level but then general tracks in events. How do you feel about these tweaks? Kind-specific events
I like your example of having a hide request event with no Four kinds
I chose enable/disable from language used on MDN. Activate/deactivate was another option. The potential downside is that tracks would continue to be 'active' after being just 'hidden' and when technically not needed anymore. The question is, is that actually a problem? If so we could encourage people to use show and disable for the primary track menus. Allow a string as the detail for a request eventconst evt1 = new CustomEvent("mediashowcaptionsrequest", {
composed: true,
bubbles: true,
detail: "en-US:English" // URL encoded label
}); Using an object would still be an option. The combination of lang and label plus kind-specific events/attrs creates a unique ID for a track. So I can see myself just using the track lang:label string as an object key or ID somewhere, and then it being easy just to pass that to the event rather than needing to create an object. It also creates some consistency with the attributes. Related to this polymorphism, what's a use case where you'd want enable multiple tracks at the same time (in an array)? Does that need go away with kind-specific events? |
Great follow up. I think your general concerns and approach make sense here. A couple of high level considerations:
|
I don't think we should ever just be 'toggling' these states, as in the UI element doesn't care what the current state is and just wants to switch it. But I think what you're saying is we just need to know the state for the tracks, and I see I missed that in my proposal. What I had in mind was something along the lines of: <media-ui-el media-captions-showing="en-US:English es"> Does that at least address the issue you're describing? Then probably also: <media-ui-el media-captions-enabled="en-US:English es fr">
You're right, some extra burden, but even with a
That makes sense to me. I see a correlation between a 'captions off' menu item and consistently using an array, even if only caption lang is selected. |
Let me give a concrete example: I have a
Let's say a user:
What would you expect to happen to the |
Got it.
Mode is not "showing", menu-el should know that, menu-el should send a
Mode is not "showing", menu-el should know that, menu-el should send a
Mode is "showing", menu-el should know that, menu-el should - 2 options: We tell menu-el author to send a We tell menu-el author to send a To be clear, I'm very not interested in trying to manage internal state of UI element track requests in media-controller. I'm also not confident we'll actually run into any real issues on this front either way we go. Without more info on performance my assumption is it's not an issue and we should start with the the first option as guidance for el authors, |
Catching up here, in the example
Agree with this 👍🏼
My S1 is that this feels better because it avoids the downstream side effects that come with disabling a text track. I don't have a strong opinion on Kind-specific events (
On the side of the UI-element author who creates a single menu containing both captions and subtitles tracks, psuedo-code would look like: function showTextTrack (track) {
let eventName
if (track.kind === 'captions') {
eventName = 'mediashowcaptionsrequest'
}
if (track.kind === 'subtitles') {
eventName = 'mediashowsubtitlesrequest'
}
const evt1 = new CustomEvent(eventName, {
composed: true,
bubbles: true,
detail: encodeURIComponent(`${track.language}:${track.label}:`)
});
} The little bit of extra overhead comes with that conditional to figure out the right event name, not a deal breaker, and Christian mentioned another way we can work around that. |
So after discussion we decided to go with the
Yup. Also, for our "built in" CC/subtitle track selector, any time we choose to "show" one track, we also need to make sure we "hide" (actually disable, per ☝️) all currently showing subtitle/cc tracks. This isn't especially more complex than your example, but it does mean we may be dispatching up to 3 events to make a transition. Not a show stopper, but worth calling out I think. |
Q: What should events to show/hide subtitle/cc text tracks look like?
Assumptions:
TextTrack
Proposal
Create 2 generic events: one for showing and one for hiding 1+ subtitles/cc text tracks (or both)
Show Text Tracks
type
:"mediashowtexttracksrequest"
detail
(required):[{ kind: TEXT_TRACK_KIND, label?: OPTIONAL_TRACK_LABEL, language: TRACK_LANGUAGE }, ...]
||{ kind: TEXT_TRACK_KIND, label?: OPTIONAL_TRACK_LABEL, language: TRACK_LANGUAGE }
Result: changes any matching
TextTrack
tomode="showing"
(NOTE: In this proposal, this would not change themode
of any currently"showing"
TextTrack
)Examples:
Hide Text Tracks
type
:"mediahidetexttracksrequest"
detail
(optional):[{ kind: TEXT_TRACK_KIND, label?: OPTIONAL_TRACK_LABEL, language: TRACK_LANGUAGE }, ...]
||{ kind: TEXT_TRACK_KIND, label?: OPTIONAL_TRACK_LABEL, language: TRACK_LANGUAGE }
||undefined
Result: if
detail
is present, changes any matchingTextTrack
tomode="disabled"
. Ifdetail
is not present, changes anyTextTrack
that currently hasmode="showing"
tomode="disabled"
.Examples:
The text was updated successfully, but these errors were encountered: