I have implemented a flashing effect on microphone button while it is recording. Now it does not allow me to click to stop. I could not able to figure out the root of the problem
-
(IBAction)microButton:(id)sender {
if(counter%2==0)
{
if (!recorder.recording) {
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setActive:YES error:nil];
[micImage setBackgroundImage:[UIImage imageNamed:@"ico_mic_on.png"] forState:UIControlStateNormal];
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction
animations:^{
self.micImage.alpha = 0.0f;
}
completion:^(BOOL finished){
}];
// Start recording
[recorder record];
}
counter=counter+1;
}
else{
[recorder stop];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:NO error:nil];
counter=counter+1;
[micImage setBackgroundImage:[UIImage imageNamed:@"ico_mic.png"] forState:UIControlStateNormal];
self.micImage.alpha = 1.0f;
[UIView animateWithDuration:0.1
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.micImage.alpha = 1.0f;
}
completion:^(BOOL finished){
}];
}
}