diff --git a/Model/Player/PlayerQueue.swift b/Model/Player/PlayerQueue.swift index 4f064173..4dd29825 100644 --- a/Model/Player/PlayerQueue.swift +++ b/Model/Player/PlayerQueue.swift @@ -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) diff --git a/Shared/Navigation/AppSidebarPlaylists.swift b/Shared/Navigation/AppSidebarPlaylists.swift index 20f5c16b..cb79f555 100644 --- a/Shared/Navigation/AppSidebarPlaylists.swift +++ b/Shared/Navigation/AppSidebarPlaylists.swift @@ -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)) } diff --git a/Shared/Playlists/PlaylistsView.swift b/Shared/Playlists/PlaylistsView.swift index 0fe825eb..6177cf6b 100644 --- a/Shared/Playlists/PlaylistsView.swift +++ b/Shared/Playlists/PlaylistsView.swift @@ -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? { diff --git a/Shared/Views/ChannelPlaylistView.swift b/Shared/Views/ChannelPlaylistView.swift index dc7c30e9..187f64c7 100644 --- a/Shared/Views/ChannelPlaylistView.swift +++ b/Shared/Views/ChannelPlaylistView.swift @@ -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] { diff --git a/Shared/Views/PlaylistVideosView.swift b/Shared/Views/PlaylistVideosView.swift index b7d139f3..202f2bb0 100644 --- a/Shared/Views/PlaylistVideosView.swift +++ b/Shared/Views/PlaylistVideosView.swift @@ -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") + } + } } } }