1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-27 07:20:32 +05:30

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 currentItem?.video
} }
func play(_ videos: [Video]) { func play(_ videos: [Video], shuffling: Bool = false) {
playbackMode = shuffling ? .shuffle : .queue
videos.forEach { enqueueVideo($0, loadDetails: false) } videos.forEach { enqueueVideo($0, loadDetails: false) }
#if os(iOS) #if os(iOS)

View File

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

View File

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

View File

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

View File

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