Persistence for queue, history and last played

This commit is contained in:
Arkadiusz Fal
2021-10-24 20:01:08 +02:00
parent 68b5abd122
commit 19bb4955a2
13 changed files with 330 additions and 118 deletions

View File

@@ -23,4 +23,26 @@ protocol VideosAPI {
func playlistVideos(_ id: String) -> Resource?
func channelPlaylist(_ id: String) -> Resource?
func loadDetails(_ item: PlayerQueueItem, completionHandler: @escaping (PlayerQueueItem) -> Void)
}
extension VideosAPI {
func loadDetails(_ item: PlayerQueueItem, completionHandler: @escaping (PlayerQueueItem) -> Void = { _ in }) {
guard (item.video?.streams ?? []).isEmpty else {
completionHandler(item)
return
}
video(item.videoID).load().onSuccess { response in
guard let video: Video = response.typedContent() else {
return
}
var newItem = item
newItem.video = video
completionHandler(newItem)
}
}
}