Add back Shuffle All and fix Play All

This commit is contained in:
Arkadiusz Fal 2022-09-04 17:23:02 +02:00
parent 1744210615
commit 14b0316724
5 changed files with 29 additions and 4 deletions

View File

@ -8,7 +8,9 @@ extension PlayerModel {
currentItem?.video
}
func play(_ videos: [Video]) {
func play(_ videos: [Video], shuffling: Bool = false) {
playbackMode = shuffling ? .shuffle : .queue
videos.forEach { enqueueVideo($0, loadDetails: false) }
#if os(iOS)

View File

@ -18,6 +18,9 @@ struct AppSidebarPlaylists: View {
Button("Play All") {
player.play(playlists.find(id: playlist.id)?.videos ?? [])
}
Button("Shuffle All") {
player.play(playlists.find(id: playlist.id)?.videos ?? [], shuffling: true)
}
Button("Edit") {
navigation.presentEditPlaylistForm(playlists.find(id: playlist.id))
}

View File

@ -299,13 +299,21 @@ struct PlaylistsView: View {
private var playButton: some View {
Button {
player.playbackMode = .queue
player.play(items.compactMap(\.video))
} label: {
Image(systemName: "play")
.padding(8)
.contentShape(Rectangle())
}
.contextMenu {
Button {
player.play(items.compactMap(\.video), shuffling: true)
} label: {
Label("Shuffle", systemImage: "shuffle")
.padding(8)
.contentShape(Rectangle())
}
}
}
private var currentPlaylist: Playlist? {

View File

@ -121,11 +121,17 @@ struct ChannelPlaylistView: View {
private var playButton: some View {
Button {
player.playbackMode = .queue
player.play(videos)
} label: {
Label("Play All", systemImage: "play")
}
.contextMenu {
Button {
player.play(videos, shuffling: true)
} label: {
Label("Shuffle All", systemImage: "shuffle")
}
}
}
private var videos: [Video] {

View File

@ -70,11 +70,17 @@ struct PlaylistVideosView: View {
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
Button {
player.playbackMode = .queue
player.play(videos)
} label: {
Label("Play All", systemImage: "play")
}
.contextMenu {
Button {
player.play(videos, shuffling: true)
} label: {
Label("Shuffle All", systemImage: "shuffle")
}
}
}
}
}