From 739fafe633ccb2a9979a9d90c8f38bde1b777f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Thomas?= Date: Sun, 20 Nov 2016 12:09:06 +0100 Subject: [PATCH] Fix shuffle behavior introduced in #132 The player's current file was not being updated, resulting in always considering that it was playing the first one when shuffling. --- .../libresonic/player/controller/StreamController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/StreamController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/StreamController.java index fe73fd1a..63486602 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/StreamController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/StreamController.java @@ -133,6 +133,15 @@ public class StreamController implements Controller { return null; } + // Update the index of the currently playing media file. At + // this point we haven't yet modified the play queue to support + // multiple streams, so the current play queue is the real one. + int currentIndex = player.getPlayQueue().getFiles().indexOf(file); + player.getPlayQueue().setIndex(currentIndex); + + // Create a new, fake play queue that only contains the + // currently playing media file, in case multiple streams want + // to use the same player. PlayQueue playQueue = new PlayQueue(); playQueue.addFiles(true, file); player.setPlayQueue(playQueue);