set the right preview orientation before startup
This commit is contained in:
parent
13384afdcf
commit
d3ec8388d9
|
@ -59,6 +59,7 @@ typedef NS_ENUM(NSInteger, RCTCameraTorchMode) {
|
|||
@property (nonatomic, assign) NSInteger presetCamera;
|
||||
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;
|
||||
@property (nonatomic, assign) NSInteger videoTarget;
|
||||
@property (nonatomic, assign) NSInteger orientation;
|
||||
@property (nonatomic, assign) BOOL mirrorImage;
|
||||
@property (nonatomic, strong) RCTPromiseResolveBlock videoResolve;
|
||||
@property (nonatomic, strong) RCTPromiseRejectBlock videoReject;
|
||||
|
|
|
@ -236,16 +236,10 @@ RCT_EXPORT_METHOD(changeFlashMode:(NSInteger)flashMode) {
|
|||
}
|
||||
|
||||
RCT_EXPORT_METHOD(changeOrientation:(NSInteger)orientation) {
|
||||
[self setOrientation:orientation];
|
||||
if (self.previewLayer.connection.isVideoOrientationSupported) {
|
||||
self.previewLayer.connection.videoOrientation = orientation;
|
||||
}
|
||||
else {
|
||||
// Setting videoOrientation isn't yet supported, so we have to wait until
|
||||
// startSession has finished to set it. Put this in the queue behind.
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
self.previewLayer.connection.videoOrientation = orientation;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(changeMirrorImage:(BOOL)mirrorImage) {
|
||||
|
@ -365,6 +359,7 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
|
|||
});
|
||||
}]];
|
||||
|
||||
[self.previewLayer.connection setVideoOrientation:self.orientation];
|
||||
[self.session startRunning];
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue