Skip to content

Refactor shuffle functionality to play a random song#1

Merged
ColbyCabrera merged 1 commit intomasterfrom
feature/shuffle-playback
Sep 8, 2025
Merged

Refactor shuffle functionality to play a random song#1
ColbyCabrera merged 1 commit intomasterfrom
feature/shuffle-playback

Conversation

@google-labs-jules
Copy link
Copy Markdown

This change refactors the shuffle functionality to align with user expectations.

Previously, the shuffle button only toggled the player's shuffle mode and would either pause playback or start playing from the beginning of the library list.

The new implementation introduces a shuffleAllSongs() method in the PlayerViewModel. This method ensures shuffle mode is active, selects a random song from the library, and then initiates playback with the randomly selected song at the start of a shuffled queue of all songs.

The UI has been updated to call this new method, providing a more intuitive and correct shuffle experience. Additionally, a unit test has been added to verify the new logic.

The previous shuffle implementation would only toggle the shuffle mode and then either pause the current song or start playing the first song in the library.

This change introduces a new `shuffleAllSongs` function in the `PlayerViewModel` that, when called:
1.  Enables shuffle mode on the media player.
2.  Selects a random song from the full list of songs.
3.  Starts playback with the random song and a shuffled queue of all songs.

The shuffle button in the library screen is updated to call this new function, providing the user with the expected shuffle behavior.

A unit test has been added to verify that the `shuffleAllSongs` function correctly calls the underlying `playSongs` method with a random starting song and the full song list.
@google-labs-jules
Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll acknowledge your comments with a 👀 emoji and then get to work. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

I will automatically address your feedback. For any comments you don't want me to act on, just include (aside).



For security, I will only act on instructions from the user who triggered this task for this pull request.

@ColbyCabrera ColbyCabrera marked this pull request as ready for review September 8, 2025 17:55
@ColbyCabrera ColbyCabrera merged commit 265179c into master Sep 8, 2025
@ColbyCabrera ColbyCabrera deleted the feature/shuffle-playback branch September 8, 2025 18:09
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