I'm following the only answer this has on SO -
Switch cameras with avcapturesession
However cameraWithPosition does not seem to work. Deprecated?
//Get new input
AVCaptureDevice *newCamera = nil;
if(((AVCaptureDeviceInput*)currentCameraInput).device.position == AVCaptureDevicePositionBack)
{
newCamera = [self cameraWithPosition:AVCaptureDevicePositionFront];
}
else
{
newCamera = [self cameraWithPosition:AVCaptureDevicePositionBack];
}
Code update for Swift 4.2
In Swift 3.0
Here is an example for using the switch with a video session:
Then:
What you need to do is reconfigure your
AVCaptureSession
Here is what i'm using: