-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[docs] add captions toggle to homepage video #8069
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
Conversation
|
| */ | ||
| function set_cue_position(node) { | ||
| const cues = node.track.cues; | ||
| if (!cues) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this works because the .vtt file is loaded by the time the JS runs (basically the inverse of the problem in onMount here), but it could presumably happen in the opposite order. Is there an event we can listen for if cues doesn't exist yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - I was able to listen to the <track>'s load event if we don't have cues yet. I tested it by wrapping the <track> in an {#if browser} block and it seemed to work. 922677f
|
nice! the captions are really great to have. it's nice that I can get the value out of the video while it's muted and I also think it will grab the attention of visitors who might otherwise skip over it |
amazing work getting the subtitles to look good, i was very much resigned to them not doing so. i think having them visible when you first hit the page is a huge win. |
This PR enables the video captions by default and adds a toggle to turn them on and off. We don't have a ton of styling flexibility, but I did what I could. The visual "enabled" state of the toggle is just a text underline.
I applied the same "unused" styling as the sound toggle, to make it more obvious that it's available.
I wasn't sure where to get an icon for the CC toggle so it's just text for now (which seems to cause some alignment issues with the sound toggle in firefox). I think it looks okay, but happy to swap out for an icon if someone can provide an SVG.
We could disable the captions by default if necessary, but imo it's nice having them on by default so people can understand the video without needing to turn on sound or hunt for the CC button. Especially since we autoplay the video and there's no way to seek at the moment - this helps people not miss the beginning.
Screenshots of captions on different browsers
Chrome
Safari
Firefox
Mobile screen width (Chrome)
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0