diff --git a/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt b/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt index a4ae9833..e187e130 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt @@ -61,6 +61,7 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe sleepTimerRunning = true sleepTimerFinishedAt = 0L sleepTimerElapsed = 0L + setVolume(1f) // Register shake sensor playerNotificationService.registerSensor() @@ -107,17 +108,14 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe playerNotificationService.clientEventEmitter?.onSleepTimerEnded(getCurrentTime()) clearSleepTimer() sleepTimerFinishedAt = System.currentTimeMillis() - } else if (sleepTimeSecondsRemaining <= 60) { - if (DeviceManager.deviceData.deviceSettings?.disableSleepTimerFadeOut == true) { - // Set volume to 1 in case setting was enabled while fading - setVolume(1f) - } else { - // Start fading out audio down to 10% volume - val percentToReduce = 1 - (sleepTimeSecondsRemaining / 60F) - val volume = 1f - (percentToReduce * 0.9f) - Log.d(tag, "SLEEP VOLUME FADE $volume | ${sleepTimeSecondsRemaining}s remaining") - setVolume(volume) - } + } else if (sleepTimeSecondsRemaining <= 60 && DeviceManager.deviceData.deviceSettings?.disableSleepTimerFadeOut != true) { + // Start fading out audio down to 10% volume + val percentToReduce = 1 - (sleepTimeSecondsRemaining / 60F) + val volume = 1f - (percentToReduce * 0.9f) + Log.d(tag, "SLEEP VOLUME FADE $volume | ${sleepTimeSecondsRemaining}s remaining") + setVolume(volume) + } else { + setVolume(1f) } } }