mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 14:47:21 +02:00
Fix session time using milliseconds instead of seconds
This commit is contained in:
@@ -49,16 +49,18 @@ class PlayerProgress {
|
|||||||
guard let session = PlayerHandler.getPlaybackSession() else { return nil }
|
guard let session = PlayerHandler.getPlaybackSession() else { return nil }
|
||||||
guard !currentTime.isNaN else { return nil } // Prevent bad data on player stop
|
guard !currentTime.isNaN else { return nil } // Prevent bad data on player stop
|
||||||
|
|
||||||
let now = Date().timeIntervalSince1970 * 1000
|
let nowInSeconds = Date().timeIntervalSince1970
|
||||||
let lastUpdate = session.updatedAt ?? now
|
let nowInMilliseconds = nowInSeconds * 1000
|
||||||
let timeSinceLastUpdate = now - lastUpdate
|
let lastUpdateInMilliseconds = session.updatedAt ?? nowInMilliseconds
|
||||||
|
let lastUpdateInSeconds = lastUpdateInMilliseconds / 1000
|
||||||
|
let secondsSinceLastUpdate = nowInSeconds - lastUpdateInSeconds
|
||||||
|
|
||||||
session.update {
|
session.update {
|
||||||
session.currentTime = currentTime
|
session.currentTime = currentTime
|
||||||
session.updatedAt = now
|
session.updatedAt = nowInMilliseconds
|
||||||
|
|
||||||
if includesPlayProgress {
|
if includesPlayProgress {
|
||||||
session.timeListening += timeSinceLastUpdate
|
session.timeListening += secondsSinceLastUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user