[video_player_avfoundation] Add adaptive bitrate streaming support#11324
[video_player_avfoundation] Add adaptive bitrate streaming support#11324sheershtehri7 wants to merge 1 commit intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for adaptive bitrate streaming on iOS and macOS by implementing the setBandwidthLimit method. This is achieved by setting the preferredPeakBitRate property on AVPlayerItem. The changes include updates to the Pigeon interface definition, the native Objective-C implementation, the Dart plugin code, and associated tests. One review comment has been added regarding error handling in the native implementation.
| - (void)setBandwidthLimit:(NSInteger)maxBandwidthBps | ||
| error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { | ||
| AVPlayerItem *currentItem = _player.currentItem; | ||
| NSAssert(currentItem, @"currentItem should not be nil"); |
There was a problem hiding this comment.
Using NSAssert is great for debugging, but it's disabled in release builds. If currentItem is nil in a release build, this method will silently do nothing, which could lead to unexpected behavior. It would be more robust to check for a nil currentItem and return an error, ensuring consistent behavior across build configurations.
if (!currentItem) {
*error = [FlutterError errorWithCode:@"no_player_item"
message:@"The player has no current item."
details:nil];
return;
}Implements setBandwidthLimit via AVPlayerItem.preferredPeakBitRate. A value of 0 removes the bandwidth cap, letting AVFoundation select quality freely. Positive values limit the peak bitrate in bps. Requires video_player_platform_interface ^6.7.0. Part of flutter/flutter#183941
676ffab to
8652d37
Compare
|
Closing per #11322 (comment) |
Implements adaptive bitrate streaming support for the iOS/macOS video player.
Changes
setBandwidthLimit— Implements the platform interface method viaAVPlayerItem.preferredPeakBitRate. A value of0tells AVFoundation to use its default (no cap), letting the player choose quality freely. Positive values limit the peak bitrate in bits per second.This is the idiomatic AVFoundation approach —
preferredPeakBitRateis a first-class property onAVPlayerItemthat controls which HLS/DASH variant the player selects.Versioned as 2.10.0 — minor version bump. Requires
video_player_platform_interface ^6.7.0.Depends on PR #11322 (platform interface
setBandwidthLimit).Part of flutter/flutter#183941
AI Disclosure: This PR was developed with assistance from AI tools (GitHub Copilot / Claude). All code has been reviewed, tested, and validated by the author.
Pre-Review Checklist
[shared_preferences]///).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