Skip to content

Conversation

miki-tebe
Copy link

@miki-tebe miki-tebe commented May 22, 2025

Problem

Wanted to shuffle tracks that are in queue

Solution

Using the loadash shuffle function added a simple shuffle utility and dispatch it when the newly added shuffle button is clicked.

Action

As a first time contributor, i will need some help with reviews and comments. Especially with tests.

@miki-tebe miki-tebe marked this pull request as draft May 22, 2025 14:35
@miki-tebe miki-tebe marked this pull request as ready for review May 22, 2025 14:40
Copy link
Member

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening a PR for this !
Looks like a good feature we are missing!

As I wrote below, I think the shuffle mechanism should be changed in favor of a "shuffle mode" users can turn on or off.

Don't hesitate if you have any questions

Comment on lines 458 to 464
{!isMobile && (
<FontAwesomeIcon
icon={faShuffle}
title="Shuffle queue"
onClick={() => dispatch({ type: "SHUFFLE_QUEUE" })}
/>
)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This !isMobile part tells you this is only displayed on large screen sizes.

You'll also need to add a button to the mobile UI, that is the MusicPlayer component, between the toggleQueue and toggleRepeatMode buttons, using the PlaybackControlButton component, with a color based on the boolean state currently missing (shuffle on or off):

<div className="player-buttons secondary">
<FeedbackButtons
currentListenFeedback={currentListenFeedback}
isPlayingATrack={isPlayingATrack}
submitLikeFeedback={submitLikeFeedback}
submitDislikeFeedback={submitDislikeFeedback}
/>
<PlaybackControlButton
className="toggle-queue-button"
action={toggleQueue}
title="Queue"
icon={faBarsStaggered}
size="xl"
/>
<PlaybackControlButton
className={queueRepeatMode.title}
action={toggleRepeatMode}
title={queueRepeatMode.title}
icon={queueRepeatMode.icon}
color={queueRepeatMode.color}
size="xl"
/>
<PlaybackControlButton
action={toggleShowVolume}
title="Volume"
icon={faVolumeUp}
size="xl"
/>
</div>

}
case "SHUFFLE_QUEUE": {
const { queue, currentListenIndex } = state;
const newQueue = shuffleQueue(queue, currentListenIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I appreciate your solution, I think this is not what users will expect from a music player. Normally, in all cases I remember using a shuffle option, instead of instantly shuffling the queue, activating "shuffle mode" will instead change the selection process for the next track, making it random, without visually affecting the queue.

So I think this action should be called SHUFFLE_MODE and should store a boolean state for the same shuffleMode.

Then the random picking would need to happen in the playNextTrack method in BrainzPlayer component:

const playNextTrack = (invert: boolean = false): void => {

This method should access the value of shuffle mode in the brainzPlayerContext (brainzPlayerContextRef.current.shuffleMode in this case) and decide what to do depending on that boolean state.

@miki-tebe
Copy link
Author

Thanks for the detailed review, your concept of shuffle totally makes sense. I will work on it and make the necessary changes.

@MonkeyDo
Copy link
Member

Hello @miki-tebe !
Please let me know if you are still interested in working on this, otherwise I'll be happy to make the remaining changes to get it merged. Thanks !

@miki-tebe
Copy link
Author

@MonkeyDo Sorry for the late reply, you should definitely take over. I can push the changes I had made but never finished if that helps in any way.

@miki-tebe miki-tebe marked this pull request as draft July 23, 2025 09:23
@MonkeyDo
Copy link
Member

Thanks for pushing your changes @miki-tebe !

We are currently rewriting our state logic for BrainzPlayer so I will wait until that is finished to reimplement and finish off your shuffling logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants