Commit 3a5e9a8
authored
[video_player] Adds audio track metadata fetching and audio track selection feature (#9925)
## 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:
1. Platform interface : #10171
2. Andrioid : #10312
3. ios : #10313
### Changes Made
#### 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
- **Updated `VideoPlayerController`** to expose audio track functionality
#### Platform Implementations
- **Android**:
- Real metadata extraction using ExoPlayer's `getCurrentTracks()` API
- Robust track selection using `TrackSelectionOverride` with proper error handling
- Support for multiple audio formats (AAC, AC3, EAC3, MP3, etc.)
- **iOS**:
- Metadata extraction from AVFoundation using `AVAssetTrack` for regular videos
- HLS stream support using `AVMediaSelectionGroup` for adaptive streams
- Proper track selection for both asset tracks and media selection options
#### Technical Infrastructure
- **Updated Pigeon interfaces** for both Android and iOS with new data structures:
- `AudioTrackMessage`, `ExoPlayerAudioTrackData`, `AssetAudioTrackData`, `MediaSelectionAudioTrackData`, `NativeAudioTrackData`
- **Enhanced platform interface** with new methods and data classes
- **Has native unit tests** for both Android and iOS platforms
- **Created demo screen** showcasing audio track functionality with interactive UI
### Demo Features
- Interactive video player with audio track selection
- Real-time metadata display (bitrate, sample rate, channels, codec)
- Support for multiple video sources including HLS streams
- Visual indicators for currently selected tracks
## Related Issues
Fixes flutter/flutter#59437
### Testing
- Added native unit tests for both Android and iOS
- Tested with various video formats and HLS streams
- Verified backward compatibility with existing functionality
- Demo screen widget for manual testing and validation
### Breaking Changes
None - all changes are additive and backward compatible.
## Pre-Review Checklist1 parent 5805a10 commit 3a5e9a8
File tree
7 files changed
+916
-54
lines changed- packages/video_player/video_player
- example
- ios/Runner.xcodeproj
- lib
- lib
- test
7 files changed
+916
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
242 | 259 | | |
243 | 260 | | |
244 | 261 | | |
| |||
0 commit comments