Skip to content

feat(player): add transparent subtitle background option - #58

Merged
ModerRAS merged 1 commit into
masterfrom
feat/subtitle-transparent-background
Aug 1, 2026
Merged

feat(player): add transparent subtitle background option#58
ModerRAS merged 1 commit into
masterfrom
feat/subtitle-transparent-background

Conversation

@ModerRAS

@ModerRAS ModerRAS commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

Add a per-player preference to render subtitles on a transparent background — only the text and outline are kept, and the black caption background is dropped.

Changes

  • Preferences: PlaybackPreferencesManager persists subtitleBackgroundTransparent (default false); added to PlaybackPreferencesRepository.
  • Player: PlayerScreen derives a CaptionStyleCompat with a transparent background when the option is on; PlayerViewModel exposes the state.
  • Settings: PlaybackPanel gains a "透明底 / 黑色底" toggle.
  • Web control: PlaybackSettingsDto/Request carry the flag; WebControlService get/set it; frontend App.vue adds the switch.

Tests

  • PlaybackPreferencesManagerTest: preference persistence
  • PlayerSubtitleStyleTest: caption style derivation keeps text/outline and only clears the background
  • WebControlSettingsRouteTest: round-trip via the settings API

Notes

  • Branch: feat/subtitle-transparent-background
  • A stray NUL file in the repo root was left untracked intentionally (not part of this change).

Summary by CodeRabbit

  • New Features

    • Added a subtitle setting to toggle transparent or black backgrounds.
    • Subtitle backgrounds now respect the selected preference during playback.
    • The setting is available in both the TV app and web control interface.
    • Preferences persist across sessions and synchronize through playback settings.
  • Tests

    • Added coverage for preference persistence, subtitle styling, and web control synchronization.

Render subtitles on a transparent background (keep only text + outline, drop the
black caption background) via a new per-player preference.

- PlaybackPreferencesManager persists subtitleBackgroundTransparent (default false)
- PlayerScreen derives a CaptionStyleCompat with a transparent background when enabled
- Settings PlaybackPanel gains a transparent-background toggle
- Web control (DTO/request + frontend switch) exposes the same option
- Unit tests cover preference persistence and caption style derivation
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5dccfdb6-3dae-4a20-a43a-26f7fb8dc966

📥 Commits

Reviewing files that changed from the base of the PR and between 91dccbc and a23cb5c.

📒 Files selected for processing (14)
  • core/model/src/main/kotlin/com/miruplay/tv/model/PlaybackUiConventions.kt
  • data/src/main/kotlin/com/miruplay/tv/data/preferences/PlaybackPreferencesManager.kt
  • data/src/test/kotlin/com/miruplay/tv/data/preferences/PlaybackPreferencesManagerTest.kt
  • repository-api/src/main/kotlin/com/miruplay/tv/repository/PlaybackPreferencesRepository.kt
  • ui-tv/src/main/kotlin/com/miruplay/tv/ui/player/PlayerScreen.kt
  • ui-tv/src/main/kotlin/com/miruplay/tv/ui/player/PlayerViewModel.kt
  • ui-tv/src/main/kotlin/com/miruplay/tv/ui/settings/AddSourceScreen.kt
  • ui-tv/src/main/kotlin/com/miruplay/tv/ui/settings/SettingsViewModel.kt
  • ui-tv/src/test/kotlin/com/miruplay/tv/ui/player/PlayerSubtitleStyleTest.kt
  • ui-tv/src/test/kotlin/com/miruplay/tv/ui/settings/SettingsViewModelTokenTest.kt
  • web-control-core/src/main/kotlin/com/miruplay/tv/webcontrol/WebControlModels.kt
  • web-control-core/src/test/kotlin/com/miruplay/tv/webcontrol/WebControlSettingsRouteTest.kt
  • web-control/frontend/src/App.vue
  • web-control/src/main/kotlin/com/miruplay/tv/webcontrol/WebControlService.kt

📝 Walkthrough

Walkthrough

The change adds a persisted subtitle background transparency preference. Android settings and the player use it, while web-control APIs and the frontend load and save it.

Changes

Subtitle background transparency

Layer / File(s) Summary
Preference storage contract
repository-api/src/main/kotlin/..., data/src/main/kotlin/..., data/src/test/...
The preference repository and SharedPreferences manager expose a Boolean setting that defaults to false. Tests verify persistence.
Android settings flow
core/model/src/main/kotlin/..., ui-tv/src/main/kotlin/com/miruplay/tv/ui/settings/..., ui-tv/src/test/...
SettingsViewModel loads and saves the preference. PlaybackPanel provides localized labels, a toggle, and the current status.
Player subtitle rendering
ui-tv/src/main/kotlin/com/miruplay/tv/ui/player/..., ui-tv/src/test/...
PlayerScreen applies system caption styles and optionally clears only the subtitle background. Tests verify style preservation.
Web-control settings flow
web-control-core/src/main/kotlin/..., web-control/src/main/kotlin/..., web-control/frontend/src/..., web-control-core/src/test/...
Playback settings DTOs, service handling, frontend state, save requests, and route tests include subtitleBackgroundTransparent.

Estimated code review effort: 4 (Complex) | ~35 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PlaybackPanel
  participant SettingsViewModel
  participant PlaybackPreferencesRepository
  participant PlaybackPreferencesManager
  participant PlayerViewModel
  participant PlayerScreen

  PlaybackPanel->>SettingsViewModel: setSubtitleBackgroundTransparent(value)
  SettingsViewModel->>PlaybackPreferencesRepository: set preference
  PlaybackPreferencesRepository->>PlaybackPreferencesManager: persist Boolean value
  PlayerViewModel->>PlaybackPreferencesRepository: get preference during initialization
  PlaybackPreferencesRepository-->>PlayerViewModel: return Boolean value
  PlayerViewModel-->>PlayerScreen: expose subtitleBackgroundTransparent
  PlayerScreen->>PlayerScreen: apply subtitleCaptionStyle
Loading

Possibly related PRs

  • ModerRAS/MiruPlay#46: Modifies adjacent subtitle settings infrastructure and shared playback preference components.
  • ModerRAS/MiruPlay#50: Modifies playback preferences and settings APIs for a different playback option.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a transparent subtitle background option for the player.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/subtitle-transparent-background

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ModerRAS
ModerRAS merged commit 4fc2fb6 into master Aug 1, 2026
7 checks passed
@ModerRAS
ModerRAS deleted the feat/subtitle-transparent-background branch August 1, 2026 23:05
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.

1 participant