[video_player] Platform interface changes to fix Android rotation for videos recorded in landscapeRight (#4634)
diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md
index 5261220..6595a5c 100644
--- a/packages/video_player/video_player_platform_interface/CHANGELOG.md
+++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 5.1.1
+
+* Adds `rotationCorrection` (for Android playing videos recorded in landscapeRight [#60327](https://github.com/flutter/flutter/issues/60327)).
+
## 5.1.0
* Adds `allowBackgroundPlayback` to `VideoPlayerOptions`.
diff --git a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart
index 2aa7fb3..097ab29 100644
--- a/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart
+++ b/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart
@@ -115,6 +115,7 @@
duration: Duration(milliseconds: map['duration']! as int),
size: Size((map['width'] as num?)?.toDouble() ?? 0.0,
(map['height'] as num?)?.toDouble() ?? 0.0),
+ rotationCorrection: map['rotationCorrection'] as int? ?? 0,
);
case 'completed':
return VideoEvent(
diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
index 8a61005..706ec61 100644
--- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
+++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
@@ -199,8 +199,8 @@
///
/// The [eventType] argument is required.
///
- /// Depending on the [eventType], the [duration], [size] and [buffered]
- /// arguments can be null.
+ /// Depending on the [eventType], the [duration], [size],
+ /// [rotationCorrection], and [buffered] arguments can be null.
// TODO(stuartmorgan): Temporarily suppress warnings about not using const
// in all of the other video player packages, fix this, and then update
// the other packages to use const.
@@ -209,6 +209,7 @@
required this.eventType,
this.duration,
this.size,
+ this.rotationCorrection,
this.buffered,
});
@@ -225,6 +226,11 @@
/// Only used if [eventType] is [VideoEventType.initialized].
final Size? size;
+ /// Degrees to rotate the video (clockwise) so it is displayed correctly.
+ ///
+ /// Only used if [eventType] is [VideoEventType.initialized].
+ final int? rotationCorrection;
+
/// Buffered parts of the video.
///
/// Only used if [eventType] is [VideoEventType.bufferingUpdate].
@@ -238,6 +244,7 @@
eventType == other.eventType &&
duration == other.duration &&
size == other.size &&
+ rotationCorrection == other.rotationCorrection &&
listEquals(buffered, other.buffered);
}
@@ -246,6 +253,7 @@
eventType.hashCode ^
duration.hashCode ^
size.hashCode ^
+ rotationCorrection.hashCode ^
buffered.hashCode;
}
diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml
index b66fa0b..ea3b17b 100644
--- a/packages/video_player/video_player_platform_interface/pubspec.yaml
+++ b/packages/video_player/video_player_platform_interface/pubspec.yaml
@@ -4,7 +4,7 @@
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
-version: 5.1.0
+version: 5.1.1
environment:
sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart
index 75baba4..ca17196 100644
--- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart
+++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart
@@ -263,6 +263,20 @@
'flutter.io/videoPlayer/videoEvents123',
const StandardMethodCodec()
.encodeSuccessEnvelope(<String, dynamic>{
+ 'event': 'initialized',
+ 'duration': 98765,
+ 'width': 1920,
+ 'height': 1080,
+ 'rotationCorrection': 180,
+ }),
+ (ByteData? data) {});
+
+ await _ambiguate(ServicesBinding.instance)
+ ?.defaultBinaryMessenger
+ .handlePlatformMessage(
+ 'flutter.io/videoPlayer/videoEvents123',
+ const StandardMethodCodec()
+ .encodeSuccessEnvelope(<String, dynamic>{
'event': 'completed',
}),
(ByteData? data) {});
@@ -316,6 +330,13 @@
eventType: VideoEventType.initialized,
duration: const Duration(milliseconds: 98765),
size: const Size(1920, 1080),
+ rotationCorrection: 0,
+ ),
+ VideoEvent(
+ eventType: VideoEventType.initialized,
+ duration: const Duration(milliseconds: 98765),
+ size: const Size(1920, 1080),
+ rotationCorrection: 180,
),
VideoEvent(eventType: VideoEventType.completed),
VideoEvent(