Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVCam not in fullscreen

I've integrated AVCam in my iOS app. The problem is in iPhone 4 the preview frame isn't fullscreen, it has empty side borders...

How can I solve this?

Thanks.

like image 396
diogo.appDev Avatar asked Dec 10 '13 14:12

diogo.appDev


2 Answers

You need to use the videoGravity property of the AVCaptureVideoPreviewLayer.

Take a look to the doc. You need to use: AVLayerVideoGravityResizeAspectFill

Edit:

Based on that the solution founded by the asker is:

- (void)setSession:(AVCaptureSession *)session {
    ((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
    ((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds;
    [(AVCaptureVideoPreviewLayer *)[self layer] setSession:session];
}
like image 167
dcorbatta Avatar answered Oct 02 '22 08:10

dcorbatta


Fixed it with the following method in AVCamPreviewView.

- (void)setSession:(AVCaptureSession *)session {
    ((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
    ((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds;
    [(AVCaptureVideoPreviewLayer *)[self layer] setSession:session];
}
like image 30
diogo.appDev Avatar answered Oct 02 '22 08:10

diogo.appDev