Rejigger shuffle list generator for albums mode, to insert the current album at the start of the list, starting from the current track
parent
55564f2991
commit
2ad9584fb2
|
@ -809,6 +809,39 @@
|
|||
|
||||
if (currentEntry && currentEntry.index >= 0)
|
||||
{
|
||||
if ([self shuffle] == ShuffleAlbums) {
|
||||
NSString * currentAlbum = currentEntry.album;
|
||||
if (!currentAlbum)
|
||||
currentAlbum = @"";
|
||||
|
||||
NSArray * wholeAlbum = [self filterPlaylistOnAlbum:currentAlbum];
|
||||
|
||||
// First prune the shuffle list of the currently playing album
|
||||
int i, j;
|
||||
for (i = 0; i < [shuffleList count];) {
|
||||
if ([wholeAlbum containsObject:[shuffleList objectAtIndex:i]]) {
|
||||
[shuffleList removeObjectAtIndex:i];
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// Then insert the playing album at the start, beginning with
|
||||
// the current track
|
||||
BOOL found = NO;
|
||||
for (i = 0, j = 0; i < [wholeAlbum count]; i++) {
|
||||
if (!found && [wholeAlbum objectAtIndex:i] == currentEntry) {
|
||||
found = YES;
|
||||
}
|
||||
if (found) {
|
||||
[shuffleList insertObject:[wholeAlbum objectAtIndex:i] atIndex:j];
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
[shuffleList insertObject:currentEntry atIndex:0];
|
||||
[currentEntry setShuffleIndex:0];
|
||||
|
||||
|
@ -827,6 +860,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setCurrentEntry:(PlaylistEntry *)pe
|
||||
|
|
Loading…
Reference in New Issue