fix: reapply track selection and external subs after MPV fallback
This commit is contained in:
@@ -166,6 +166,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
bool _waitingForExternalSubsTrackSelection = false;
|
||||
bool _isApplyingTrackSelection = false;
|
||||
bool _isHandlingBack = false;
|
||||
List<SubtitleTrack> _lastExternalSubtitles = const [];
|
||||
BifThumbnailService? _bifService;
|
||||
|
||||
// Live TV channel navigation
|
||||
@@ -1014,6 +1015,8 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
_livePlaybackStartTime = DateTime.now();
|
||||
await player!.open(Media(streamUrl, headers: const {'Accept-Language': 'en'}), play: true, isLive: true);
|
||||
|
||||
_lastExternalSubtitles = const [];
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_availableVersions = [];
|
||||
@@ -1186,6 +1189,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
}
|
||||
}
|
||||
|
||||
// Store external subtitles for re-use after backend fallback
|
||||
_lastExternalSubtitles = result.externalSubtitles;
|
||||
|
||||
// Add external subtitles while paused, then start playback
|
||||
if (result.externalSubtitles.isNotEmpty) {
|
||||
_hasFirstFrame.value = false;
|
||||
@@ -1981,6 +1987,21 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
if (mounted) {
|
||||
showAppSnackBar(context, t.messages.switchingToCompatiblePlayer);
|
||||
}
|
||||
|
||||
// Re-add external subtitles to MPV (lost when ExoPlayer was disposed)
|
||||
if (_lastExternalSubtitles.isNotEmpty) {
|
||||
_addExternalSubtitles(_lastExternalSubtitles);
|
||||
}
|
||||
|
||||
// Re-subscribe to tracks so we reapply Plex/user preferences when MPV's track list arrives
|
||||
_trackLoadingSubscription?.cancel();
|
||||
_trackLoadingSubscription = player?.streams.tracks.listen((tracks) {
|
||||
if (tracks.audio.isEmpty && tracks.subtitle.isEmpty) return;
|
||||
|
||||
_trackLoadingSubscription?.cancel();
|
||||
_trackLoadingSubscription = null;
|
||||
_applyTrackSelection();
|
||||
});
|
||||
}
|
||||
|
||||
// OS Media Controls Integration
|
||||
|
||||
Reference in New Issue
Block a user