Better UI handling for loading video details (fixes #46)

This commit is contained in:
Arkadiusz Fal
2021-12-29 19:55:41 +01:00
parent 0af2db2fd7
commit 89957e3b56
4 changed files with 82 additions and 19 deletions

View File

@@ -62,7 +62,13 @@ extension PlayerModel {
preservedTime = currentItem.playbackTime
restoreLoadedChannel()
loadAvailableStreams(currentVideo!)
DispatchQueue.main.async { [weak self] in
guard let video = self?.currentVideo else {
return
}
self?.loadAvailableStreams(video)
}
}
func preferredStream(_ streams: [Stream]) -> Stream? {
@@ -95,6 +101,9 @@ extension PlayerModel {
remove(newItem)
currentItem = newItem
player.pause()
accounts.api.loadDetails(newItem) { newItem in
self.playItem(newItem, video: newItem.video, at: time)
}
@@ -135,6 +144,12 @@ extension PlayerModel {
) -> PlayerQueueItem? {
let item = PlayerQueueItem(video, playbackTime: atTime)
if play {
currentItem = item
// pause playing current video as it's going to be replaced with next one
player.pause()
}
queue.insert(item, at: prepending ? 0 : queue.endIndex)
accounts.api.loadDetails(item) { newItem in