Skip to content
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] Try to address test flake #6899

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.8.7

* Ensures that `value.position` never reports a value larger than `value.duration`.
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.

## 2.8.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ void main() {

testWidgets('test video player view with local asset',
(WidgetTester tester) async {
final Completer<void> loaded = Completer<void>();
Future<bool> started() async {
await controller.initialize();
await controller.play();
loaded.complete();
return true;
}

Expand All @@ -221,12 +223,12 @@ void main() {
),
));

await loaded.future;
await tester.pumpAndSettle();
expect(controller.value.isPlaying, true);
},
skip: kIsWeb || // Web does not support local assets.
// Extremely flaky on iOS: https://github.com/flutter/flutter/issues/86915
defaultTargetPlatform == TargetPlatform.iOS);
// Web does not support local assets.
skip: kIsWeb);
});

group('file-based videos', () {
Expand Down
6 changes: 6 additions & 0 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,12 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
}

void _updatePosition(Duration position) {
// The underlying native implementation on some platforms sometimes reports
// a position slightly past the reported max duration. Clamp to the duration
// to insulate clients from this behavior.
if (position.compareTo(value.duration) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would this not be easier to read as position > value.duration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, for some reason I thought that didn't work. Yes, definitely much better that way.

position = value.duration;
}
value = value.copyWith(
position: position,
caption: _getCaptionAt(position),
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.8.6
version: 2.8.7

environment:
sdk: ">=3.2.3 <4.0.0"
Expand Down