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

Commit 52995e8

Browse files
authored
[video_player] Platform interface changes to fix Android rotation for videos recorded in landscapeRight (#4634)
1 parent 3069bc3 commit 52995e8

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

packages/video_player/video_player_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.1.1
2+
3+
* Adds `rotationCorrection` (for Android playing videos recorded in landscapeRight [#60327](https://github.com/flutter/flutter/issues/60327)).
4+
15
## 5.1.0
26

37
* Adds `allowBackgroundPlayback` to `VideoPlayerOptions`.

packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class MethodChannelVideoPlayer extends VideoPlayerPlatform {
115115
duration: Duration(milliseconds: map['duration']! as int),
116116
size: Size((map['width'] as num?)?.toDouble() ?? 0.0,
117117
(map['height'] as num?)?.toDouble() ?? 0.0),
118+
rotationCorrection: map['rotationCorrection'] as int? ?? 0,
118119
);
119120
case 'completed':
120121
return VideoEvent(

packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ class VideoEvent {
199199
///
200200
/// The [eventType] argument is required.
201201
///
202-
/// Depending on the [eventType], the [duration], [size] and [buffered]
203-
/// arguments can be null.
202+
/// Depending on the [eventType], the [duration], [size],
203+
/// [rotationCorrection], and [buffered] arguments can be null.
204204
// TODO(stuartmorgan): Temporarily suppress warnings about not using const
205205
// in all of the other video player packages, fix this, and then update
206206
// the other packages to use const.
@@ -209,6 +209,7 @@ class VideoEvent {
209209
required this.eventType,
210210
this.duration,
211211
this.size,
212+
this.rotationCorrection,
212213
this.buffered,
213214
});
214215

@@ -225,6 +226,11 @@ class VideoEvent {
225226
/// Only used if [eventType] is [VideoEventType.initialized].
226227
final Size? size;
227228

229+
/// Degrees to rotate the video (clockwise) so it is displayed correctly.
230+
///
231+
/// Only used if [eventType] is [VideoEventType.initialized].
232+
final int? rotationCorrection;
233+
228234
/// Buffered parts of the video.
229235
///
230236
/// Only used if [eventType] is [VideoEventType.bufferingUpdate].
@@ -238,6 +244,7 @@ class VideoEvent {
238244
eventType == other.eventType &&
239245
duration == other.duration &&
240246
size == other.size &&
247+
rotationCorrection == other.rotationCorrection &&
241248
listEquals(buffered, other.buffered);
242249
}
243250

@@ -246,6 +253,7 @@ class VideoEvent {
246253
eventType.hashCode ^
247254
duration.hashCode ^
248255
size.hashCode ^
256+
rotationCorrection.hashCode ^
249257
buffered.hashCode;
250258
}
251259

packages/video_player/video_player_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/video_player/v
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 5.1.0
7+
version: 5.1.1
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,20 @@ void main() {
257257
}),
258258
(ByteData? data) {});
259259

260+
await _ambiguate(ServicesBinding.instance)
261+
?.defaultBinaryMessenger
262+
.handlePlatformMessage(
263+
'flutter.io/videoPlayer/videoEvents123',
264+
const StandardMethodCodec()
265+
.encodeSuccessEnvelope(<String, dynamic>{
266+
'event': 'initialized',
267+
'duration': 98765,
268+
'width': 1920,
269+
'height': 1080,
270+
'rotationCorrection': 180,
271+
}),
272+
(ByteData? data) {});
273+
260274
await _ambiguate(ServicesBinding.instance)
261275
?.defaultBinaryMessenger
262276
.handlePlatformMessage(
@@ -316,6 +330,13 @@ void main() {
316330
eventType: VideoEventType.initialized,
317331
duration: const Duration(milliseconds: 98765),
318332
size: const Size(1920, 1080),
333+
rotationCorrection: 0,
334+
),
335+
VideoEvent(
336+
eventType: VideoEventType.initialized,
337+
duration: const Duration(milliseconds: 98765),
338+
size: const Size(1920, 1080),
339+
rotationCorrection: 180,
319340
),
320341
VideoEvent(eventType: VideoEventType.completed),
321342
VideoEvent(

0 commit comments

Comments
 (0)