Cleaned up/fixed previous/next album.
This commit is contained in:
parent
dea4553bfc
commit
4c8630e808
1 changed files with 42 additions and 43 deletions
|
@ -112,7 +112,7 @@
|
||||||
//called by double-clicking on table
|
//called by double-clicking on table
|
||||||
- (void)playEntryAtIndex:(int)i
|
- (void)playEntryAtIndex:(int)i
|
||||||
{
|
{
|
||||||
PlaylistEntry *pe = [[playlistController arrangedObjects] objectAtIndex:i];
|
PlaylistEntry *pe = [playlistController entryAtIndex:i];
|
||||||
|
|
||||||
[self playEntry:pe];
|
[self playEntry:pe];
|
||||||
}
|
}
|
||||||
|
@ -351,92 +351,91 @@
|
||||||
NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
|
NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
|
||||||
NSString *origAlbum = [[playlistController currentEntry] album];
|
NSString *origAlbum = [[playlistController currentEntry] album];
|
||||||
|
|
||||||
int playlistLength = [[playlistController arrangedObjects] count] - 1;
|
int i;
|
||||||
int i = [index intValue] + 1;
|
|
||||||
NSString *curAlbum;
|
NSString *curAlbum;
|
||||||
|
|
||||||
PlaylistEntry *pe;
|
PlaylistEntry *pe;
|
||||||
|
|
||||||
while (!found)
|
for (i = 1; i < [[playlistController arrangedObjects] count]; i++)
|
||||||
{
|
{
|
||||||
pe = [[playlistController arrangedObjects] objectAtIndex:i];
|
pe = [playlistController entryAtIndex:[index intValue] + i];
|
||||||
|
if (pe == nil) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
curAlbum = [pe album];
|
curAlbum = [pe album];
|
||||||
|
|
||||||
// check for untagged files, and just play the first untagged one
|
// check for untagged files, and just play the first untagged one
|
||||||
// we come across
|
// we come across
|
||||||
if (curAlbum == nil)
|
if (curAlbum == nil)
|
||||||
break;
|
|
||||||
|
|
||||||
if (![curAlbum caseInsensitiveCompare:origAlbum])
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if (i > playlistLength)
|
|
||||||
return;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
found = YES;
|
found = YES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([curAlbum caseInsensitiveCompare:origAlbum])
|
||||||
|
{
|
||||||
|
found = YES;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self playEntryAtIndex:i];
|
if (found)
|
||||||
|
{
|
||||||
|
[self playEntryAtIndex:i + [index intValue]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)skipToPreviousAlbum:(id)sender
|
- (IBAction)skipToPreviousAlbum:(id)sender
|
||||||
{
|
{
|
||||||
BOOL found = NO;
|
BOOL found = NO;
|
||||||
BOOL foundAlbum = NO;
|
BOOL foundAlbum = NO;
|
||||||
|
|
||||||
NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
|
NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
|
||||||
NSString *origAlbum = [[playlistController currentEntry] album];
|
NSString *origAlbum = [[playlistController currentEntry] album];
|
||||||
NSString *curAlbum;
|
NSString *curAlbum;
|
||||||
|
|
||||||
int i = [index intValue] - 1;
|
int i;
|
||||||
|
|
||||||
if (i <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlaylistEntry *pe;
|
PlaylistEntry *pe;
|
||||||
|
|
||||||
while (!found)
|
for (i = 1; i < [[playlistController arrangedObjects] count]; i++)
|
||||||
{
|
{
|
||||||
pe = [[playlistController arrangedObjects] objectAtIndex:i];
|
pe = [playlistController entryAtIndex:[index intValue] - i];
|
||||||
|
if (pe == nil) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
curAlbum = [pe album];
|
curAlbum = [pe album];
|
||||||
if (curAlbum == nil)
|
if (curAlbum == nil)
|
||||||
break;
|
|
||||||
|
|
||||||
if (![curAlbum caseInsensitiveCompare:origAlbum])
|
|
||||||
{
|
{
|
||||||
i--;
|
found = YES;
|
||||||
if (i == 0) // first entry in playlist
|
break;
|
||||||
if (foundAlbum == YES)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ([curAlbum caseInsensitiveCompare:origAlbum])
|
||||||
{
|
{
|
||||||
if (foundAlbum == NO)
|
if (foundAlbum == NO)
|
||||||
{
|
{
|
||||||
foundAlbum = YES;
|
foundAlbum = YES;
|
||||||
// now we need to move up to the first song in the album, so we'll
|
// now we need to move up to the first song in the album, so we'll
|
||||||
// go till we either find index 0, or the first song in the album
|
// go till we either find index 0, or the first song in the album
|
||||||
origAlbum = [[[playlistController arrangedObjects] objectAtIndex:i] album];
|
origAlbum = curAlbum;
|
||||||
i--;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
found = YES; // terminate loop
|
found = YES; // terminate loop
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((foundAlbum == YES) && i != 0)
|
if (found || foundAlbum)
|
||||||
i++;
|
{
|
||||||
[self playEntryAtIndex:i];
|
if (foundAlbum == YES)
|
||||||
|
i--;
|
||||||
|
[self playEntryAtIndex:[index intValue] - i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue