Skip to content

Commit

Permalink
Completely redesigned all menus, fixed crashers due to new PlaylistEn…
Browse files Browse the repository at this point in the history
…try structure, validated menu items, added menu entry for fading, synthesized playbackStatus, updated KnownIssues
  • Loading branch information
areff committed Feb 23, 2008
1 parent 86f691b commit d2e95a5
Show file tree
Hide file tree
Showing 6 changed files with 2,938 additions and 2,699 deletions.
4 changes: 3 additions & 1 deletion Application/PlaybackController.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
AudioScrobbler *scrobbler;
}

@property int playbackStatus;

- (IBAction)toggleShowTimeRemaining:(id)sender;
- (IBAction)changeVolume:(id)sender;
- (IBAction)volumeDown:(id)sender;
Expand All @@ -61,7 +63,7 @@
- (void)seekForward:(double)sender;
- (IBAction)eventSeekBackward:(id)sender;
- (void)seekBackward:(double)amount;
- (IBAction)fade:(id)sender withTime:(double)time;
- (IBAction)fade:(id)sender;

- (void)initDefaults;
- (void)audioFadeDown:(NSTimer *)audioTimer;
Expand Down
30 changes: 17 additions & 13 deletions Application/PlaybackController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ @implementation PlaybackController

#define DEFAULT_SEEK 10

@synthesize playbackStatus;

- (id)init
{
Expand Down Expand Up @@ -290,6 +291,7 @@ - (void)audioFadeDown:(NSTimer *)audioTimer
[audioPlayer setVolume:originalVolume];
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
[audioTimer invalidate];
playbackStatus = kCogStatusPaused;
}

}
Expand All @@ -313,12 +315,15 @@ - (void)audioFadeUp:(NSTimer *)audioTimer
{
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
[audioTimer invalidate];
playbackStatus = kCogStatusPlaying;
}

}

- (IBAction)fade:(id)sender withTime:(double)time
- (IBAction)fade:(id)sender
{
double time = 0.1;

// we can not allow multiple fade timers to be registered
if (playbackStatus == kCogStatusFading)
return;
Expand Down Expand Up @@ -351,7 +356,7 @@ - (IBAction)skipToNextAlbum:(id)sender
{
BOOL found = NO;

NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
int index = [[playlistController currentEntry] index];
NSString *origAlbum = [[playlistController currentEntry] album];

int i;
Expand All @@ -361,10 +366,9 @@ - (IBAction)skipToNextAlbum:(id)sender

for (i = 1; i < [[playlistController arrangedObjects] count]; i++)
{
pe = [playlistController entryAtIndex:[index intValue] + i];
if (pe == nil) {
pe = [playlistController entryAtIndex:index + i];
if (pe == nil)
break;
}

curAlbum = [pe album];

Expand All @@ -385,7 +389,7 @@ - (IBAction)skipToNextAlbum:(id)sender

if (found)
{
[self playEntryAtIndex:i + [index intValue]];
[self playEntryAtIndex:i + index];
}
}

Expand All @@ -394,7 +398,7 @@ - (IBAction)skipToPreviousAlbum:(id)sender
BOOL found = NO;
BOOL foundAlbum = NO;

NSNumber *index = (NSNumber *)[[playlistController currentEntry] index];
int index = [[playlistController currentEntry] index];
NSString *origAlbum = [[playlistController currentEntry] album];
NSString *curAlbum;

Expand All @@ -404,10 +408,10 @@ - (IBAction)skipToPreviousAlbum:(id)sender

for (i = 1; i < [[playlistController arrangedObjects] count]; i++)
{
pe = [playlistController entryAtIndex:[index intValue] - i];
if (pe == nil) {
pe = [playlistController entryAtIndex:index - i];
if (pe == nil)
break;
}

curAlbum = [pe album];
if (curAlbum == nil)
{
Expand Down Expand Up @@ -437,7 +441,7 @@ - (IBAction)skipToPreviousAlbum:(id)sender
{
if (foundAlbum == YES)
i--;
[self playEntryAtIndex:[index intValue] - i];
[self playEntryAtIndex:index - i];
}
}

Expand Down Expand Up @@ -571,10 +575,10 @@ -(BOOL)validateMenuItem:(NSMenuItem*)menuItem
{
SEL action = [menuItem action];

if (action == @selector(seekBackward:) && (playbackStatus == kCogStatusStopped))
if (action == @selector(eventSeekBackward:) && (playbackStatus == kCogStatusStopped))
return NO;

if (action == @selector(seekForward:) && (playbackStatus == kCogStatusStopped))
if (action == @selector(eventSeekForward:) && (playbackStatus == kCogStatusStopped))
return NO;

if (action == @selector(stop:) && (playbackStatus == kCogStatusStopped))
Expand Down
Loading

0 comments on commit d2e95a5

Please sign in to comment.