Skip to content

Commit dbc222d

Browse files
committed
update deprecated AVCaptureVideoOrientation in favor of rotation angle
1 parent e0e5630 commit dbc222d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Modules/Sources/WPMediaPicker/WPMediaCapturePreviewCollectionView.m

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ - (void)startCapture
111111
self.captureVideoPreviewLayer.frame = viewLayer.bounds;
112112
self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
113113
UIWindowScene *currentScene = [[[[UIApplication sharedApplication] windows] lastObject] windowScene];
114-
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[currentScene interfaceOrientation]];
114+
self.captureVideoPreviewLayer.connection.videoRotationAngle = [self videoRotationAngleForInterfaceOrientation:[currentScene interfaceOrientation]];
115115
[viewLayer addSublayer:self.captureVideoPreviewLayer];
116116
});
117117
}
@@ -121,24 +121,23 @@ - (void)startCapture
121121

122122
- (void)deviceOrientationDidChange:(NSNotification *)notification
123123
{
124-
if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) {
125-
UIWindowScene *currentScene = [[[[UIApplication sharedApplication] windows] lastObject] windowScene];
126-
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[currentScene interfaceOrientation]];
127-
}
124+
UIWindowScene *currentScene = [[[[UIApplication sharedApplication] windows] lastObject] windowScene];
125+
self.captureVideoPreviewLayer.connection.videoRotationAngle = [self videoRotationAngleForInterfaceOrientation:[currentScene interfaceOrientation]];
128126
}
129127

130-
- (AVCaptureVideoOrientation)videoOrientationForInterfaceOrientation:(UIInterfaceOrientation)orientation
128+
- (CGFloat)videoRotationAngleForInterfaceOrientation:(UIInterfaceOrientation)orientation
131129
{
132130
switch (orientation) {
133131
case UIInterfaceOrientationPortrait:
134-
return AVCaptureVideoOrientationPortrait;
132+
return 90.0;
135133
case UIInterfaceOrientationPortraitUpsideDown:
136-
return AVCaptureVideoOrientationPortraitUpsideDown;
134+
return 270.0;
137135
case UIInterfaceOrientationLandscapeLeft:
138-
return AVCaptureVideoOrientationLandscapeLeft;
136+
return 180.0;
139137
case UIInterfaceOrientationLandscapeRight:
140-
return AVCaptureVideoOrientationLandscapeRight;
141-
default:return AVCaptureVideoOrientationPortrait;
138+
return 0.0;
139+
default:
140+
return 90.0;
142141
}
143142
}
144143

0 commit comments

Comments
 (0)