Add Play/Shuffle All for playlists (fixes #39)

Add Remove All from queue button on tvOS
This commit is contained in:
Arkadiusz Fal
2022-01-02 19:59:57 +01:00
parent ba21583a95
commit 04df9551ba
5 changed files with 125 additions and 36 deletions

View File

@@ -8,16 +8,30 @@ extension PlayerModel {
currentItem?.video
}
func playAll(_ videos: [Video]) {
let first = videos.first
func play(_ videos: [Video], shuffling: Bool = false, inNavigationView: Bool = false) {
let videosToPlay = shuffling ? videos.shuffled() : videos
videos.forEach { video in
enqueueVideo(video) { _, item in
guard let first = videosToPlay.first else {
return
}
enqueueVideo(first, prepending: true) { _, item in
self.advanceToItem(item)
}
videosToPlay.dropFirst().reversed().forEach { video in
enqueueVideo(video, prepending: true) { _, item in
if item.video == first {
self.advanceToItem(item)
}
}
}
if inNavigationView {
playerNavigationLinkActive = true
} else {
show()
}
}
func playNext(_ video: Video) {