简体   繁体   中英

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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM