Skip to content
This repository was archived by the owner on Jun 16, 2023. It is now read-only.

Commit 91f5bf4

Browse files
authoredJun 13, 2018
fix(rn-camera): fix codec backwards compat
1 parent 4fdd548 commit 91f5bf4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed
 

‎ios/RN/RNCamera.m

+9-6
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ - (void)record:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve r
451451
[connection setVideoOrientation:[RNCameraUtils videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]];
452452

453453
if (options[@"codec"]) {
454-
AVVideoCodecType videoCodecType = options[@"codec"];
455454
if (@available(iOS 10, *)) {
455+
AVVideoCodecType videoCodecType = options[@"codec"];
456456
if ([self.movieFileOutput.availableVideoCodecTypes containsObject:videoCodecType]) {
457457
[self.movieFileOutput setOutputSettings:@{AVVideoCodecKey:videoCodecType} forConnection:connection];
458458
self.videoCodecType = videoCodecType;
@@ -812,12 +812,15 @@ - (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToO
812812
}
813813
}
814814
if (success && self.videoRecordedResolve != nil) {
815-
AVVideoCodecType videoCodec = self.videoCodecType;
816-
if (videoCodec == nil) {
817-
videoCodec = [self.movieFileOutput.availableVideoCodecTypes firstObject];
815+
if (@available(iOS 10, *)) {
816+
AVVideoCodecType videoCodec = self.videoCodecType;
817+
if (videoCodec == nil) {
818+
videoCodec = [self.movieFileOutput.availableVideoCodecTypes firstObject];
819+
}
820+
self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString, @"codec":videoCodec });
821+
} else {
822+
self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString });
818823
}
819-
820-
self.videoRecordedResolve(@{ @"uri": outputFileURL.absoluteString, @"codec":videoCodec });
821824
} else if (self.videoRecordedReject != nil) {
822825
self.videoRecordedReject(@"E_RECORDING_FAILED", @"An error occurred while recording a video.", error);
823826
}

0 commit comments

Comments
 (0)