-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[video_player] Adds audio track metadata fetching and audio track selection feature #9925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 introduces a valuable feature for fetching and selecting audio tracks in the video_player package. The changes are comprehensive, touching the platform interface, Android (ExoPlayer) and iOS (AVFoundation) implementations, and adding a new demo screen.
My review has identified several critical and high-severity issues that should be addressed:
- The new native unit tests for both Android and iOS appear to be broken due to type mismatches and incorrect method calls, and will not compile in their current state.
- The Dart implementation code for both Android and iOS contains unsafe null assertions on data coming from the native side, which could lead to runtime crashes.
- The Android implementation has been updated to use a milestone version of Gradle, which is not recommended for production packages.
- The new audio track selection feature has not been implemented for the web platform, which will lead to
UnimplementedErroron web. - There is a minor issue in the new example app where
contextis used after anawaitwithout checking if the widget is still mounted.
Addressing these points will significantly improve the robustness and completeness of this new feature.
...deo_player_android/android/src/test/java/io/flutter/plugins/videoplayer/AudioTracksTest.java
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_avfoundation/darwin/RunnerTests/AudioTracksTests.m
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_android/android/gradle/wrapper/gradle-wrapper.properties
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_android/lib/src/android_video_player.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart
Outdated
Show resolved
Hide resolved
…oPlayer async updates
… fix format builders
|
I updated native andorid tests and ran the tests and verified that all native android tests are passing. |
fix(ios): fixed tests
|
@stuartmorgan-g @ash2moon can you please comment on this PR and lemme know if there are any concerns ? |
…S compatibility - Added macOS 10.13 availability check alongside iOS 11.0 - Updated to use currentMediaSelection property instead of deprecated selectedMediaOptionInMediaSelectionGroup method
…o separate indices - Replaced concatenated string trackId with separate groupIndex and trackIndex parameters in Android implementation - Updated iOS/macOS to use trackType and numeric trackId instead of prefixed string format - Modified Pigeon message definitions and generated code to support new parameter structure
|
Have addressed all the major concerns in this PR , can we please have the platform PRs merged ? If any furthur changes are needed, pls let me know at the earliest so that i can quickly push the changes and we can take this forward sooner. |
I'm not sure why you are pinging people here. This PR can't land until the sub-PRs have landed, and the sub PRs are still under review. Those PRs will be landed when they have been reviewed and approved. |
| /// Throws an exception if the video player is disposed. | ||
| Future<List<VideoAudioTrack>> getAudioTracks() async { | ||
| if (_isDisposed) { | ||
| throw Exception('VideoPlayerController is disposed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be throwing an exception if the video is already disposed ? or should be just return like how its just returned in many of the other methods ?
…andling and remove redundant tests - Replace try-catch with explicit bounds checking in selectAudioTrack method - Add separate validation for groupIndex and trackIndex bounds - Improve error messages to distinguish between different validation failures - Remove AudioTracksTest.java as tests are now covered in VideoPlayerTest.java - Add comprehensive test coverage for audio track selection edge cases
Cherry-picked from upstream PR flutter#9925: - Add getAudioTracks() to VideoPlayerController - Add selectAudioTrack() to VideoPlayerController - Add isAudioTrackSupportAvailable() for feature detection - Export VideoAudioTrack from platform interface - Bump version to 2.10.0 This provides the public API that users call to: 1. Check if audio track selection is supported 2. Get list of available audio tracks with metadata 3. Select a specific audio track by ID Source: flutter#9925
- Implemented getAudioTracks() and selectAudioTrack() methods for Android video player Android PR for : #9925 ## Pre-Review Checklist
|
@nateshmbhat I'll take a look at the Android changes again once you port them over from the split out PR. Thanks! |
|
@camsim99 i have ported the android changes. |
Description
This PR adds comprehensive audio track retrieval and selection support to the video_player package, enabling developers to access detailed information about available audio tracks and switch between them during playback.
Breakout PRs:
Changes Made
Core Features
VideoAudioTrackmodel with comprehensive metadata fields:id,label,language,isSelected,bitrate,sampleRate,channelCount,codecVideoPlayerControllerto expose audio track functionalityPlatform Implementations
getCurrentTracks()APITrackSelectionOverridewith proper error handlingAVAssetTrackfor regular videosAVMediaSelectionGroupfor adaptive streamsTechnical Infrastructure
AudioTrackMessage,ExoPlayerAudioTrackData,AssetAudioTrackData,MediaSelectionAudioTrackData,NativeAudioTrackDataDemo Features
Related Issues
#59437 - Add audio track metadata support to video_player
Testing
Breaking Changes
None - all changes are additive and backward compatible.
Pre-Review Checklist
[video_player]pubspec.yamlwith an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].CHANGELOG.mdto add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].///).