rwieruch / favesound-redux

🎶 A SoundCloud Client in React + Redux running in production. Live Demo and Source Code to explore React + Redux as a beginner.
http://www.robinwieruch.de/the-soundcloud-client-in-react-redux/
1.59k stars 249 forks source link

Feature Proposal: Shuffle Playlist #7

Closed rwieruch closed 8 years ago

rwieruch commented 8 years ago

There could be a button in the player which allows you to toggle the shuffle mode. You could easily save this in the global redux state. Once it is set to shuffled, you only need to make sure that the next played track is a random track from the playlist.

Player component src/components/Player where you would have to place the Shuffle Button. It has to fire a new action via src/actions/player to set the shuffleMode in the src/reducers/player

const initialState = {
  shuffleMode: false,
  activeTrackId: null,
  isPlaying: false,
  playlist: []
};

Once the mode is implemented, the second step would be to adapt the action which gets fired in

<ButtonInline onClick={() => onActivateIteratedTrack(activeTrackId, 1)}>
  <i className="fa fa-step-forward" />
</ButtonInline>

in src/components/player to respect the shuffleMode. Rather than playing the next track, it should play some random track from the playlist. The logic would get implemented in src/actions/player.