-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(video_player): add audio track management support to platform interface #10171
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?
feat(video_player): add audio track management support to platform interface #10171
Conversation
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
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 audio track management capabilities to the video_player
platform interface. It adds a new VideoAudioTrack
model to represent audio track metadata, and new methods getAudioTracks()
, selectAudioTrack()
, and isAudioTrackSupportAvailable()
to the VideoPlayerPlatform
abstract class. The changes are well-structured and additive. My review includes a suggestion to add tests for the new platform interface methods and a minor improvement to the changelog entry for completeness.
packages/video_player/video_player_platform_interface/CHANGELOG.md
Outdated
Show resolved
Hide resolved
/// Gets the available audio tracks for the video. | ||
Future<List<VideoAudioTrack>> getAudioTracks(int playerId) { | ||
throw UnimplementedError('getAudioTracks() has not been implemented.'); | ||
} | ||
|
||
/// Selects an audio track by its ID. | ||
Future<void> selectAudioTrack(int playerId, String trackId) { | ||
throw UnimplementedError('selectAudioTrack() has not been implemented.'); | ||
} | ||
|
||
/// Returns whether audio track selection is supported on this platform. | ||
/// | ||
/// This method allows developers to query at runtime whether the current | ||
/// platform supports audio track selection functionality. This is useful | ||
/// for platforms like web where audio track selection may not be available. | ||
/// | ||
/// Returns `true` if [getAudioTracks] and [selectAudioTrack] are supported, | ||
/// `false` otherwise. | ||
Future<bool> isAudioTrackSupportAvailable() { | ||
throw UnimplementedError( | ||
'isAudioTrackSupportAvailable() has not been implemented.', | ||
); | ||
} |
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.
These new methods are correctly defined with default UnimplementedError
implementations. However, the corresponding tests are missing in test/video_player_platform_interface_test.dart
. Please add tests to verify that calling these methods on the default VideoPlayerPlatform
instance throws an UnimplementedError
, similar to existing tests in that file. This is important for maintaining test coverage and ensuring platform implementations correctly override them.
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.
These tests are still missing from the PR.
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.
Gemini's comments are good this time. Would implement them.
…G.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…eshmbhat/flutter_packages into 4-oct-video-player-interface-updates
have updated PR as per gemini's suggestions @tarrinneal |
final String label; | ||
|
||
/// Language code of the audio track (e.g., 'en', 'es', 'und'). | ||
final String language; |
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.
Why is this non-nullable if we already know that every implementation so far can return a null value for this?
We generally do not want the platform interface to force implementations to throw away information (like whether the SDK returned null or actually returned the string "und"). If we want to normalize what plugin clients see, we should do that once at the app-facing package level, not hard-code it into every implementation.
final String id; | ||
|
||
/// Human-readable label for the track. | ||
final String label; |
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.
Same question here as for language
; this can be null for at least ExoPlayer; why force that information to be discarded at this layer?
} | ||
|
||
/// Gets the available audio tracks for the video. | ||
Future<List<VideoAudioTrack>> getAudioTracks(int playerId) { |
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.
There needs to be a method to let the app-facing package know whether it's safe to call audio track methods. https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#api-support-queries
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.
This method is already there isn't it?
It's called isAudioTrackSupportAvailable
/// Gets the available audio tracks for the video. | ||
Future<List<VideoAudioTrack>> getAudioTracks(int playerId) { | ||
throw UnimplementedError('getAudioTracks() has not been implemented.'); | ||
} | ||
|
||
/// Selects an audio track by its ID. | ||
Future<void> selectAudioTrack(int playerId, String trackId) { | ||
throw UnimplementedError('selectAudioTrack() has not been implemented.'); | ||
} | ||
|
||
/// Returns whether audio track selection is supported on this platform. | ||
/// | ||
/// This method allows developers to query at runtime whether the current | ||
/// platform supports audio track selection functionality. This is useful | ||
/// for platforms like web where audio track selection may not be available. | ||
/// | ||
/// Returns `true` if [getAudioTracks] and [selectAudioTrack] are supported, | ||
/// `false` otherwise. | ||
Future<bool> isAudioTrackSupportAvailable() { | ||
throw UnimplementedError( | ||
'isAudioTrackSupportAvailable() has not been implemented.', | ||
); | ||
} |
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.
These tests are still missing from the PR.
Description
platform interface pr for #9925
Core Features
VideoAudioTrack
model with comprehensive metadata fields:id
,label
,language
,isSelected
,bitrate
,sampleRate
,channelCount
,codec
Breaking Changes
None - all changes are additive and backward compatible.
Pre-Review Checklist
[video_player]
pubspec.yaml
with 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.md
to 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].///
).