From 7b03d112cb9b4b07d086b81a967044e31617a630 Mon Sep 17 00:00:00 2001 From: Sailendra Bathi Date: Thu, 18 Jun 2026 10:45:14 +0000 Subject: [PATCH 1/3] [video_player_platform_interface] Add backBufferDurationMs to VideoPlayerOptions --- .../CHANGELOG.md | 4 ++++ .../lib/video_player_platform_interface.dart | 18 ++++++++++++++++-- .../test/video_player_options_test.dart | 8 ++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index a5fa13cea706..c2ac93a85cfb 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.9.0 + +* Adds `backBufferDurationMs` to `VideoPlayerOptions` to support configuring ExoPlayer back buffer duration on Android. + ## 6.8.0 * Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index 2079ef4af34f..b971aa9b7109 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -472,7 +472,11 @@ class VideoPlayerOptions { this.allowBackgroundPlayback = false, this.preventsDisplaySleepDuringVideoPlayback = true, this.webOptions, - }); + this.backBufferDurationMs, + }) : assert( + backBufferDurationMs == null || backBufferDurationMs > 0, + 'backBufferDurationMs must be greater than zero', + ); /// Set this to true to keep playing video in background, when app goes in background. /// The default value is false. @@ -494,6 +498,9 @@ class VideoPlayerOptions { /// Additional web controls final VideoPlayerWebOptions? webOptions; + + /// ** Android only **. Sets ExoPlayer's back buffer duration in milliseconds. + final int? backBufferDurationMs; } /// [VideoPlayerWebOptions] can be optionally used to set additional web settings @@ -593,13 +600,20 @@ class VideoViewOptions { @immutable class VideoCreationOptions { /// Constructs an instance of [VideoCreationOptions]. - const VideoCreationOptions({required this.dataSource, required this.viewType}); + const VideoCreationOptions({ + required this.dataSource, + required this.viewType, + this.videoPlayerOptions, + }); /// The data source used to create the player. final DataSource dataSource; /// The type of view to be used for displaying the video player final VideoViewType viewType; + + /// Additional configuration options for the video player. + final VideoPlayerOptions? videoPlayerOptions; } /// Represents an audio track in a video with its metadata. diff --git a/packages/video_player/video_player_platform_interface/test/video_player_options_test.dart b/packages/video_player/video_player_platform_interface/test/video_player_options_test.dart index a2969c67db0f..91e4d8fdb062 100644 --- a/packages/video_player/video_player_platform_interface/test/video_player_options_test.dart +++ b/packages/video_player/video_player_platform_interface/test/video_player_options_test.dart @@ -18,4 +18,12 @@ void main() { final options = VideoPlayerOptions(); expect(options.preventsDisplaySleepDuringVideoPlayback, true); }); + test('VideoPlayerOptions backBufferDurationMs defaults to null', () { + final options = VideoPlayerOptions(); + expect(options.backBufferDurationMs, null); + }); + test('VideoPlayerOptions backBufferDurationMs stores configured value', () { + final options = VideoPlayerOptions(backBufferDurationMs: 20000); + expect(options.backBufferDurationMs, 20000); + }); } From 781181634e75621d9c9f30f0bcea9b76de408fc8 Mon Sep 17 00:00:00 2001 From: Sailendra Bathi Date: Fri, 26 Jun 2026 18:08:23 +0000 Subject: [PATCH 2/3] re-break out from the combined PR after sync to main --- .../lib/video_player_platform_interface.dart | 3 +++ .../video_player/video_player_platform_interface/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index b971aa9b7109..85a386963bd0 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -500,6 +500,9 @@ class VideoPlayerOptions { final VideoPlayerWebOptions? webOptions; /// ** Android only **. Sets ExoPlayer's back buffer duration in milliseconds. + /// + /// This is not possible on iOS because AVPlayer does not provide a way to + /// configure the back buffer duration. final int? backBufferDurationMs; } diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index c8d03f31704d..4e113a877e2b 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/video_player/ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 6.8.0 +version: 6.9.0 environment: sdk: ^3.10.0 From d55829f3e7ef81a3f60c0680cdb9b5f27dfbe4de Mon Sep 17 00:00:00 2001 From: sailendrabathi <44525804+sailendrabathi@users.noreply.github.com> Date: Tue, 30 Jun 2026 14:09:37 +0530 Subject: [PATCH 3/3] Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../lib/video_player_platform_interface.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index 85a386963bd0..58b3acb35b42 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -474,8 +474,8 @@ class VideoPlayerOptions { this.webOptions, this.backBufferDurationMs, }) : assert( - backBufferDurationMs == null || backBufferDurationMs > 0, - 'backBufferDurationMs must be greater than zero', + backBufferDurationMs == null || backBufferDurationMs >= 0, + 'backBufferDurationMs must be zero or greater', ); /// Set this to true to keep playing video in background, when app goes in background.