Replies: 4 comments 6 replies
-
I created a POC here #236. You can play around with it here: https://media-chrome-git-fork-gkatsev-text-track-renderer-mux.vercel.app/examples/advanced.html. The key point is that the text track renderer doesn't have much state itself. It mostly grabs the correct track via the media-controller and then using the media it has access to the text tracks. |
Beta Was this translation helpful? Give feedback.
-
Thanks for writing this up! At a high level, I see three different places we could solve this.
Number 1 honestly feels ideal to mean. I don't know if regions are meant for this, but I want the video element to solve for this. With Number 3, the thing I'm most worried about is the layout complexity it introduces. How exactly do captions get out of the way of controls? I don't see an easy and clean way of doing that. Maybe if we could put captions in "middle-chrome" and have middle chrome expand when there's nothing in top/bottom-chrome. What are the other reasons today, besides moving out of the way of controls, for solving this in a custom way? |
Beta Was this translation helpful? Give feedback.
-
If we were just building a player that could be an option but we can't make that decision for everyone using media chrome.
Yeah, seeing as media chrome users can put controls anywhere in the display area, making sure nothing ever overlaps captions feels impossible, so there is no perfect here and we've gotta consider the most common use cases. I'm thinking you're right that the cleanest way to solve for this is just make theme builders or media chrome users manually set the size of the text renderer as they're designing the controls. But with that being the case, I don't think this can be the default. It has to be the advanced version of captions, so people are opting into the complexity, not being forced into it, and it's clear how it works because you're intentionally adding the custom element in the clear, not working with a semi secret Here's what I'm understanding could be the option then:
How does that sound? |
Beta Was this translation helpful? Give feedback.
-
I'm good with that. |
Beta Was this translation helpful? Give feedback.
-
Using native captions is great, since it means less code in the player and there are some features that only native captions can take advantage off, such as captions in PiP. However, there are some limitations, namely making native captions not be obscured by overlays such as custom controls and doing so in a cross browser way.
This proposal adds a new slot, that's positioned in front of the gestures layer.
When an element is slotted into it, it would signal to media-chrome that when captions are toggled, they should toggle between disabled and hidden, compared to disabled and showing as it is normally. A currently enabled text track would have its
mode
change tohidden
.This would make the expectation of media slotted elements is that captions with mode
hidden
work more concrete. It should also be possible to switch tracks by changing the modes tohidden
. Hls.js based players would work, but would require some tweaks or configurations to properly support switching of tracks while keeping themhidden
.The element slotted into the new slot is expected to handle all the rendering of the tracks based on the
textTracks
of the media element and the chosen track that's exposed in the media-controller.If the slotted rendered is removed, rendering should transition back to native rendering by changing the mode back to
showing
. Knowing when an element is added or removed from a slot should be possible with theslotchange
event.A slotted element should use
media-controller's
media-captions-showing
attribute to get the selected textTrack and render the cues appropriately when the active cues change.By default, no element should be slotted, but there should be a media-chrome extras element
<text-track-renderer>
which would use vtt.js to render the cues appropriately. Keeping a separate element that's in extras would open it up for media-chrome users to create their own element should they want to over using the media-chrome extras element.Having this element would allow us to style it smaller when the top or bottom chrome is showing so that captions don't overlap (keeping things away from center chrome is a lot more complicated).
In addition, since we're relying on the native text tracks to still be there, we can swap the track's mode from
hidden
toshowing
when pip is requested so that for browsers that support captions in PiP would receive them. Fullscreen on iPhones is another place we'd want to do this.Beta Was this translation helpful? Give feedback.
All reactions