mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-31 23:20:35 +02:00
Fix lost sleep time on play/pause
This commit is contained in:
parent
5c76158729
commit
268cf67576
1 changed files with 6 additions and 0 deletions
|
@ -224,6 +224,9 @@ class AudioPlayer: NSObject {
|
||||||
public func play(allowSeekBack: Bool = false) {
|
public func play(allowSeekBack: Bool = false) {
|
||||||
guard self.isInitialized() else { return }
|
guard self.isInitialized() else { return }
|
||||||
|
|
||||||
|
// Capture remaining sleep time before changing the track position
|
||||||
|
let sleepSecondsRemaining = PlayerHandler.remainingSleepTime
|
||||||
|
|
||||||
if allowSeekBack {
|
if allowSeekBack {
|
||||||
let diffrence = Date.timeIntervalSinceReferenceDate - lastPlayTime
|
let diffrence = Date.timeIntervalSinceReferenceDate - lastPlayTime
|
||||||
var time: Int?
|
var time: Int?
|
||||||
|
@ -262,6 +265,9 @@ class AudioPlayer: NSObject {
|
||||||
self.rate = self.tmpRate
|
self.rate = self.tmpRate
|
||||||
self.audioPlayer.rate = self.tmpRate
|
self.audioPlayer.rate = self.tmpRate
|
||||||
|
|
||||||
|
// If we have an active sleep timer, reschedule based on rate
|
||||||
|
self.rescheduleSleepTimerAtTime(time: self.getCurrentTime(), secondsRemaining: sleepSecondsRemaining)
|
||||||
|
|
||||||
updateNowPlaying()
|
updateNowPlaying()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue