[permissions] rename checkCameraAuthorizationStatus to checkVideoAuthorizationStatus
This commit is contained in:
parent
c981675636
commit
cfac209da8
|
@ -113,7 +113,7 @@ export default class Camera extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
static checkDeviceAuthorizationStatus = CameraManager.checkDeviceAuthorizationStatus;
|
static checkDeviceAuthorizationStatus = CameraManager.checkDeviceAuthorizationStatus;
|
||||||
static checkVideoAuthorizationStatus = CameraManager.checkCameraAuthorizationStatus;
|
static checkVideoAuthorizationStatus = CameraManager.checkVideoAuthorizationStatus;
|
||||||
static checkAudioAuthorizationStatus = CameraManager.checkAudioAuthorizationStatus;
|
static checkAudioAuthorizationStatus = CameraManager.checkAudioAuthorizationStatus;
|
||||||
|
|
||||||
setNativeProps(props) {
|
setNativeProps(props) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ RCT_EXPORT_MODULE();
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
{
|
{
|
||||||
self.session = [AVCaptureSession new];
|
self.session = [AVCaptureSession new];
|
||||||
|
|
||||||
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
|
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
|
||||||
self.previewLayer.needsDisplayOnBoundsChange = YES;
|
self.previewLayer.needsDisplayOnBoundsChange = YES;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ RCT_EXPORT_METHOD(checkDeviceAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(checkCameraAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
RCT_EXPORT_METHOD(checkVideoAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||||
reject:(__unused RCTPromiseRejectBlock)reject) {
|
reject:(__unused RCTPromiseRejectBlock)reject) {
|
||||||
__block NSString *mediaType = AVMediaTypeVideo;
|
__block NSString *mediaType = AVMediaTypeVideo;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ RCT_EXPORT_METHOD(checkCameraAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||||
RCT_EXPORT_METHOD(checkAudioAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
RCT_EXPORT_METHOD(checkAudioAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||||
reject:(__unused RCTPromiseRejectBlock)reject) {
|
reject:(__unused RCTPromiseRejectBlock)reject) {
|
||||||
__block NSString *mediaType = AVMediaTypeAudio;
|
__block NSString *mediaType = AVMediaTypeAudio;
|
||||||
|
|
||||||
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
||||||
resolve(@(granted));
|
resolve(@(granted));
|
||||||
}];
|
}];
|
||||||
|
@ -258,7 +258,7 @@ RCT_EXPORT_METHOD(changeOrientation:(NSInteger)orientation) {
|
||||||
self.previewLayer.connection.videoOrientation = orientation;
|
self.previewLayer.connection.videoOrientation = orientation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(changeMirrorImage:(BOOL)mirrorImage) {
|
RCT_EXPORT_METHOD(changeMirrorImage:(BOOL)mirrorImage) {
|
||||||
self.mirrorImage = mirrorImage;
|
self.mirrorImage = mirrorImage;
|
||||||
}
|
}
|
||||||
|
@ -554,18 +554,18 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
|
||||||
else if (target == RCTCameraCaptureTargetDisk) {
|
else if (target == RCTCameraCaptureTargetDisk) {
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||||
NSString *documentsDirectory = [paths firstObject];
|
NSString *documentsDirectory = [paths firstObject];
|
||||||
|
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSString *fullPath = [[documentsDirectory stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]] stringByAppendingPathExtension:@"jpg"];
|
NSString *fullPath = [[documentsDirectory stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]] stringByAppendingPathExtension:@"jpg"];
|
||||||
|
|
||||||
[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
|
[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
|
||||||
responseString = fullPath;
|
responseString = fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (target == RCTCameraCaptureTargetTemp) {
|
else if (target == RCTCameraCaptureTargetTemp) {
|
||||||
NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString];
|
NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString];
|
||||||
NSString *fullPath = [NSString stringWithFormat:@"%@%@.jpg", NSTemporaryDirectory(), fileName];
|
NSString *fullPath = [NSString stringWithFormat:@"%@%@.jpg", NSTemporaryDirectory(), fileName];
|
||||||
|
|
||||||
[imageData writeToFile:fullPath atomically:YES];
|
[imageData writeToFile:fullPath atomically:YES];
|
||||||
responseString = fullPath;
|
responseString = fullPath;
|
||||||
}
|
}
|
||||||
|
@ -711,10 +711,10 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||||
else if (self.videoTarget == RCTCameraCaptureTargetTemp) {
|
else if (self.videoTarget == RCTCameraCaptureTargetTemp) {
|
||||||
NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString];
|
NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString];
|
||||||
NSString *fullPath = [NSString stringWithFormat:@"%@%@.mov", NSTemporaryDirectory(), fileName];
|
NSString *fullPath = [NSString stringWithFormat:@"%@%@.mov", NSTemporaryDirectory(), fileName];
|
||||||
|
|
||||||
NSFileManager * fileManager = [NSFileManager defaultManager];
|
NSFileManager * fileManager = [NSFileManager defaultManager];
|
||||||
NSError * error = nil;
|
NSError * error = nil;
|
||||||
|
|
||||||
//moving to destination
|
//moving to destination
|
||||||
if (!([fileManager moveItemAtPath:[outputFileURL path] toPath:fullPath error:&error])) {
|
if (!([fileManager moveItemAtPath:[outputFileURL path] toPath:fullPath error:&error])) {
|
||||||
self.videoReject(RCTErrorUnspecified, nil, RCTErrorWithMessage(error.description));
|
self.videoReject(RCTErrorUnspecified, nil, RCTErrorWithMessage(error.description));
|
||||||
|
@ -734,7 +734,7 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||||
if (metadata.type == barcodeType) {
|
if (metadata.type == barcodeType) {
|
||||||
// Transform the meta-data coordinates to screen coords
|
// Transform the meta-data coordinates to screen coords
|
||||||
AVMetadataMachineReadableCodeObject *transformed = (AVMetadataMachineReadableCodeObject *)[_previewLayer transformedMetadataObjectForMetadataObject:metadata];
|
AVMetadataMachineReadableCodeObject *transformed = (AVMetadataMachineReadableCodeObject *)[_previewLayer transformedMetadataObjectForMetadataObject:metadata];
|
||||||
|
|
||||||
NSDictionary *event = @{
|
NSDictionary *event = @{
|
||||||
@"type": metadata.type,
|
@"type": metadata.type,
|
||||||
@"data": metadata.stringValue,
|
@"data": metadata.stringValue,
|
||||||
|
@ -868,7 +868,7 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||||
@"zoomFactor": [NSNumber numberWithDouble:zoomFactor],
|
@"zoomFactor": [NSNumber numberWithDouble:zoomFactor],
|
||||||
@"velocity": [NSNumber numberWithDouble:velocity]
|
@"velocity": [NSNumber numberWithDouble:velocity]
|
||||||
};
|
};
|
||||||
|
|
||||||
[self.bridge.eventDispatcher sendInputEventWithName:@"zoomChanged" body:event];
|
[self.bridge.eventDispatcher sendInputEventWithName:@"zoomChanged" body:event];
|
||||||
|
|
||||||
device.videoZoomFactor = zoomFactor;
|
device.videoZoomFactor = zoomFactor;
|
||||||
|
|
Loading…
Reference in New Issue