A cross platform Audiobookshelf client for Android and iOS
Dart
Stop stuckCheckTimer on pause, restart on play to avoid background wakes
Nathan Poulsondfbff65c7412
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dartindex 3b38a22e..a1928bc9 100644--- a/lib/services/audio_player_service.dart+++ b/lib/services/audio_player_service.dart@@ -2339,6 +2339,10 @@ class AudioPlayerService extends ChangeNotifier {await _saveProgressLocal(pos);});}+ // Restart stuck detection (stopped on pause to avoid background wakes)+ if (_stuckCheckTimer == null || !_stuckCheckTimer!.isActive) {+ _startStuckDetection();+ }// Check auto sleep on every resume — catches window entry between pausesSleepTimerService().checkAutoSleep();notifyListeners();@@ -2348,12 +2352,17 @@ class AudioPlayerService extends ChangeNotifier {debugPrint('[Service] pause() called');_wasPlayingBeforeInterrupt = false;_lastPauseTime = DateTime.now();- // Stop safety-net save timer to avoid background wakes while paused+ // Stop timers to avoid background wakes while pausedif (_bgSaveTimer != null) {debugPrint('[Battery] bgSaveTimer STOPPED (pause)');_bgSaveTimer!.cancel();_bgSaveTimer = null;}+ if (_stuckCheckTimer != null) {+ debugPrint('[Battery] stuckCheckTimer STOPPED (pause)');+ _stuckCheckTimer!.cancel();+ _stuckCheckTimer = null;+ }await _player?.pause();_logEvent(PlaybackEventType.pause);_onPlaybackStateChangedCallback?.call(false);