-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve shuffle #157
Comments
It probably isn't even necessary to set the index to a random number after reshuffling, just setting it to 0 should be fine. Possible issue: it could end up playing the same song twice in a row. While this might actually be "truly" random, I assume most users don't want this. |
@charliefoxtwo good point. |
I think the best way to do this would be to create an array of all of the songs in the playlist, and shuffle said array. When we get to the end, just start from the beginning again. I think this is what other players do, and personally I've never had an issue with it. |
@charliefoxtwo I have already fixed and committed it, just wanted your input. Will make changes accordingly. Most of the bugs should now be fixed. I am working on Playlists and fixing bugs there. |
Closing this as the task is done. |
@charliefoxtwo on #17 :
On a 12 song library, the repeat skipping is to be expected because the library is so small. Basically, what BreadPlayer does when you enable Shuffle is create a random
Array
ofMediafile
s and then when a user presses the next button, it takes the *Index
of the currently playing song from theOriginalCollection
and adds1
to it. The next song is the song that sits at the resulting integer in theshuffled collection
.A little easier explanation:
Suppose the currently playing index is 15. Add 1 into 15, the result is 16. The next song will be the song that sits at number 16 in the shuffled collection.
Not a bad implementation, but there are a few bad things.
IndexOutOfRange
expection will be thrown if we get a index that is outside the maximum count. (This will happen if we are playing the last song in the collection).What can we do to make both of these better:
All input to make this better will be very much appreciated.
The text was updated successfully, but these errors were encountered: