implemented method getFOV for ios

This commit is contained in:
WellDone2044 2015-11-02 15:08:17 +01:00
parent edbbcd75a3
commit 2462fb8ada
1 changed files with 44 additions and 12 deletions

View File

@ -232,6 +232,38 @@ RCT_EXPORT_METHOD(stopCapture) {
}
}
RCT_EXPORT_METHOD(getFOV: (RCTResponseSenderBlock)callback) {
NSArray *devices = [AVCaptureDevice devices];
AVCaptureDevice *frontCamera;
AVCaptureDevice *backCamera;
double frontFov;
double backFov;
for (AVCaptureDevice *device in devices) {
NSLog(@"Device name: %@", [device localizedName]);
if ([device hasMediaType:AVMediaTypeVideo]) {
if ([device position] == AVCaptureDevicePositionBack) {
NSLog(@"Device position : back");
backCamera = device;
backFov = backCamera.activeFormat.videoFieldOfView;
}
else {
NSLog(@"Device position : front");
frontCamera = device;
frontFov = frontCamera.activeFormat.videoFieldOfView;
}
}
}
callback(@[[NSNull null], @{
@"backCamera": [NSNumber numberWithDouble: backFov],
@"frontCamera": [NSNumber numberWithDouble: frontFov]
}]);
}
- (void)startSession {
#if TARGET_IPHONE_SIMULATOR
return;