Fixed up fading logic.
parent
fd4fa4c62d
commit
1fcf3bb2ff
|
@ -30,6 +30,7 @@
|
||||||
int playbackStatus;
|
int playbackStatus;
|
||||||
double position;
|
double position;
|
||||||
BOOL seekable;
|
BOOL seekable;
|
||||||
|
BOOL fading;
|
||||||
|
|
||||||
AudioScrobbler *scrobbler;
|
AudioScrobbler *scrobbler;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
{
|
{
|
||||||
[self initDefaults];
|
[self initDefaults];
|
||||||
|
|
||||||
|
seekable = NO;
|
||||||
|
fading = NO;
|
||||||
|
|
||||||
audioPlayer = [[AudioPlayer alloc] init];
|
audioPlayer = [[AudioPlayer alloc] init];
|
||||||
[audioPlayer setDelegate:self];
|
[audioPlayer setDelegate:self];
|
||||||
[self setPlaybackStatus: kCogStatusStopped];
|
[self setPlaybackStatus: kCogStatusStopped];
|
||||||
|
@ -276,7 +279,8 @@
|
||||||
[audioPlayer setVolume:originalVolume];
|
[audioPlayer setVolume:originalVolume];
|
||||||
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
|
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
|
||||||
[audioTimer invalidate];
|
[audioTimer invalidate];
|
||||||
[self setPlaybackStatus: kCogStatusPaused];
|
|
||||||
|
fading = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -300,7 +304,8 @@
|
||||||
{
|
{
|
||||||
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
|
[volumeSlider setDoubleValue: logarithmicToLinear(originalVolume)];
|
||||||
[audioTimer invalidate];
|
[audioTimer invalidate];
|
||||||
[self setPlaybackStatus: kCogStatusPlaying];
|
|
||||||
|
fading = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -310,8 +315,9 @@
|
||||||
double time = 0.1;
|
double time = 0.1;
|
||||||
|
|
||||||
// we can not allow multiple fade timers to be registered
|
// we can not allow multiple fade timers to be registered
|
||||||
if (playbackStatus == kCogStatusFading)
|
if (YES == fading)
|
||||||
return;
|
return;
|
||||||
|
fading = YES;
|
||||||
|
|
||||||
NSNumber *originalVolume = [NSNumber numberWithDouble: [audioPlayer volume]];
|
NSNumber *originalVolume = [NSNumber numberWithDouble: [audioPlayer volume]];
|
||||||
NSTimer *fadeTimer;
|
NSTimer *fadeTimer;
|
||||||
|
@ -335,9 +341,6 @@
|
||||||
[[NSRunLoop currentRunLoop] addTimer:fadeTimer forMode:NSRunLoopCommonModes];
|
[[NSRunLoop currentRunLoop] addTimer:fadeTimer forMode:NSRunLoopCommonModes];
|
||||||
[self pauseResume:self];
|
[self pauseResume:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setPlaybackStatus: kCogStatusFading];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)skipToNextAlbum:(id)sender
|
- (IBAction)skipToNextAlbum:(id)sender
|
||||||
|
|
|
@ -12,8 +12,4 @@ enum
|
||||||
kCogStatusStopped = 0,
|
kCogStatusStopped = 0,
|
||||||
kCogStatusPaused,
|
kCogStatusPaused,
|
||||||
kCogStatusPlaying,
|
kCogStatusPlaying,
|
||||||
kCogStatusFading,
|
|
||||||
// kCogStatusEndOfFile,
|
|
||||||
// kCogStatusEndOfPlaylist,
|
|
||||||
// kCogStatusPlaybackEnded
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut
|
||||||
|
|
||||||
NSImage *image = nil;
|
NSImage *image = nil;
|
||||||
|
|
||||||
if (playbackStatus == kCogStatusPlaying || playbackStatus == kCogStatusFading) {
|
if (playbackStatus == kCogStatusPlaying) {
|
||||||
image = [NSImage imageNamed:@"pause"];
|
image = [NSImage imageNamed:@"pause"];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue