mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
32 lines
740 B
Swift
32 lines
740 B
Swift
import AVFoundation
|
|
import Foundation
|
|
|
|
struct PlayerQueueItem: Hashable, Identifiable {
|
|
var id = UUID()
|
|
var video: Video
|
|
var playbackTime: CMTime?
|
|
var videoDuration: TimeInterval?
|
|
|
|
init(_ video: Video, playbackTime: CMTime? = nil, videoDuration: TimeInterval? = nil) {
|
|
self.video = video
|
|
self.playbackTime = playbackTime
|
|
self.videoDuration = videoDuration
|
|
}
|
|
|
|
var duration: TimeInterval {
|
|
videoDuration ?? video.length
|
|
}
|
|
|
|
var shouldRestartPlaying: Bool {
|
|
guard let seconds = playbackTime?.seconds else {
|
|
return false
|
|
}
|
|
|
|
return duration - seconds <= 10
|
|
}
|
|
|
|
func hash(into hasher: inout Hasher) {
|
|
hasher.combine(id)
|
|
}
|
|
}
|