-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[video_player_android] Correct rotation of videos recorded by the camera #7846
Conversation
...yer_android/android/src/main/java/io/flutter/plugins/videoplayer/ExoPlayerEventListener.java
Outdated
Show resolved
Hide resolved
...yer_android/android/src/main/java/io/flutter/plugins/videoplayer/ExoPlayerEventListener.java
Outdated
Show resolved
Hide resolved
} | ||
events.onInitialized(width, height, exoPlayer.getDuration(), rotationCorrection); | ||
} | ||
|
||
private int getRotationCorrectionFromUnappliedRotation(int unappliedRotationDegrees) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using an enum instead of an int since our code does not actually handle in between values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 enum
} | ||
|
||
@OptIn(markerClass = androidx.media3.common.util.UnstableApi.class) | ||
// The annotation is used to enable using a Format to determine the rotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment should instead of explaining what an unstable api annotation does should instead explain why it is ok to use an unstable api and what the failure modes are that we can expect. (for example should we expect the signature to possibly change across minor versions).
@@ -33,7 +35,7 @@ | |||
* ({@link VideoPlayerCallbacks} and/or interface with the player instance as expected. | |||
*/ | |||
@RunWith(RobolectricTestRunner.class) | |||
public final class ExoPlayerEventListenerTests { | |||
public final class ExoPlayerEventListenerTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to remove the "s" in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes to make it consistent with the other tests in this plugin (and across plugins).
...android/android/src/test/java/io/flutter/plugins/videoplayer/ExoPlayerEventListenerTest.java
Outdated
Show resolved
Hide resolved
...android/android/src/test/java/io/flutter/plugins/videoplayer/ExoPlayerEventListenerTest.java
Outdated
Show resolved
Hide resolved
...yer_android/android/src/main/java/io/flutter/plugins/videoplayer/ExoPlayerEventListener.java
Outdated
Show resolved
Hide resolved
} | ||
events.onInitialized(width, height, exoPlayer.getDuration(), rotationCorrection); | ||
} | ||
|
||
private int getRotationCorrectionFromUnappliedRotation(int unappliedRotationDegrees) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 enum
...yer_android/android/src/main/java/io/flutter/plugins/videoplayer/ExoPlayerEventListener.java
Outdated
Show resolved
Hide resolved
...yer_android/android/src/main/java/io/flutter/plugins/videoplayer/ExoPlayerEventListener.java
Outdated
Show resolved
Hide resolved
cc @matanlurey the video_player_android test |
Filed flutter/flutter#157307 |
flutter/packages@b6f7e47...5e03bb1 2024-10-21 43054281+camsim99@users.noreply.github.com [video_player_android] Correct rotation of videos recorded by the camera (flutter/packages#7846) 2024-10-21 gspencergoog@users.noreply.github.com Allow custom blocks to be something other than `Column` or `SizedBox` (flutter/packages#7859) 2024-10-21 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump androidx.annotation:annotation from 1.8.2 to 1.9.0 in /packages/camera/camera_android/android (flutter/packages#7905) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…r#157349) flutter/packages@b6f7e47...5e03bb1 2024-10-21 43054281+camsim99@users.noreply.github.com [video_player_android] Correct rotation of videos recorded by the camera (flutter/packages#7846) 2024-10-21 gspencergoog@users.noreply.github.com Allow custom blocks to be something other than `Column` or `SizedBox` (flutter/packages#7859) 2024-10-21 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump androidx.annotation:annotation from 1.8.2 to 1.9.0 in /packages/camera/camera_android/android (flutter/packages#7905) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Hopefully 🤞 corrects the calculation used to determine the rotation correction of the video being played. These are the different cases this addresses:
SurfaceTexture
Impeller backend is used. From my testing, I see the preview is correctly rotated and sized without any further intervention, so the correction is set 0.ImageReader
Impelled backend is used and a preview correction was noticed by the community (see [video_player_android] Incorrect orientation when previewing captured videos flutter#154696). To fix this, we now use the rotation correction reported by the video's format. We also now use this rotation to make the fix for a swapped = width and height when the correction is 90 or 270 degrees (indicating that the video is landscape) as the logic did before but instead with the unapplied rotation degrees (see case 1 for context).Tested this on Android APIs 28, 30, 32, and 35.
A fix attempt for flutter/flutter#154696.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).