feat: multi-track subtitle selection#948
Open
Ortes wants to merge 4 commits into
Open
Conversation
Generalise subtitle support beyond a single on/off cue list: the controller now holds a source-agnostic list of selectable SubtitleTracks, an active id and an onSubtitleTrackChanged callback, plus a liveSubtitle ValueNotifier for streaming sources (e.g. HLS) that emit cue text over time. - ChewieController: subtitleTracks / activeSubtitleTrackId / onSubtitleTrackChanged / liveSubtitle, setSubtitleTracks, selectSubtitleTrack, setLiveSubtitle; copyWith + dispose wired. - Material + Material desktop controls: a Subtitles entry in the options menu opening a track picker, live-cue rendering reusing subtitleBuilder, and a track-aware toggle. - SubtitleTrackDialog widget + SubtitleTrack model.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #948 +/- ##
===========================================
+ Coverage 43.82% 58.30% +14.48%
===========================================
Files 21 23 +2
Lines 1602 1746 +144
===========================================
+ Hits 702 1018 +316
+ Misses 900 728 -172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds unit and widget tests for the new subtitle-track API: - SubtitleTrack model (equality, hashCode, toString) - SubtitleTrackDialog (rendering, selection, custom off label, dismissal) - ChewieController track methods (setSubtitleTracks, selectSubtitleTrack, setLiveSubtitle, copyWith, dispose, hasSubtitleTracks) - Material and desktop controls: toggle-driven selection, options-menu track picker, live-cue and static-cue rendering, custom subtitleBuilder Brings patch coverage to ~99%.
The Material controls passed the optionsTranslation subtitle label into the SubtitleTrackDialog's "off" entry, but the desktop controls always showed the hardcoded "Off". Mirror the Material behavior so both variants honor optionsTranslation.subtitlesButtonText.
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.
Motivation
Streaming sources (notably HLS) expose multiple subtitle renditions in their manifest, but Chewie currently has no UI to let the user pick one. This adds a source-agnostic subtitle-track picker to the Material controls.
What this adds
subtitleTracksis non-empty.setLiveSubtitle), alongside the existing staticsubtitlecue list.The widget is source-agnostic: the host populates the track list and reacts to selection; Chewie never assumes HLS or any particular backend.
API (all opt-in — defaults preserve current behavior)
ChewieController:List<SubtitleTrack> subtitleTracks— selectable tracks (default empty).Object? activeSubtitleTrackId— currently selected id (null= Off).void Function(SubtitleTrack?)? onSubtitleTrackChanged— selection callback.setSubtitleTracks()/selectSubtitleTrack()— for tracks known only after load.setLiveSubtitle(String?)+ValueNotifier<String?> liveSubtitle— push current cue text for streaming sources.bool get hasSubtitleTracks— gates the menu entry.New:
SubtitleTrackmodel andSubtitleTrackDialogbottom sheet.Backwards compatibility
Fully backwards compatible — every field is optional and defaults to the current behavior. No menu entry appears unless the host provides tracks.
Testing
dart analyze— no issues.setLiveSubtitle).Independent of the audio-track PR (#949) — single commit, based on
master.