Start playlist Play at a random video in shuffle mode (#988)

Play always started from the first video, so shuffle only affected the
rest of the session. When the queue mode is Shuffle, rotate the list to
a random start so the remaining videos stay queued.
This commit is contained in:
Arkadiusz Fal
2026-10-19 23:26:41 +02:00
parent 4d8ba7e028
commit c4272c86f7

View File

@@ -1221,8 +1221,17 @@ struct UnifiedPlaylistDetailView: View {
private func playAll() {
guard !videos.isEmpty, let appEnvironment else { return }
// In shuffle mode start from a random video (#988). Rotate rather than
// pick an index so every other video stays in the queue instead of
// being pushed to history as "already played".
var orderedVideos = videos
if appEnvironment.playerService.state.queueMode == .shuffle {
let start = Int.random(in: 0..<videos.count)
orderedVideos = Array(videos[start...] + videos[..<start])
}
appEnvironment.queueManager.playFromList(
videos: videos,
videos: orderedVideos,
index: 0,
queueSource: queueSource,
sourceLabel: title