Implemented Repeat All through NSPredicate and filtering, method should be applicable when Shuffle is fixed too.

CQTexperiment
areff 2008-02-21 19:14:20 +00:00
parent 390c98b18c
commit 184525a47a
2 changed files with 23 additions and 0 deletions

View File

@ -50,6 +50,7 @@ typedef enum {
- (BOOL)shuffle;
- (void)setRepeat:(RepeatMode)r;
- (RepeatMode)repeat;
- (NSArray *)filterPlaylistOnAlbum:(NSString *)album;
- (PlaylistEntry *)getNextEntry:(PlaylistEntry *)pe;
- (PlaylistEntry *)getPrevEntry:(PlaylistEntry *)pe;

View File

@ -399,10 +399,32 @@
i = [[pe index] intValue] + 1;
}
if (repeat == RepeatAlbum)
{
PlaylistEntry *next = [self entryAtIndex:i];
if ((i > [[self arrangedObjects] count]-1) || ([[next album] caseInsensitiveCompare:[pe album]]) || ([next album] == nil))
{
NSArray *filtered = [self filterPlaylistOnAlbum:[pe album]];
if ([pe album] == nil)
i--;
else
i = [[[filtered objectAtIndex:0] index] intValue];
}
}
return [self entryAtIndex:i];
}
}
- (NSArray *)filterPlaylistOnAlbum:(NSString *)album
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"album like %@",
album];
return [[self arrangedObjects] filteredArrayUsingPredicate:predicate];
}
- (PlaylistEntry *)getPrevEntry:(PlaylistEntry *)pe
{
if (repeat == RepeatOne) {