You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[video_player] Move Android buffer updates to Dart (#9771)
Since ExoPlayer does not generate events for changes to the buffer position, the `video_player_android` synthesizes them via polling. This moves the logic to generate these events from Java to Dart, to reduce the amount of logic on the Java side.
This does not attempt to fix the structural problem that the workaround was piggy-backed on the fact that the app-facing package polls frequently for the playback position, generating buffer update events when that polling happens rather than via any independent internal polling system. This approach is not only fragile, as it depends on logic defined in another package, but already doesn't work in the case of a paused video. However, this refactoring will make it possible to change this behavior in Dart code in a follow-up focused on that behavioral change. This change should be behavior-neutral, except that it adds the simple improvement of not creating events if the buffer position hasn't changed, so that clients aren't getting a stream of useless buffer position events during playback.
This version will also be more efficient from a platform channel standpoint, since instead of sending a separate message with the buffer position, it's returned in the same call as the playback position.
To support synthesizing events on the Dart side, this adds a custom stream controller in Dart, instead of creating it directly from the EventChannel stream; this change will make future changes to a non-method-channel approach (e.g., FFI callbacks) straightforward. As this adds non-trivial additional per-player-instance state on the Dart side, this adds a Dart player instance class, and consolidates existing state into that class, including passthrough methods for the API calls, making it clearer which state is plugin level vs player level.
Part of flutter/flutter#172763
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
+5-10Lines changed: 5 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -66,10 +66,6 @@ public void setDisposeHandler(@Nullable DisposeHandler handler) {
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java
+18-14Lines changed: 18 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -126,17 +126,6 @@ public void playsAndPausesProvidedMedia() {
0 commit comments