mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
SoundPlayer: Implement playlist shuffle mode
The shuffling algorithm uses a naïve bloom filter to provide random uniformity, avoiding items that were recently played. With 32 bits, double hashing, and an error rate of ~10%, this bloom filter should be able to hold around ~16 keys, which should be sufficient to give the illusion of fairness to the shuffling algorithm. This avoids having to shuffle the playlist itself (user might have spent quite a bit of time to sort them, so it's not a good idea to mess with it), or having to create a proxy model that shuffles (that could potentially use quite a bit of memory).
This commit is contained in:
parent
0812965f50
commit
314b8a374b
7 changed files with 106 additions and 11 deletions
|
@ -98,6 +98,14 @@ int main(int argc, char** argv)
|
|||
playlist_toggle->set_checked(true);
|
||||
playback_menu.add_action(playlist_toggle);
|
||||
|
||||
auto shuffle_mode = GUI::Action::create_checkable("S&huffle Playlist", [&](auto& action) {
|
||||
if (action.is_checked())
|
||||
player->set_shuffle_mode(Player::ShuffleMode::Shuffling);
|
||||
else
|
||||
player->set_shuffle_mode(Player::ShuffleMode::None);
|
||||
});
|
||||
playback_menu.add_action(shuffle_mode);
|
||||
|
||||
auto& visualization_menu = window->add_menu("&Visualization");
|
||||
GUI::ActionGroup visualization_actions;
|
||||
visualization_actions.set_exclusive(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue