1

iOS red bar appear by chance when i stop running camera recording.

  • In my opinion,only red bar appear, when application go to background, but it appear when B controller dismiss to A controller.
  • I have opened audio background mode in plist. When I close this option, red bar will not appear. I know this is reminder to user when open audio background mode.
  • The red bar random appear will disorder A controller's view.
  • I try to AudioSessionSetActive(false) when stop running camera but no use, this action looks can't stop audio sample immediately so the red bar appear random.

My code as follow:

- (void)stopRunning{
    if (self.audioDeviceInput) {
        [self.captureSession removeInput:self.audioDeviceInput];
    }
    if (self.videoDeviceInput) {
        [self.captureSession removeInput:self.videoDeviceInput];
    }
    if (self.captureAudioDataOutput) {
        [self.captureSession removeOutput:self.captureAudioDataOutput];
    }
    if (self.captureVideoDataOutput) {
        [self.captureSession removeOutput:self.captureVideoDataOutput];
    }

    for (AVCaptureOutput *output1 in self.captureSession.outputs) {
        [self.captureSession removeOutput:output1];
    }
    self.videoDeviceInput = nil;
    self.captureAudioDataOutput = nil;
    self.audioConnection = nil;

    self.captureVideoDataOutput = nil;
    self.stillImageOutput = nil;
    self.videoConnection = nil;

    self.captureSession = nil;
    self.sessionInited = NO;

}

In my opinion, when B controller dismiss, I stop the audio input, but why red bar still appear random?

can you tell me what should i do when i dismiss B controller so that never appear red bar?
NSPratik
  • 4,714
  • 7
  • 51
  • 81

0 Answers0