I'm trying to get the volume of an AVAudioPlayer
to oscillate over time.
Ex: Every 10 seconds, adjust volume to 0.5, then to 1.0, etc.
I have tried using an NSTimer
but it only works the first time and doesn't loop.
oscillateTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(oscillateRun) userInfo:nil repeats:YES];
oscillateRun function
- (void)oscillateRun {
BOOL oscillation;
oscillation = NO;
if(oscillation = YES) {
oscillation = NO;
audioPlayer.volume = 0.50;
}
else {
oscillation = YES;
audioPlayer.volume = 1;
}
}
Unsure what to do, thanks in advance!