diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index f9bae8dee6e1..22444b09e44f 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.0-nullsafety.8 + +* Fixed an issue where some videos would be rendered black on iOS. + ## 2.0.0-nullsafety.7 * Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. @@ -276,7 +280,6 @@ DefaultHttpDataSourceFactory by default. * Fix a few other IDE warnings. - ## 0.10.0+7 * Android: Fix issue where buffering status in percentage instead of milliseconds diff --git a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m index e6a4f6ccb0b7..8edc8034a117 100644 --- a/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m @@ -171,21 +171,26 @@ - (CGAffineTransform)fixTransform:(AVAssetTrack*)videoTrack { CGAffineTransform transform = videoTrack.preferredTransform; // TODO(@recastrodiaz): why do we need to do this? Why is the preferredTransform incorrect? // At least 2 user videos show a black screen when in portrait mode if we directly use the - // videoTrack.preferredTransform Setting tx to the height of the video instead of 0, properly - // displays the video https://github.com/flutter/flutter/issues/17606#issuecomment-413473181 - if (transform.tx == 0 && transform.ty == 0) { - NSInteger rotationDegrees = (NSInteger)round(radiansToDegrees(atan2(transform.b, transform.a))); - NSLog(@"TX and TY are 0. Rotation: %ld. Natural width,height: %f, %f", (long)rotationDegrees, - videoTrack.naturalSize.width, videoTrack.naturalSize.height); - if (rotationDegrees == 90) { - NSLog(@"Setting transform tx"); - transform.tx = videoTrack.naturalSize.height; - transform.ty = 0; - } else if (rotationDegrees == 270) { - NSLog(@"Setting transform ty"); - transform.tx = 0; - transform.ty = videoTrack.naturalSize.width; - } + // videoTrack.preferredTransform. This is because the transform.tx and transform.ty values are + // incorrectly set to 0. + // Setting the transform.tx value to the height of the video instead of 0 when rotationDegrees == + // 90 and transform.ty to the video width when rotationDegrees == 270, properly displays the video + // https://github.com/flutter/flutter/issues/17606#issuecomment-413473181 In 1 other user video + // the transform.x and transform.y are set to 1080.0 and 0.0 respectively, whilst the width, + // height and rotation of the video are 848.0, 480.0 and 90 respectively. Replacing the value of + // transform.tx to the video height properly renders the video. + NSInteger rotationDegrees = (NSInteger)round(radiansToDegrees(atan2(transform.b, transform.a))); + NSLog(@"VIDEO__ %f, %f, %f, %f, %li", transform.tx, transform.ty, videoTrack.naturalSize.height, + videoTrack.naturalSize.width, (long)rotationDegrees); + if (rotationDegrees == 90) { + transform.tx = videoTrack.naturalSize.height; + transform.ty = 0; + } else if (rotationDegrees == 180) { + transform.tx = videoTrack.naturalSize.width; + transform.ty = videoTrack.naturalSize.height; + } else if (rotationDegrees == 270) { + transform.tx = 0; + transform.ty = videoTrack.naturalSize.width; } return transform; } diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index e4694195ebde..72fb54b125ea 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter # 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 2.0.0-nullsafety.7 +version: 2.0.0-nullsafety.8 homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player flutter: