fix(player): keep hidden and cycled subtitles off in the next episode

Episode navigation carries the subtitle choice this screen has committed, so
a way of turning subtitles off that the screen never sees is undone by the
next episode.

ExoPlayer has no renderer-level visibility switch, so the player's hide
toggle is emulated by deselecting the track. That emulation lasted until the
next selection: the automatic pass after an episode change put subtitles
straight back on screen while the toggle still read "hidden", and un-hiding
then restored a track id belonging to the episode that had already ended.
Hiding is now sticky across media opens the way mpv's global sub-visibility
is, selections made while hidden become what un-hiding restores, and the
toggle no longer refuses to restore because the hidden track reads as Off.

Cycling subtitles over the native track list — downloads, and items whose
server exposes no subtitle rows — went straight to the track manager, which
owns the player selection and the server write-back but not the committed
choice. The screen records the cycled track now.
This commit is contained in:
edde746
2026-08-03 17:07:14 +02:00
parent e7aa1e4782
commit 2b4875d389
6 changed files with 245 additions and 21 deletions
@@ -4,11 +4,19 @@ final Expando<LatestAsyncWrite<String>> _subtitleVisibilityWrites = Expando<Late
extension _PlexVideoControlsTrackMethods on _PlexVideoControlsState {
void _toggleSubtitles() {
final currentTrack = widget.player.state.track.subtitle;
// No-op if no subtitle track is selected
if (currentTrack == null || currentTrack.id == 'no') return;
// Restoring always works: backends without a renderer-level visibility
// switch hide subtitles by deselecting them, so the current track reads
// as Off while hidden and a selection check would trap the toggle.
if (!_subtitlesVisible) {
_setSubtitleVisibility(true);
return;
}
_setSubtitleVisibility(!_subtitlesVisible);
final currentTrack = widget.player.state.track.subtitle;
// Nothing to hide when no subtitle track is selected.
if (currentTrack == null || currentTrack.id == SubtitleTrack.off.id) return;
_setSubtitleVisibility(false);
}
void _onSubtitleTrackChanged(SubtitleTrack track) {