Skip to content

Conversation

nateshmbhat
Copy link

Description

platform interface pr for #9925

Core Features

  • Added VideoAudioTrack model with comprehensive metadata fields: id, label, language, isSelected, bitrate, sampleRate, channelCount, codec
  • Added getAudioTracks() method to retrieve all available audio tracks with real metadata
  • Added selectAudioTrack() method to switch between audio tracks during playback

Breaking Changes

None - all changes are additive and backward compatible.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [video_player]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated 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].
  • I updated 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].
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +125 to +147
/// 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.',
);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Collaborator

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.

Copy link
Contributor

@tarrinneal tarrinneal left a 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.

nateshmbhat and others added 4 commits October 13, 2025 13:32
…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
@nateshmbhat
Copy link
Author

nateshmbhat commented Oct 13, 2025

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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) {
Copy link
Collaborator

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

Copy link
Author

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

Comment on lines +125 to +147
/// 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.',
);
}
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants