mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 10:04:39 +02:00
Sync local progress with server progress
This commit is contained in:
parent
8d38f3358e
commit
ef661bba37
6 changed files with 89 additions and 26 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
struct PlaybackSession: Decodable, Encodable {
|
||||
struct PlaybackSession: Codable {
|
||||
var id: String
|
||||
var userId: String?
|
||||
var libraryItemId: String?
|
||||
|
@ -30,10 +30,21 @@ struct PlaybackSession: Decodable, Encodable {
|
|||
var serverConnectionConfigId: String?
|
||||
var serverAddress: String?
|
||||
|
||||
var isLocal: Bool { self.localLibraryItem != nil }
|
||||
|
||||
var localMediaProgressId: String {
|
||||
if let episodeId = episodeId {
|
||||
return "\(localLibraryItem!.id)-\(episodeId)"
|
||||
} else {
|
||||
return localLibraryItem!.id
|
||||
}
|
||||
}
|
||||
|
||||
var totalDuration: Double {
|
||||
var total = 0.0
|
||||
self.audioTracks.forEach { total += $0.duration }
|
||||
return total
|
||||
}
|
||||
|
||||
var progress: Double { self.currentTime / self.totalDuration }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue