feat: caption style and toggle persistence - #608
Conversation
YouTube TV stores caption style in localStorage with a 30-day TTL and sometimes never writes it at all, so Caption style settings reset when the app restarts. Updated the config store for captionssettingschanged, re-apply it via updateSubtitlesUserSettings on startup, and back up / restore the raw yt-player-caption-* keys with a far-future expiration. Adds a "Remember Caption Style" toggle under Subtitle Settings (default on).
The TV app never writes yt-player-sticky-caption, so backing up that key could not restore the CC state. Track isSubtitlesOn() on captionschanged (ignoring videos with no caption tracks). When the saved state is on, call toggleSubtitlesOn() once per video after the track list loads.
…spatch Guard isSubtitlesOn() with try/catch, only read the CC state once the track list exists, and defer toggleSubtitlesOn() out of the player's event handler with setTimeout.
getOption('captions', 'tracklist') can be empty on the TV player even when a video has captions, which blocked both saving and restoring the CC state. Fall back to the caption tracks in getPlayerResponse().
The player fires captionschanged with an empty track and isSubtitlesOn() false both while a video is starting and when it is unloaded on returning to the feed, which recorded a bogus "off" state. Only accept an off reading while the player is playing or paused.
The TV app keeps its own captions on/off state and overrides the player, so toggling via the player API gets reverted. Wrap resolveCommand to observe caption commands, record the one that turned captions on (judged by isSubtitlesOn() before and after), and replay it once a captioned video is playing, retrying a few times if the app switches captions back off.
Matching any key containing "subtitle" caught the subtitle text field of toast and popup renderers, so unrelated commands were observed and replayed. Match only caption command/endpoint/action keys at the top level or inside commandExecutorCommand, and discard a stored command that no longer matches.
|
Hi, this is almost perfect! Thanks for your work. I had tried to figure out how to keep captions persisting before and had failed, so it's nice to see someone else figure out (and your code doesn't seem to be written by AI, lovely). Small nitpick though: Is it possible to change |
|
Yeah that makes sense, I'll look into that 👍. I'll move this to a draft btw - I've been running it for a few days and the caption toggle works 95% of the time, but it looks like there can be cases where it maxes out the retries, or the app's own events fight with it and defeat the retry. |
Splitting both could be better. Both could also be enabled by default. |
YouTube TV stores caption style with what appears to be a 30-day TTL and the app never persists the CC on/off state, so both reset - CC state on restart, caption style when it feels like it.
This PR mirrors the caption style into TizenTube's config, re-applies it via
updateSubtitlesUserSettings, and records the app's caption command (observed throughresolveCommand, judged byisSubtitlesOn()flipping) to replay once a captioned video plays.Adds a "Remember Caption Style" toggle under Subtitle Settings, default on.
Tested on a 2022 QN85B (Tizen 6.5).
Resolves #362, #405