feat: Add dual subtitle playback with translation support.#5839
Open
whyzgeek wants to merge 1 commit into
Open
feat: Add dual subtitle playback with translation support.#5839whyzgeek wants to merge 1 commit into
whyzgeek wants to merge 1 commit into
Conversation
Author
|
I prepped this using AI and tested all worked on Android device and FireTV Stick |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dual subtitles with on-the-fly translation
Adds a "dual subtitles" mode that renders a second translated line below the
primary subtitle while a video plays. This is very useful for language learners. The translation source is picked
automatically:
tlangtimedtext when the selected caption track ismarked translatable — same XML the YouTube site uses, no extra latency, and
line breaks stay aligned with the primary track.
can't be translated by YouTube (e.g. user-uploaded SRT-style captions),
with an LRU cache of the last 200 lines.
The translated line is rendered in italic light-green directly under the
original by a small extension to the SmartTube ExoPlayer fork's
SubtitlePainter, so both lines paint as a single block (no flicker, no
parallel SubtitleView overlays).
Why a Painter-level change
The translated text is merged into the same Cue as the original, then tagged
with an android.text.Annotation span (smarttube-dual / translation).
SubtitlePainter detects the span and renders the second line with a separate
TextPaint, so the merge:
apply to the primary line),
player resize, AFR switching, PiP, etc.).
User-facing controls
languages).
dialog and shows a warning if dual subtitles isn't enabled yet.
Settings persistence
Three new fields appended to the existing PlayerData serialization
(indices 63, 65, 66) — backwards-compatible with existing saved prefs.