Sync local progress with server progress

This commit is contained in:
ronaldheft 2022-08-12 23:11:09 -04:00
parent 8d38f3358e
commit ef661bba37
6 changed files with 89 additions and 26 deletions

View file

@ -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 }
}