Skip to content

[video_player] Improve seek performance on Android#11810

Open
sailendrabathi wants to merge 1 commit into
flutter:mainfrom
sailendrabathi:improve_seek_performance
Open

[video_player] Improve seek performance on Android#11810
sailendrabathi wants to merge 1 commit into
flutter:mainfrom
sailendrabathi:improve_seek_performance

Conversation

@sailendrabathi
Copy link
Copy Markdown

Adds backBufferDurationMs to VideoPlayerOptions and configures ExoPlayer's DefaultLoadControl to retain the back buffer from keyframes. This significantly improves seek performance and responsiveness during video playback on Android.

iOS already has some kind of back buffering implemented in AVPlayer because the replays and seeks are instantaneous for small videos.

Before:
Replays and seeks on Android for network based video assets involve a network call to fetch the video content. This significantly hampers the user experience.

After:
Replays and seeks on Android (within the back buffer duration) are instant just like in iOS. Improving user experience

This PR partly addresses flutter/flutter#97428. Not enabling back buffering by default and instead allowing the app to configure as per need. The default behavior will be same as the existing implementation to avoid any regressions.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • 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. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style], or I have commented below to indicate which documented exception 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.

Copy link
Copy Markdown

@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 adds the backBufferDurationMs option to VideoPlayerOptions to configure the ExoPlayer back buffer duration on Android, updating the platform interface, Android implementation, and adding no-op stubs for AVFoundation and Web. Feedback on the changes highlights that passing backBufferDurationMs via a global setter on Android can cause state persistence and race conditions during concurrent player initialization, and recommends passing this option directly through CreationOptions instead.

Comment thread packages/video_player/video_player/lib/video_player.dart Outdated
@sailendrabathi sailendrabathi force-pushed the improve_seek_performance branch from b94d8e4 to 624afd5 Compare May 31, 2026 07:54
@sailendrabathi sailendrabathi marked this pull request as draft May 31, 2026 08:09
@sailendrabathi sailendrabathi force-pushed the improve_seek_performance branch from 624afd5 to b75044f Compare May 31, 2026 08:53
@sailendrabathi sailendrabathi marked this pull request as ready for review May 31, 2026 08:53
Copy link
Copy Markdown

@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 adds support for configuring ExoPlayer's back buffer duration on Android by introducing backBufferDurationMs to VideoPlayerOptions and forwarding it through the platform interface to the Android implementation. The Android plugin updates PlatformViewVideoPlayer and TextureVideoPlayer to configure ExoPlayer's DefaultLoadControl using this value, supported by new unit tests. Feedback suggests correcting an inaccurate comment regarding how backBufferDurationMs is passed and adding an assertion to ensure the duration is positive if provided.

Comment thread packages/video_player/video_player/lib/video_player.dart Outdated
@sailendrabathi sailendrabathi force-pushed the improve_seek_performance branch 2 times, most recently from 54e8d1e to 2f8c779 Compare May 31, 2026 09:25
@stuartmorgan-g stuartmorgan-g added the triage-android Should be looked at in Android triage label Jun 2, 2026
@stuartmorgan-g stuartmorgan-g requested a review from mboetger June 2, 2026 18:27
Adds `backBufferDurationMs` to `VideoPlayerOptions` and configures ExoPlayer's `DefaultLoadControl` to retain the back buffer from keyframes. This significantly improves seek performance and responsiveness during video playback on Android.
@sailendrabathi sailendrabathi force-pushed the improve_seek_performance branch from 2f8c779 to 178a8e1 Compare June 5, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: video_player platform-android triage-android Should be looked at in Android triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants