mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-28 22:27:14 +02:00
Fix all kinds of syncing errors
This commit is contained in:
@@ -71,12 +71,16 @@ class PlayerHandler {
|
||||
}
|
||||
|
||||
public static func stopPlayback() {
|
||||
player?.destroy()
|
||||
player = nil
|
||||
// Pause playback first, so we can sync our current progress
|
||||
player?.pause()
|
||||
|
||||
// Stop updating progress before we destory the player, so we don't receive bad data
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
|
||||
player?.destroy()
|
||||
player = nil
|
||||
|
||||
NowPlayingInfo.shared.reset()
|
||||
}
|
||||
|
||||
@@ -164,6 +168,9 @@ class PlayerHandler {
|
||||
return
|
||||
}
|
||||
|
||||
// Prevent a sync if we got junk data from the player (occurs when exiting out of memory
|
||||
guard !playerCurrentTime.isNaN else { return }
|
||||
|
||||
lastSyncTime = Date().timeIntervalSince1970 // seconds
|
||||
let report = PlaybackReport(currentTime: playerCurrentTime, duration: player.getDuration(), timeListened: listeningTimePassedSinceLastSync)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user