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..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 @@ -472,7 +472,11 @@ class VideoPlayerOptions { this.allowBackgroundPlayback = false, this.preventsDisplaySleepDuringVideoPlayback = true, this.webOptions, - }); + this.backBufferDurationMs, + }) : assert( + 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. /// The default value is false. @@ -494,6 +498,12 @@ class VideoPlayerOptions { /// Additional web controls 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; } /// [VideoPlayerWebOptions] can be optionally used to set additional web settings @@ -593,13 +603,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/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 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); + }); }