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:
Loch Wansbrough 2015-12-08 14:38:07 -08:00
commit abca50a241
1 changed files with 3 additions and 1 deletions

View File

@ -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);