Repository navigation
[video_player] Add forwardBufferDurationMs option - #11950
mhmdfathy96 wants to merge 5 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request adds support for a new forwardBufferDuration option to VideoPlayerOptions and VideoCreationOptions across the video_player packages, allowing users to cap network buffering. The implementation spans the platform interface, Android (ExoPlayer), and iOS/macOS (AVFoundation) implementations, along with corresponding tests. Feedback suggests adding non-negative assertions to the Dart constructors, clamping the duration on Android to prevent integer overflow, and clamping it on iOS/macOS to prevent potential crashes from negative values.
|
Thanks for the review! Addressed in bdc6655:
|
bdc6655 to
fd7120c
Compare
|
Thank you for your contribution! Because of the volume of PRs we receive, we require that new contributors use our checklist to guide them through critical steps in creating a Flutter PR. This PR's description is missing that checklist, so it is being marked as a Draft. Please edit the PR description to add the checklist, then ensure that you have completed all of the steps. Once you've done that, please mark the PR as ready for review. If you need help, consider asking for advice on the #hackers-new channel on Discord.
Please make sure in particular to read the AI contribution guidelines carefully. Thanking a clearly labeled bot for doing a review suggests there is not a human in the loop on this response. |
|
Please note that a pr regarding buffer size (back buffer) is likely landing soon. #11810 |
|
Greetings from stale PR triage! 👋 |
|
Still on my radar, yes — sorry for the long silence. Where I'm picking it up: tarrinneal — thanks for the heads-up about #11810; it landed while I was away. I'll rebase on top of it and match it: stuartmorgan-g — I'll restore the repo's PR template and complete the checklist properly before taking this out of draft. |
fd7120c to
4513e4c
Compare
39469c4 to
4db13a4
Compare
|
Rebased onto current Changes since the last review:
This PR is now 4 files: the option, its tests, the CHANGELOG entry and the version bump. |
There was a problem hiding this comment.
Code Review
This pull request adds a new forwardBufferDurationMs option to VideoPlayerOptions in the video_player_platform_interface package to support capping the forward buffer duration. It includes assertions to ensure the value is non-negative, updates the package version to 6.10.0 along with the changelog, and adds unit tests to verify the new option's behavior. There are no review comments, so no additional feedback is provided.
|
Please do not |
Please re-read the contribution guide section concerning changing federated plugins. We will not review or land individual sub-PRs until the combination PR has been reviewed and approved by all relevant reviewers. Converting to a draft until this is once again a combination PR that can be reviewed. Once it's ready according to our documented process, please mark it as ready for review. |
Adds an optional `forwardBufferDurationMs` to `VideoPlayerOptions`, allowing apps to cap how far ahead of the playback position streamed media is buffered. This mirrors the existing `backBufferDurationMs` option added in flutter#11932, including its non-negative assertion and documentation style. When null or zero, the platform's default buffering behavior is used, so existing behavior is unchanged. Part 1 of 4. Platform implementations follow once this is published. Fixes flutter/flutter#40931 Fixes flutter/flutter#141511
Implements `VideoPlayerOptions.forwardBufferDurationMs` by configuring ExoPlayer's `DefaultLoadControl`, following the back buffer implementation added in flutter#12124. The back buffer and forward buffer options now share a single `VideoPlayer.buildLoadControl` helper, replacing the duplicated load control setup in `TextureVideoPlayer` and `PlatformViewVideoPlayer`. The forward cap uses `setBufferDurationsMsForStreaming`, so local files and assets keep ExoPlayer's defaults. Playback start thresholds are clamped to the cap, since `DefaultLoadControl` requires them to be no larger than the buffer size. Part 2 of 4.
Implements `VideoPlayerOptions.forwardBufferDurationMs` by setting `AVPlayerItem.preferredForwardBufferDuration`. `preferredForwardBufferDuration` is exposed through the `FVPAVPlayerItem` protocol so it can be verified in unit tests. A value of 0 is AVPlayer's "automatic" default, so passing 0 matches leaving the option unset. Negative values are rejected. Part 3 of 4.
Updates the platform implementation constraints to versions that support `VideoPlayerOptions.forwardBufferDurationMs`, exposing the option to apps. `VideoPlayerOptions` is re-exported by this package, so the new field is part of its public API; no other code change is required, as the options object is already forwarded to the platform via `VideoCreationOptions`. This follows the same sequencing the back buffer option used: flutter#11932 (platform interface), flutter#12124 (Android), then flutter#11810 (app-facing). Part 4 of 4.
FOR TESTING AND INITIAL REVIEW ONLY. These overrides are removed as each package is split out and published, per the federated plugin change process.
4db13a4 to
2420716
Compare
|
Restored this as the combination PR: all four packages, with path-based dependency overrides from make-deps-path-based. The expected failures are the checks that reject those overrides (including video_player_web, which only carries an override). I'll split out the platform interface and implementation PRs once this is approved. |
There was a problem hiding this comment.
Code Review
This pull request adds the forwardBufferDurationMs option to VideoPlayerOptions to limit the forward buffer duration for streamed media. The option is implemented for Android using ExoPlayer's LoadControl and for iOS/macOS using AVPlayerItem.preferredForwardBufferDuration. The changes span the platform interface, the main player package, and the Android and AVFoundation platform implementations, accompanied by corresponding unit tests and Pigeon integration updates. No review comments were provided, so there is no feedback to address.
Adds an optional
forwardBufferDurationMstoVideoPlayerOptions, allowing apps to cap how far ahead of the playback position streamed media is buffered.Without a cap, players read a long way ahead (ExoPlayer's default target is around 50 seconds, and
AVPlayermay fetch a large portion of the file), which wastes user bandwidth when someone seeks away from or abandons playback.The option mirrors the existing
backBufferDurationMsfrom #11932: the sameint?type with anMssuffix, the same non-negative assertion, and the same doc comment shape. When null or zero, the platform's default buffering behavior is used, so existing behavior is unchanged.This is the combination PR for the federated change, following Changing federated plugins. It contains all four package changes plus temporary path-based dependency overrides added with
make-deps-path-based:video_player_platform_interface6.10.0: adds the option toVideoPlayerOptionsvideo_player_android2.13.0: caps ExoPlayer'sDefaultLoadControlviasetBufferDurationsMsForStreaming, so local playback is unaffectedvideo_player_avfoundation2.13.0: setsAVPlayerItem.preferredForwardBufferDurationvideo_player2.15.0: raises the implementation constraints to expose the optionThe expected CI failures are the checks that reject the temporary overrides, including
video_player_web, which carries an override but no code change. Once this is approved, I will split out the platform interface and implementation PRs and then remove the overrides here.Fixes flutter/flutter#40931
Fixes flutter/flutter#141511
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot 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.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2