Search code examples
iosobjective-caudio-recordingavaudiorecorder

iOS when finished recording, turn off red status bar for AV Audio Recorder


My app both records with and asks permission to use, background recording. I enjoy the red status bar while recording despite the fact that no one else seems to. My problem is turning it off...

This is the code I use when I am finished with the recording process:

- (void)stopRecording {
    [self.recorder pause];
    [self.recorder stop];
    self.recorder = nil;

    [self.audioSession setActive:NO error:nil];
    self.audioSession = nil;
}

I want this red bar to be gone once the recording is done (or at least shortly thereafter) to let the user know it has finished. Obviously it refuses and a quick Google search will show that a number of other people have had similar problems. Can anyone tell me what the solution is because I have at least 2 apps I have found that respond properly to stopping a recording and shutting it off at an appropriate time.


Solution

  • Turns out I was missing just a few lines of code... here they are:

    - (void)stopRecording {
        [self.recorder pause];
        [self.recorder stop];
        self.recorder = nil;
    
        [self.audioSession setActive:NO error:nil];
        [self.audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
        self.audioSession = nil;
    }