mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Update watch time on close item
This commit is contained in:
parent
0328656a44
commit
6f91eedf4c
@ -46,11 +46,11 @@ extension PlayerModel {
|
||||
}
|
||||
}
|
||||
|
||||
func updateWatch(finished: Bool = false) {
|
||||
func updateWatch(finished: Bool = false, time: CMTime? = nil) {
|
||||
guard let currentVideo, saveHistory else { return }
|
||||
|
||||
let id = currentVideo.videoID
|
||||
let time = backend.currentTime
|
||||
let time = time ?? backend.currentTime
|
||||
let seconds = time?.seconds ?? 0
|
||||
let duration = playerTime.duration.seconds
|
||||
if seconds < 3 {
|
||||
@ -63,7 +63,7 @@ extension PlayerModel {
|
||||
let results = try? backgroundContext.fetch(watchFetchRequest)
|
||||
|
||||
backgroundContext.perform { [weak self] in
|
||||
guard let self, finished || self.backend.isPlaying else {
|
||||
guard let self, finished || time != nil || self.backend.isPlaying else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
|
||||
self.timeObserverThrottle.execute {
|
||||
self.model.updateWatch()
|
||||
self.model.updateWatch(time: self.currentTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -656,7 +656,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
#endif
|
||||
|
||||
self.timeObserverThrottle.execute {
|
||||
self.model.updateWatch()
|
||||
self.model.updateWatch(time: self.currentTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ final class MPVBackend: PlayerBackend {
|
||||
}
|
||||
|
||||
timeObserverThrottle.execute {
|
||||
self.model.updateWatch()
|
||||
self.model.updateWatch(time: self.currentTime)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,13 +624,14 @@ final class PlayerModel: ObservableObject {
|
||||
closing = true
|
||||
controls.presentingControls = false
|
||||
|
||||
self.prepareCurrentItemForHistory(finished: finished)
|
||||
|
||||
self.hide()
|
||||
|
||||
Delay.by(0.8) { [weak self] in
|
||||
guard let self else { return }
|
||||
self.closePiP()
|
||||
|
||||
self.prepareCurrentItemForHistory(finished: finished)
|
||||
withAnimation {
|
||||
self.currentItem = nil
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ extension PlayerModel {
|
||||
if let video = currentVideo, !historyVideos.contains(where: { $0 == video }) {
|
||||
historyVideos.append(video)
|
||||
}
|
||||
updateWatch(finished: finished)
|
||||
updateWatch(finished: finished, time: backend.currentTime)
|
||||
}
|
||||
|
||||
if let video = currentItem.video,
|
||||
|
Loading…
Reference in New Issue
Block a user