mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 09:48:17 +00:00
Option to mirrorVideo for iOS
The work done by @rad182 (but he closed his pull request?) https://github.com/react-native-community/react-native-camera/pull/915
This commit is contained in:
parent
0a7511ffd6
commit
f25df35431
@ -256,6 +256,10 @@ By default a <ActivityIndicator> will be displayed while the component is waitin
|
||||
|
||||
If set to `true`, the image returned will be mirrored.
|
||||
|
||||
#### `mirrorVideo`
|
||||
|
||||
If set to `true`, the video returned will be mirrored.
|
||||
|
||||
#### `fixOrientation` (_deprecated_)
|
||||
|
||||
If set to `true`, the image returned will be rotated to the _right way up_. WARNING: It uses a significant amount of memory and my cause your application to crash if the device cannot provide enough RAM to perform the rotation.
|
||||
|
@ -72,6 +72,7 @@ typedef NS_ENUM(NSInteger, RCTCameraTorchMode) {
|
||||
@property (nonatomic, assign) NSInteger videoTarget;
|
||||
@property (nonatomic, assign) NSInteger orientation;
|
||||
@property (nonatomic, assign) BOOL mirrorImage;
|
||||
@property (nonatomic, assign) BOOL mirrorVideo;
|
||||
@property (nonatomic, assign) BOOL cropToPreview;
|
||||
@property (nonatomic, strong) NSArray* barCodeTypes;
|
||||
@property (nonatomic, strong) RCTPromiseResolveBlock videoResolve;
|
||||
|
@ -298,6 +298,10 @@ RCT_CUSTOM_VIEW_PROPERTY(mirrorImage, BOOL, RCTCamera) {
|
||||
self.mirrorImage = [RCTConvert BOOL:json];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(mirrorVideo, BOOL, RCTCamera) {
|
||||
self.mirrorVideo = [RCTConvert BOOL:json];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(cropToPreview, BOOL, RCTCamera) {
|
||||
self.cropToPreview = [RCTConvert BOOL:json];
|
||||
}
|
||||
@ -325,6 +329,7 @@ RCT_CUSTOM_VIEW_PROPERTY(captureAudio, BOOL, RCTCamera) {
|
||||
- (id)init {
|
||||
if ((self = [super init])) {
|
||||
self.mirrorImage = false;
|
||||
self.mirrorVideo = false;
|
||||
|
||||
self.sessionQueue = dispatch_queue_create("cameraManagerQueue", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
@ -845,7 +850,10 @@ RCT_EXPORT_METHOD(setZoom:(CGFloat)zoomFactor) {
|
||||
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
[[self.movieFileOutput connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:orientation];
|
||||
|
||||
|
||||
if (self.mirrorVideo) {
|
||||
[[self.movieFileOutput connectionWithMediaType:AVMediaTypeVideo] setVideoMirrored:YES]
|
||||
}
|
||||
//Create temporary URL to record to
|
||||
NSString *outputPath = [[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"output.mov"];
|
||||
NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:outputPath];
|
||||
|
@ -115,6 +115,7 @@ export default class Camera extends Component {
|
||||
onFocusChanged: PropTypes.func,
|
||||
onZoomChanged: PropTypes.func,
|
||||
mirrorImage: PropTypes.bool,
|
||||
mirrorVideo: PropTypes.bool,
|
||||
fixOrientation: PropTypes.bool,
|
||||
barCodeTypes: PropTypes.array,
|
||||
orientation: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
@ -142,6 +143,7 @@ export default class Camera extends Component {
|
||||
playSoundOnCapture: true,
|
||||
torchMode: CameraManager.TorchMode.off,
|
||||
mirrorImage: false,
|
||||
mirrorVideo: false,
|
||||
cropToPreview: false,
|
||||
clearWindowBackground: false,
|
||||
barCodeTypes: Object.values(CameraManager.BarCodeType),
|
||||
@ -305,6 +307,7 @@ export default class Camera extends Component {
|
||||
title: '',
|
||||
description: '',
|
||||
mirrorImage: props.mirrorImage,
|
||||
mirrorVideo: props.mirrorVideo,
|
||||
fixOrientation: props.fixOrientation,
|
||||
cropToPreview: props.cropToPreview,
|
||||
...options,
|
||||
|
Loading…
x
Reference in New Issue
Block a user