-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(video_player_platform_interface): refactor audio track API to use track objects #10378
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
feat(video_player_platform_interface): refactor audio track API to use track objects #10378
Conversation
…oPlayer async updates
… fix format builders
fix(ios): fixed tests
19 sept pr review changes
feat(video_player): add platform check for audio track selection support
- Added new data classes for audio track management (PlaybackState, AudioTrackMessage, ExoPlayerAudioTrackData, NativeAudioTrackData) - Implemented getAudioTracks() and selectAudioTrack() methods in VideoPlayerInstanceApi - Fixed Map comparison in deepEquals to use containsKey instead of contains - Added message codec handling for new audio track data classes - Updated Android video player implementation to support audio track selection
- Updated video_player_platform_interface dependency from ^6.3.0 to ^6.6.0 across all video_player packages - Removed temporary dependency_overrides for video_player_platform_interface that were used for testing - Reformatted dependency override paths for better readability in remaining overrides
- Reduced sample video URLs from 3 to 2 by removing redundant examples - Changed primary video source to flutter.github.io butterfly video for better reliability - Simplified audio track data construction in Android native code by using direct constructor instead of builder pattern - Fixed code formatting and line wrapping in audio tracks demo UI - Removed unnecessary builder pattern usage in NativeAudioTrackData creation
- Removed fully qualified class names (Messages.ExoPlayerAudioTrackData) in favor of direct class names for better readability - Updated getter method name from getIsSelected() to isSelected() to follow Java boolean getter conventions - Maintained same test coverage and assertions while making code more concise - No functional changes to the test behavior or validation logic
- Upgraded video_player_platform_interface dependency from ^6.4.0 to ^6.6.0 in video_player_web package - Maintains compatibility with web platform support while incorporating latest interface updates
…he code formatting changes: style(video_player): improve code formatting and line wrapping - Fixed line wrapping and indentation in audio_tracks_demo.dart for better readability - Simplified import statements and removed fully qualified class names in AudioTracksTest.java - Improved code formatting and line breaks in avfoundation_video_player files - Adjusted indentation and line breaks in example files to follow consistent style
feat(video): improve audio track selection handling - Removed manual delay for Android track selection and implemented event-based completion tracking - Added AudioTrackChangedEvent to notify when selected audio track changes - Enhanced ExoPlayerEventListener to detect and report audio track changes - Added timeout handling for audio track selection to prevent indefinite waits - Updated message codecs and interfaces to support new audio track change
- Added caching for audio selection options to avoid repeated media group queries - Simplified current audio track selection by using direct item method - Optimized selectAudioTrack to use cached options instead of re-fetching media group - Added cleanup of cached options in dispose method to prevent memory leaks
- Simplified mock format descriptions in VideoPlayerTests to prevent Core Media crashes - Removed unnecessary mock format description setup that could cause test instability - Updated format description validation to only accept genuine Core Media objects, removing NSObject fallback - Fixed potential crash when accessing format descriptions in test environment
…S compatibility - Added macOS 10.13 availability check alongside iOS 11.0 - Updated to use currentMediaSelection property instead of deprecated selectedMediaOptionInMediaSelectionGroup method
- Changed VideoAudioTrack to use groupIndex and trackIndex instead of a single string ID
- Updated selectAudioTrack to accept VideoAudioTrack object instead of string trackId
- Modified UI to display track indices in format "Track {groupIndex}_{trackIndex}"
…ect instead of ID - Modified selectAudioTrack to accept VideoAudioTrack object instead of string trackId - Replaced single id field with groupIndex and trackIndex integers in VideoAudioTrack - Updated equality, hashCode, and toString methods to reflect new track identification structure
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 refactors the audio track API for the video_player_platform_interface package. It introduces a VideoAudioTrack class that uses groupIndex and trackIndex integers for track identification, replacing the previous string-based ID. The selectAudioTrack method is updated to accept a VideoAudioTrack object, improving type safety. This is a breaking change, reflected by a major version bump to 7.0.0. The CHANGELOG.md and tests have been updated accordingly.
| ## 7.0.0 | ||
|
|
||
| * **BREAKING CHANGE**: Refactors audio track identification system: | ||
| * `VideoAudioTrack.id` (String) replaced with separate `groupIndex` (int) and `trackIndex` (int) properties. | ||
| * `selectAudioTrack(int playerId, String trackId)` changed to `selectAudioTrack(int playerId, VideoAudioTrack track)` - now accepts the full track object instead of separate parameters. | ||
| * This change provides better type safety and a more intuitive API for audio track selection. | ||
|
|
||
| ## 6.6.0 | ||
|
|
||
| * Adds `VideoAudioTrack` class and `getAudioTracks()`, `selectAudioTrack()`, `isAudioTrackSupportAvailable()` methods for audio track management. |
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.
The current changelog is a bit confusing as it introduces a feature in a 6.6.0 entry and then immediately describes a breaking refactor of it in the 7.0.0 entry. Assuming 6.6.0 was not released, it would be clearer to combine these into a single entry for 7.0.0 that describes the audio track selection feature as it is being introduced in its final form. This will provide better clarity for users reading the release notes.
| ## 7.0.0 | |
| * **BREAKING CHANGE**: Refactors audio track identification system: | |
| * `VideoAudioTrack.id` (String) replaced with separate `groupIndex` (int) and `trackIndex` (int) properties. | |
| * `selectAudioTrack(int playerId, String trackId)` changed to `selectAudioTrack(int playerId, VideoAudioTrack track)` - now accepts the full track object instead of separate parameters. | |
| * This change provides better type safety and a more intuitive API for audio track selection. | |
| ## 6.6.0 | |
| * Adds `VideoAudioTrack` class and `getAudioTracks()`, `selectAudioTrack()`, `isAudioTrackSupportAvailable()` methods for audio track management. | |
| ## 7.0.0 | |
| * **BREAKING CHANGE**: Adds support for audio track selection. | |
| * Adds the `VideoAudioTrack` class, `getAudioTracks()`, `selectAudioTrack()`, and `isAudioTrackSupportAvailable()` methods for audio track management. | |
| * `VideoAudioTrack` uses `groupIndex` and `trackIndex` integers for identification. | |
| * `selectAudioTrack` accepts a `VideoAudioTrack` object for improved type safety. |
feat(video_player_platform_interface): refactor audio track API to use track objects
Summary
Refactors the audio track identification and selection API to use separate
groupIndexandtrackIndexintegers instead of encoded string IDs, and updates selectAudioTrack to accept aVideoAudioTrackobject for improved type safety and developer experience.Breaking Changes
Version: 7.0.0 (major version bump)
1. VideoAudioTrack Structure Change
Before:
Motivation :
The previous string-based track ID system had several issues:
Lack of Type Safety: String encoding/decoding of track indices was error-prone
Poor Developer Experience: Required developers to manually construct or parse track IDs
Platform Inconsistency: Different platforms (ExoPlayer vs AVFoundation) handle track groups differently, but this was hidden in string encoding
Unintuitive API: Users had to remember the format and construction of track IDs
Interface Breakout PR From : #9925
Pre-Review Checklist
[shared_preferences]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].///).