From 3e1d24d9a25a63aa2b1aa2a4ad5c142d699204a0 Mon Sep 17 00:00:00 2001 From: ferferga Date: Mon, 22 Jun 2020 18:02:45 +0200 Subject: [PATCH] Don't shuffle first item --- src/components/playback/playqueuemanager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/playback/playqueuemanager.js b/src/components/playback/playqueuemanager.js index e26a738a02..4eac7d7c76 100644 --- a/src/components/playback/playqueuemanager.js +++ b/src/components/playback/playqueuemanager.js @@ -60,16 +60,22 @@ define([], function () { PlayQueueManager.prototype.shufflePlaylist = function () { this._sortedPlaylist = []; + let currentPlaylistItem = this._playlist[this.getCurrentPlaylistIndex()]; for (let item of this._playlist) { this._sortedPlaylist.push(item); } for (let i = this._playlist.length - 1; i > 0; i--) { + if (this._playlist[i] === currentPlaylistItem) { + this._playlist.splice(i, 1); + continue; + } const j = Math.floor(Math.random() * i); const temp = this._playlist[i]; this._playlist[i] = this._playlist[j]; this._playlist[j] = temp; } + this._playlist.unshift(currentPlaylistItem); this._shuffleMode = 'Shuffle'; };