iolsen / harmonium

Automatically exported from code.google.com/p/harmonium
GNU Affero General Public License v3.0
0 stars 0 forks source link

Shuffle malfunction in "Now Playing" #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For some reason after adding many different artists to the now playing 
list I was unable to get it to "shuffle". It played every sony from every 
artist I added in the order I added them. Turning shuffle off then on 
again didnt work either. 

What steps will reproduce the problem?
(as a side note, I had shuffle enabled when harmonium was launched. So 
when I start this list I assume you have shuffle set to on by default)
1. Upon first launch of harmonium click Browse Music->Artist
2. Select an Artist and hit the Play button
3. When the music starts playing hit the left arrow and select a different 
artist, select an album and hit the Enter key, select add to "Now Playing" 
playlist. This may be important **I hit the Enter key when an Album was 
highlighted(Add the entire album)**
4. Do step 3 a few times
5. When your done selecting artists/albums stay at the now playing screen
(with the album art etc...)
6. When hitting >>| the shuffle label changes from off to on as it should 
but the "next song" doesnt change. Pressing the channel up button simply 
goes to the next song in the album. 
7. Turning shuffle on-off-on and skipping many songs has the same effect

To get my playlist to shuffle I went to Browse Playlists, selected 
the "Now Playing" playlist and selected to save it as a playlist. Once I 
had named it I was able to select the new playlist and select Play. Then I 
was able to shuffle just fine.

OS: Windows Vista

Tivo: Tivo HD 

After typing step 3 above I realized that maybe the issue is related to 
the fact that I added the "Album" rather than a specific song. Perhaps the 
system grouped the files into albums and was going to shuffle the Albums
(Play each album in its entirety in order but randomly choose the next 
album) 

If that is the case, and it was intentional, then after I saved the 
playlist and reopened it it should have behaved the same way.

Aaron

Original issue reported on code.google.com by aaron.ri...@gmail.com on 16 Mar 2010 at 10:21

GoogleCodeExporter commented 9 years ago
Thanks for the report.  I'm think I understand what happened.

During playback, Harmonium actually keeps track of two playlists: the regular 
one and
the shuffled one.  When you toggle shuffle on/off, it simply switches the 
"real" now
playing playlist between these two.

When you add songs to play during playback, the song you're adding gets added 
either
next or at the end of both the normal and shuffled playlist.  This was 
deliberate. 
When you say "play this song next," you expect the song to play next whether 
you're
shuffling or not.  But when you say "add this song" (not next) when shuffle is 
on, I
should probably add it in a random spot.

Two possible fixes:

1. Re-shuffle the shuffled playlist when shuffle gets toggled back on.  

2. Have "add to now playing" add the selection in a random place in the shuffled
playlist.  If adding multiple songs, I'll have to chose a random spot for each 
one.  

Maybe both.

Original comment by ian.ol...@gmail.com on 17 Mar 2010 at 3:44

GoogleCodeExporter commented 9 years ago

Original comment by ian.ol...@gmail.com on 17 Mar 2010 at 3:45

GoogleCodeExporter commented 9 years ago
I replied to the response I got automatically from the group expecting it would 
show 
up here but I dont see it. So here it is:

Actually I think just doing #1 would work. When someone adds a song or a group 
of 
songs to a playlist and shuffle is on then it should add the songs first then 
Re-
shuffle the playlist. This should be an easy fix, you must already have a 
shuffle 
function written for when someone starts a new playlist. As long as you can 
maintain 
a pointer to the currently playing song then you can shuffle the entire 
playlist.

If I am understanding this correctly then if someone selects "shuffle: on" it 
actually plays a pre-compiled shuffled version of the playlist. If this is the 
case 
then I might also suggest the following change:

There must currently be a point in the program where it checks to see if 
the "Repeat" option is turned on(when the end of a playlist is reached). Before 
restarting the playlist the shuffled version of the playlist should be 
re-shuffled. 
This would prevent a shuffled playlist from repeating the same exact ordering 
the 
second time around. 

***Here are the code changes I propose***

Change the following code in the toggleShuffleMode function from:

this.musicIndex = this.shuffledMusicQueue.indexOf(this.nowPlaying);

to:

{
Collections.shuffle(this.shuffledMusicQueue);
this.musicIndex = this.shuffledMusicQueue.indexOf(this.nowPlaying);
}

Change the following code in the enqueueAtEnd function from:

this.shuffledMusicQueue.addAll(list);
this.musicQueue.addAll(list);

to:

this.shuffledMusicQueue.addAll(list);
Collections.shuffle(this.shuffledMusicQueue);
this.musicQueue.addAll(list);

Change the following code in the playNext() function from:

if(this.repeatMode) {
this.musicIndex=0;
}

to:

if(this.repeatMode) {
Collections.shuffle(this.shuffledMusicQueue);
this.musicIndex=0;
}

If I find any more bugs I will try to help supply the code changes. The source 
for 
this program is a fairly easy read.

Thanks again for this awesome program!

Original comment by aaron.ri...@gmail.com on 17 Mar 2010 at 6:07

GoogleCodeExporter commented 9 years ago
Just noticed, for the enqueueAtEnd function you also need to add:

if(this.shuffleMode)
    this.musicIndex = this.shuffledMusicQueue.indexOf(this.nowPlaying); 

because the currently playing song will also be shuffled to an unknown location

Original comment by aaron.ri...@gmail.com on 17 Mar 2010 at 6:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 7a6dcc6b6b.

Original comment by aaron.ri...@gmail.com on 18 Mar 2010 at 3:28