Fixed up fading logic.
parent
fd4fa4c62d
commit
1fcf3bb2ff
|
@ -30,6 +30,7 @@
|
|||
int playbackStatus;
|
||||
double position;
|
||||
BOOL seekable;
|
||||
BOOL fading;
|
||||
|
||||
AudioScrobbler *scrobbler;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,8 +12,4 @@ enum
|
|||
kCogStatusStopped = 0,
|
||||
kCogStatusPaused,
|
||||
kCogStatusPlaying,
|
||||
kCogStatusFading,
|
||||
// kCogStatusEndOfFile,
|
||||
// kCogStatusEndOfPlaylist,
|
||||
// kCogStatusPlaybackEnded
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut
|
|||
|
||||
NSImage *image = nil;
|
||||
|
||||
if (playbackStatus == kCogStatusPlaying || playbackStatus == kCogStatusFading) {
|
||||
if (playbackStatus == kCogStatusPlaying) {
|
||||
image = [NSImage imageNamed:@"pause"];
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue