Skip to content

Conversation

@Andro999b
Copy link

@Andro999b Andro999b commented Oct 31, 2025

Some custom video_platform implementation can update a duration during playback (like media_kit) for HLS streams (if they detected as a livestream). To address this new VideoEventType added: durationUpdate.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [video_player]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].
  • All existing and new tests are passing.

@Andro999b Andro999b requested a review from tarrinneal as a code owner October 31, 2025 08:25
@Andro999b Andro999b changed the title [video_player] Add updateDuration event [video_player] Add durationUpdate to VideoEventType Oct 31, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new durationUpdate event to allow for changes in video duration during playback, which is useful for formats like HLS live streams. The VideoPlayerController is updated to handle this event and update its duration value accordingly. A new test is added to verify this functionality. My feedback focuses on improving the clarity and correctness of the new test case.

Comment on lines 1053 to 1072
testWidgets('buffering status', (WidgetTester tester) async {
final VideoPlayerController controller =
VideoPlayerController.networkUrl(_localhostUri);

await controller.initialize();
const Duration initDuration = Duration(milliseconds: 100);
controller.value = controller.value.copyWith(duration: initDuration);

final StreamController<VideoEvent> fakeVideoEventStream =
fakeVideoPlayerPlatform.streams[controller.playerId]!;

const Duration updatedDuration = Duration(milliseconds: 200);
fakeVideoEventStream.add(
VideoEvent(eventType: VideoEventType.durationUpdate, duration: updatedDuration),
);

await tester.pumpAndSettle();
expect(controller.value.duration, updatedDuration);
await tester.runAsync(controller.dispose);
});

Choose a reason for hiding this comment

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

medium

The test name 'buffering status' is misleading as this test verifies the duration update functionality. It's also a duplicate of another test name in this file, which can cause confusion. It should be renamed to be more descriptive. Additionally, an extra blank line can be removed for conciseness.

Suggested change
testWidgets('buffering status', (WidgetTester tester) async {
final VideoPlayerController controller =
VideoPlayerController.networkUrl(_localhostUri);
await controller.initialize();
const Duration initDuration = Duration(milliseconds: 100);
controller.value = controller.value.copyWith(duration: initDuration);
final StreamController<VideoEvent> fakeVideoEventStream =
fakeVideoPlayerPlatform.streams[controller.playerId]!;
const Duration updatedDuration = Duration(milliseconds: 200);
fakeVideoEventStream.add(
VideoEvent(eventType: VideoEventType.durationUpdate, duration: updatedDuration),
);
await tester.pumpAndSettle();
expect(controller.value.duration, updatedDuration);
await tester.runAsync(controller.dispose);
});
testWidgets('duration is updated by durationUpdate event', (WidgetTester tester) async {
final VideoPlayerController controller =
VideoPlayerController.networkUrl(_localhostUri);
await controller.initialize();
const Duration initDuration = Duration(milliseconds: 100);
controller.value = controller.value.copyWith(duration: initDuration);
final StreamController<VideoEvent> fakeVideoEventStream =
fakeVideoPlayerPlatform.streams[controller.playerId]!;
const Duration updatedDuration = Duration(milliseconds: 200);
fakeVideoEventStream.add(
VideoEvent(eventType: VideoEventType.durationUpdate, duration: updatedDuration),
);
await tester.pumpAndSettle();
expect(controller.value.duration, updatedDuration);
await tester.runAsync(controller.dispose);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant