mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-20 09:40:17 +02:00
Fix:Android sleep timer reset volume when shake #626
This commit is contained in:
parent
e4345a4438
commit
15ccc7192e
1 changed files with 9 additions and 11 deletions
|
@ -61,6 +61,7 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe
|
||||||
sleepTimerRunning = true
|
sleepTimerRunning = true
|
||||||
sleepTimerFinishedAt = 0L
|
sleepTimerFinishedAt = 0L
|
||||||
sleepTimerElapsed = 0L
|
sleepTimerElapsed = 0L
|
||||||
|
setVolume(1f)
|
||||||
|
|
||||||
// Register shake sensor
|
// Register shake sensor
|
||||||
playerNotificationService.registerSensor()
|
playerNotificationService.registerSensor()
|
||||||
|
@ -107,17 +108,14 @@ class SleepTimerManager constructor(private val playerNotificationService: Playe
|
||||||
playerNotificationService.clientEventEmitter?.onSleepTimerEnded(getCurrentTime())
|
playerNotificationService.clientEventEmitter?.onSleepTimerEnded(getCurrentTime())
|
||||||
clearSleepTimer()
|
clearSleepTimer()
|
||||||
sleepTimerFinishedAt = System.currentTimeMillis()
|
sleepTimerFinishedAt = System.currentTimeMillis()
|
||||||
} else if (sleepTimeSecondsRemaining <= 60) {
|
} else if (sleepTimeSecondsRemaining <= 60 && DeviceManager.deviceData.deviceSettings?.disableSleepTimerFadeOut != true) {
|
||||||
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
|
// Start fading out audio down to 10% volume
|
||||||
val percentToReduce = 1 - (sleepTimeSecondsRemaining / 60F)
|
val percentToReduce = 1 - (sleepTimeSecondsRemaining / 60F)
|
||||||
val volume = 1f - (percentToReduce * 0.9f)
|
val volume = 1f - (percentToReduce * 0.9f)
|
||||||
Log.d(tag, "SLEEP VOLUME FADE $volume | ${sleepTimeSecondsRemaining}s remaining")
|
Log.d(tag, "SLEEP VOLUME FADE $volume | ${sleepTimeSecondsRemaining}s remaining")
|
||||||
setVolume(volume)
|
setVolume(volume)
|
||||||
}
|
} else {
|
||||||
|
setVolume(1f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue