fix: exit video player when sleep timer completes

close #456
This commit is contained in:
edde746
2026-02-14 11:58:16 +01:00
parent 938e739ba7
commit 2278af8d83
3 changed files with 13 additions and 5 deletions
+8
View File
@@ -33,6 +33,7 @@ import '../services/playback_initialization_service.dart';
import '../services/playback_progress_tracker.dart';
import '../services/offline_watch_sync_service.dart';
import '../services/settings_service.dart';
import '../services/sleep_timer_service.dart';
import '../services/track_selection_service.dart';
import '../services/video_filter_manager.dart';
import '../services/video_pip_manager.dart';
@@ -106,6 +107,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
StreamSubscription<Duration>? _positionSubscription;
StreamSubscription<void>? _playbackRestartSubscription;
StreamSubscription<void>? _backendSwitchedSubscription;
StreamSubscription<void>? _sleepTimerSubscription;
bool _isReplacingWithVideo = false; // Flag to skip orientation restoration during video-to-video navigation
bool _isDisposingForNavigation = false;
bool _waitingForExternalSubsTrackSelection = false;
@@ -219,6 +221,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
// Wire companion remote playback callbacks
_setupCompanionRemoteCallbacks();
// Exit the player when the sleep timer completes so the device can auto-lock
_sleepTimerSubscription = SleepTimerService().onCompleted.listen((_) {
if (mounted) _handleBackButton();
});
// Initialize player asynchronously with buffer size from settings
_initializePlayer();
}
@@ -1374,6 +1381,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
_positionSubscription?.cancel();
_playbackRestartSubscription?.cancel();
_backendSwitchedSubscription?.cancel();
_sleepTimerSubscription?.cancel();
// Cancel auto-play timer
_autoPlayTimer?.cancel();