Add buttons to next video and restart video (fix #106)

Previous video requires rebuilding queue a little, maybe in the future
This commit is contained in:
Arkadiusz Fal
2022-05-29 17:50:54 +02:00
parent 4f6e0e2a3d
commit 44e6c28fd4
4 changed files with 38 additions and 10 deletions

View File

@@ -281,8 +281,12 @@ final class PlayerModel: ObservableObject {
}
func upgradeToStream(_ stream: Stream, force: Bool = false) {
guard let video = currentVideo else {
return
}
if !self.stream.isNil, force || self.stream != stream {
playStream(stream, of: currentVideo!, preservingTime: true, upgrading: true)
playStream(stream, of: video, preservingTime: true, upgrading: true)
}
}

View File

@@ -1,10 +1,12 @@
import CoreData
import CoreMedia
import Defaults
import Foundation
@objc(Watch)
final class Watch: NSManagedObject, Identifiable {
@Default(.watchedThreshold) private var watchedThreshold
@Default(.saveHistory) private var saveHistory
}
extension Watch {
@@ -45,4 +47,15 @@ extension Watch {
formatter.unitsStyle = .full
return formatter.localizedString(for: watchedAt, relativeTo: Date())
}
var timeToRestart: CMTime? {
finished ? nil : saveHistory ? .secondsInDefaultTimescale(stoppedAt) : nil
}
var video: Video {
Video(
videoID: videoID, title: "", author: "",
length: 0, published: "", views: -1, channel: Channel(id: "", name: "")
)
}
}