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

Commit a80dd47

Browse files
committed
Apply natural size transform for 90/270 degrees orientated videos
1 parent 04f64ec commit a80dd47

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

packages/video_player/video_player_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.3.2
2+
3+
* Apply natural size transform for 90/270 degrees orientated videos.
4+
15
## 2.3.1
26

37
* Renames internal method channels to avoid potential confusion with the

packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,18 @@ - (instancetype)initWithURL:(NSURL *)url
189189

190190
- (CGAffineTransform)fixTransform:(AVAssetTrack *)videoTrack {
191191
CGAffineTransform transform = videoTrack.preferredTransform;
192-
// TODO(@recastrodiaz): why do we need to do this? Why is the preferredTransform incorrect?
193-
// At least 2 user videos show a black screen when in portrait mode if we directly use the
194-
// videoTrack.preferredTransform Setting tx to the height of the video instead of 0, properly
195-
// displays the video https://github.com/flutter/flutter/issues/17606#issuecomment-413473181
196-
if (transform.tx == 0 && transform.ty == 0) {
197-
NSInteger rotationDegrees = (NSInteger)round(radiansToDegrees(atan2(transform.b, transform.a)));
198-
NSLog(@"TX and TY are 0. Rotation: %ld. Natural width,height: %f, %f", (long)rotationDegrees,
199-
videoTrack.naturalSize.width, videoTrack.naturalSize.height);
200-
if (rotationDegrees == 90) {
201-
NSLog(@"Setting transform tx");
202-
transform.tx = videoTrack.naturalSize.height;
203-
transform.ty = 0;
204-
} else if (rotationDegrees == 270) {
205-
NSLog(@"Setting transform ty");
206-
transform.tx = 0;
207-
transform.ty = videoTrack.naturalSize.width;
208-
}
192+
NSInteger rotationDegrees = (NSInteger)round(radiansToDegrees(atan2(transform.b, transform.a)));
193+
CGSize size = videoTrack.naturalSize;
194+
NSLog(@"TX and TY: %f, %f. Rotation: %ld. Natural width and height: %f, %f", transform.tx,
195+
transform.ty, (long)rotationDegrees, size.width, size.height);
196+
if (rotationDegrees == 90) {
197+
NSLog(@"Setting transform tx");
198+
transform.tx = size.height;
199+
transform.ty = 0;
200+
} else if (rotationDegrees == 270) {
201+
NSLog(@"Setting transform ty");
202+
transform.tx = 0;
203+
transform.ty = size.width;
209204
}
210205
return transform;
211206
}

packages/video_player/video_player_avfoundation/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: video_player_avfoundation
22
description: iOS implementation of the video_player plugin.
33
repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_avfoundation
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
5-
version: 2.3.1
5+
version: 2.3.2
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"

0 commit comments

Comments
 (0)