Fix player controls progress bar

This commit is contained in:
Arkadiusz Fal 2022-01-06 15:55:34 +01:00
parent 7317aec1ed
commit c1e219e46e

View File

@ -27,7 +27,9 @@ extension PlayerModel {
return return
} }
let time = player.currentTime().seconds let time = player.currentTime()
let seconds = time.seconds
currentItem.playbackTime = time
let watch: Watch! let watch: Watch!
let watchFetchRequest = Watch.fetchRequest() let watchFetchRequest = Watch.fetchRequest()
@ -36,7 +38,7 @@ extension PlayerModel {
let results = try? context.fetch(watchFetchRequest) let results = try? context.fetch(watchFetchRequest)
if results?.isEmpty ?? true { if results?.isEmpty ?? true {
if time < 1 { if seconds < 1 {
return return
} }
watch = Watch(context: context) watch = Watch(context: context)
@ -55,8 +57,8 @@ extension PlayerModel {
if finished { if finished {
watch.stoppedAt = watch.videoDuration watch.stoppedAt = watch.videoDuration
} else if time.isFinite, time > 0 { } else if seconds.isFinite, seconds > 0 {
watch.stoppedAt = time watch.stoppedAt = seconds
} }
watch.watchedAt = Date() watch.watchedAt = Date()