rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

Dark Gray screen when switching camera, freezes #345

Closed joshoconnor89 closed 7 years ago

joshoconnor89 commented 7 years ago

I am using the method "switchCameraButtonPressed" below, which switches the capture device from front -> back, or vice versa. When this method is ran, the entire screen overlays with a dark background, and freezes. I cant switch the camera back again. I'm not sure what is causing this issue. Does anyone else experiencing this freezing?

` @IBAction func switchCameraButtonPressed(sender: AnyObject) {

    recorder.pause()
    recorder.switchCaptureDevices()

    if recordInProgress {
        recorder.record()
    }
}`
joshoconnor89 commented 7 years ago

Seems like the issue was I had set the AVAudioSession to Ambient or Playback elsewhere, and this audiosession was causing video to not load. Here is an example of the code I updated (isCaptureMode will be true if we are using the camera)

` do { if (!isCaptureMode){ try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient) }

    }
    catch {
        // report for an error
    }

`