add output to session only when possible

This commit is contained in:
Ran Greenberg 2019-03-06 10:06:32 +02:00
parent 94c24b2c40
commit a753c508ed
1 changed files with 8 additions and 4 deletions

View File

@ -308,11 +308,15 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
{ {
if (onReadCode) { if (onReadCode) {
_onReadCode = onReadCode; _onReadCode = onReadCode;
self.metadataOutput = [[AVCaptureMetadataOutput alloc] init];
AVCaptureMetadataOutput * output = [[AVCaptureMetadataOutput alloc] init];
if ([self.session canAddOutput:output]) {
self.metadataOutput = output;
[self.session addOutput:self.metadataOutput]; [self.session addOutput:self.metadataOutput];
[self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; [self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
[self.metadataOutput setMetadataObjectTypes:[self.metadataOutput availableMetadataObjectTypes]]; [self.metadataOutput setMetadataObjectTypes:[self.metadataOutput availableMetadataObjectTypes]];
} }
}
} }
-(void)handleCameraPermission { -(void)handleCameraPermission {