feat(subtitles): Customize how captions look in Settings › Subtitles #42
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/subtitle-style"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed
Settings has a new Subtitles row (under Playback) that shows the current caption style and opens Settings › Subtitles. That screen has one row per caption setting and a preview on the right:
◀ ▶ change a row's value. OK cycles it forward and wraps (Extra large back to Small). Changes save at once and apply to the player straight away.
This follows mockup option B in
design/mockups/bgrid/subtitles/, with one change agreed during design review. The mockup's Position row (Bottom / Raised) became Placement (As broadcast / Always bottom). Raised is no longer a setting: captions move up on their own while the info bar shows.What looks different with no setting touched
The default style is medium white text on a black box, the same as Media3's default. Even so, captions change for everyone in four ways:
How it works
CaptionStyling: turns the savedSubtitleStyleinto a Media3CaptionStyleCompatand text size. It also callssetApplyEmbeddedStyles(false)andsetApplyEmbeddedFontSizes(false). Per Media3's source (SubtitleViewUtils.removeAllEmbeddedStyling), that clears window color, style spans and sizes, and keeps each cue's line and position. US broadcasts use those positions to keep captions clear of score bugs and on-screen names and titles (screenshot 5).PlayerCaptionssends cues to a separate caption view, sized to the picture's frame inside the PlayerView. That view is placed above the info bar so the bar's dark gradient doesn't dim the captions, and below the side panels.third_party/images/SOURCES.md) with sample captions drawn by the sameSubtitleViewandCaptionStylingthe player uses. The sample sits lower left the way a broadcaster places captions, so switching to Always bottom moves it visibly.SettingsStore. A row hands the store a function from the saved value to the next one, and that function runs inside one DataStore edit, so two quick presses step twice. An unknown stored value falls back to the default.SettingRow,Segment,StepArrow,Hintand three size constants inSettingsScreen.ktgo from private to internal, so the new screen reuses them.SettingRowleaves out the description line when it's blank. Every existing row has one, so they don't change.Segmentgains an optional mark before its label, used for the color swatches.OpenRowandActionButtonhelpers draw the "Customize ›" and "Reset ›" buttons.settings/subtitles. Settings returns focus to the Subtitles row on Back, like Favorites and Providers, and the top bar keeps Settings marked.Verified
testDebugUnitTest,lintDebugandassembleRelease, each run on its own. The newSubtitleStyleTestcovers:TopBarSectionTestchecks that Subtitles keeps Settings marked. The merge itself (placeCues) builds Android text objects, so it's checked on the emulator, not in unit tests.Screenshots
Not tested
Intent: let viewers change how captions look (size, color, background, edge, font) and choose between the broadcaster's caption placement and always-bottom, with a preview that matches the player.
Not a goal: