I am using AVCaptureSession
to record video.I want to open camera on full screen but there is gray bar is displaying on top and bottom. I am using following code-
-(void)addCamera
{
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
AVCaptureDevicePosition currentCameraPosition = [input device].position;
currentCameraPosition = AVCaptureDevicePositionFront;
if (!input)
{
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
}
I just change the frame of the captureVideoPreviewLayer
and the camera is showing on full screen.