diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-28 08:14:32 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-28 08:14:32 +0000 |
commit | 3565bac66002ee5fba3745240428695c979c55dc (patch) | |
tree | a7c439f7133c691008b6778882bd05ac4c42326a | |
parent | 6ccd3e16579828a21b679df24dbc653d5f61081f (diff) | |
parent | f7a5c8b4128465c7040c656e03e233a856e0237a (diff) | |
download | LocalMediaPlayer-3565bac66002ee5fba3745240428695c979c55dc.tar.gz |
release-request-2c5efa61-1f02-4e74-bfeb-1ca3cd5028bd-for-git_pi-release-4301718 snap-temp-L56500000097146696
Change-Id: Idbeaf11a3ca048164ccd05bda67dfaee174765cb
-rw-r--r-- | src/com/android/car/media/localmediaplayer/Player.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/car/media/localmediaplayer/Player.java b/src/com/android/car/media/localmediaplayer/Player.java index 01f6772..7b3d151 100644 --- a/src/com/android/car/media/localmediaplayer/Player.java +++ b/src/com/android/car/media/localmediaplayer/Player.java @@ -509,10 +509,19 @@ public class Player extends MediaSession.Callback { Log.d(TAG, "Shuffling"); } - if (mQueue != null) { - QueueItem current = mQueue.remove(mCurrentQueueIdx); - Collections.shuffle(mQueue); - mQueue.add(0, current); + // rebuild the the queue in a shuffled form. + List<QueueItem> queue = mDataModel.getQueue(); + if (queue != null) { + QueueItem current = queue.remove(mCurrentQueueIdx); + Collections.shuffle(queue); + queue.add(0, current); + // A QueueItem contains a queue id that's used as the key for when the user selects + // the current play list. This means the QueueItems must be rebuilt to have their new + // id's set. + for (int i = 0; i < queue.size(); i++) { + queue.set(i, new QueueItem(queue.get(i).getDescription(), i)); + } + mQueue = new ArrayList<>(queue); mCurrentQueueIdx = 0; updateSessionQueueState(); updatePlaybackStatePlaying(); |