Merge pull request #130 from apprennet/pinch-to-zoom-crash-fix
Fix crash when user pinches to zoom on devices that don't support it.
This commit is contained in:
commit
abca50a241
|
@ -723,6 +723,8 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
|||
AVCaptureDevice *device = [[self videoCaptureDeviceInput] device];
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
CGFloat zoomFactor = device.videoZoomFactor + atan(velocity / pinchVelocityDividerFactor);
|
||||
zoomFactor = zoomFactor >= 1 && zoomFactor <= device.activeFormat.videoMaxZoomFactor ? zoomFactor : 1.0f;
|
||||
|
||||
NSDictionary *event = @{
|
||||
@"target": reactTag,
|
||||
@"zoomFactor": [NSNumber numberWithDouble:zoomFactor],
|
||||
|
@ -730,7 +732,7 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
|||
};
|
||||
[self.bridge.eventDispatcher sendInputEventWithName:@"zoomChanged" body:event];
|
||||
|
||||
device.videoZoomFactor = zoomFactor >= 1.0f ? zoomFactor : 1.0f;
|
||||
device.videoZoomFactor = zoomFactor;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"error: %@", error);
|
||||
|
|
Loading…
Reference in New Issue