Fixed up fading logic.

CQTexperiment
vspader 2009-02-28 13:19:26 -08:00
parent fd4fa4c62d
commit 1fcf3bb2ff
4 changed files with 11 additions and 11 deletions

View File

@ -30,6 +30,7 @@
int playbackStatus;
double position;
BOOL seekable;
BOOL fading;
AudioScrobbler *scrobbler;

View File

@ -25,6 +25,9 @@
{
[self initDefaults];
seekable = NO;
fading = NO;
audioPlayer = [[AudioPlayer alloc] init];
[audioPlayer setDelegate:self];
[self setPlaybackStatus: kCogStatusStopped];
@ -276,7 +279,8 @@
[audioPlayer setVolume:originalVolume];
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
[audioTimer invalidate];
[self setPlaybackStatus: kCogStatusPaused];
fading = NO;
}
}
@ -300,7 +304,8 @@
{
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
[audioTimer invalidate];
[self setPlaybackStatus: kCogStatusPlaying];
fading = NO;
}
}
@ -310,8 +315,9 @@
double time = 0.1;
// we can not allow multiple fade timers to be registered
if (playbackStatus == kCogStatusFading)
if (YES == fading)
return;
fading = YES;
NSNumber *originalVolume = [NSNumber numberWithDouble: [audioPlayer volume]];
NSTimer *fadeTimer;
@ -335,9 +341,6 @@
[[NSRunLoop currentRunLoop] addTimer:fadeTimer forMode:NSRunLoopCommonModes];
[self pauseResume:self];
}
[self setPlaybackStatus: kCogStatusFading];
}
- (IBAction)skipToNextAlbum:(id)sender

View File

@ -12,8 +12,4 @@ enum
kCogStatusStopped = 0,
kCogStatusPaused,
kCogStatusPlaying,
kCogStatusFading,
// kCogStatusEndOfFile,
// kCogStatusEndOfPlaylist,
// kCogStatusPlaybackEnded
};

View File

@ -45,7 +45,7 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut
NSImage *image = nil;
if (playbackStatus == kCogStatusPlaying || playbackStatus == kCogStatusFading) {
if (playbackStatus == kCogStatusPlaying) {
image = [NSImage imageNamed:@"pause"];
}
else {