我正在使用AVCaptureSession
来录制视频。我想在全屏幕上打开相机,但顶部和底部都显示灰色条。我正在使用以下代码 -
-(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];
}
答案 0 :(得分:0)
我只是更改captureVideoPreviewLayer
的画面,相机全屏显示。