Skip to content

feat: caption style and toggle persistence - #608

Draft
OscarBarrett wants to merge 7 commits into
reisxd:mainfrom
OscarBarrett:feat/caption-style-persistence
Draft

feat: caption style and toggle persistence#608
OscarBarrett wants to merge 7 commits into
reisxd:mainfrom
OscarBarrett:feat/caption-style-persistence

Conversation

@OscarBarrett

Copy link
Copy Markdown

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 through resolveCommand, judged by isSubtitlesOn() 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

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.
@reisxd

reisxd commented Aug 28, 2026

Copy link
Copy Markdown
Owner

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 captionsOnCommand when the user changes the caption language? Checking for the selectSubtitlesTrackCommand property in resolveCommand should be it.

@OscarBarrett

Copy link
Copy Markdown
Author

Yeah that makes sense, I'll look into that 👍.
Also, considering if the caption toggle persistence should be listed as its own setting, or rename the setting to make it clear it persists both?

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.
Will do some more debugging for those and move this back to open when it's at 100% :)

@OscarBarrett
OscarBarrett marked this pull request as draft August 28, 2026 21:04
@reisxd

reisxd commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Also, considering if the caption toggle persistence should be listed as its own setting, or rename the setting to make it clear it persists both?

Splitting both could be better. Both could also be enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] To remember subtitles status

2 participants