mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix calculating progress on banner
This commit is contained in:
parent
cda6dc8b9b
commit
35c553cd05
@ -42,7 +42,7 @@ struct PlayerQueueItem: Hashable, Identifiable, Defaults.Serializable {
|
||||
return false
|
||||
}
|
||||
|
||||
return duration - seconds <= 20
|
||||
return (seconds / duration) * 100 > Double(Defaults[.watchedThreshold])
|
||||
}
|
||||
|
||||
var hasDetailsLoaded: Bool {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import CoreMedia
|
||||
import Defaults
|
||||
import Foundation
|
||||
import SDWebImageSwiftUI
|
||||
import SwiftUI
|
||||
@ -169,13 +170,19 @@ struct VideoBanner: View {
|
||||
private var progressView: some View {
|
||||
Group {
|
||||
if !playbackTime.isNil, !(video?.live ?? false) {
|
||||
ProgressView(value: progressViewValue, total: progressViewTotal)
|
||||
ProgressView(value: watchValue, total: progressViewTotal)
|
||||
.progressViewStyle(.linear)
|
||||
.frame(maxWidth: thumbnailWidth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var watchValue: Double {
|
||||
if finished { return progressViewTotal }
|
||||
|
||||
return progressViewValue
|
||||
}
|
||||
|
||||
private var progressViewValue: Double {
|
||||
guard videoDuration != 0 else { return 1 }
|
||||
return [playbackTime?.seconds, videoDuration].compactMap { $0 }.min() ?? 0
|
||||
@ -185,6 +192,10 @@ struct VideoBanner: View {
|
||||
guard videoDuration != 0 else { return 1 }
|
||||
return videoDuration ?? video?.length ?? 1
|
||||
}
|
||||
|
||||
private var finished: Bool {
|
||||
(progressViewValue / progressViewTotal) * 100 > Double(Defaults[.watchedThreshold])
|
||||
}
|
||||
}
|
||||
|
||||
struct VideoBanner_Previews: PreviewProvider {
|
||||
|
Loading…
Reference in New Issue
Block a user