Skip to content

Commit 3a5e9a8

Browse files
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 Checklist
1 parent 5805a10 commit 3a5e9a8

File tree

7 files changed

+916
-54
lines changed

7 files changed

+916
-54
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 2.11.0
22

3-
* Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.
3+
* Adds `getAudioTracks()` and `selectAudioTrack()` methods to retrieve and select available audio tracks.
4+
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.
45
* Updates README to reflect currently supported OS versions for the latest
56
versions of the endorsed platform implementations.
67
* Applications built with older versions of Flutter will continue to

packages/video_player/video_player/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,23 @@
239239
shellPath = /bin/sh;
240240
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
241241
};
242+
40E43985C26639614BC3B419 /* [CP] Embed Pods Frameworks */ = {
243+
isa = PBXShellScriptBuildPhase;
244+
buildActionMask = 2147483647;
245+
files = (
246+
);
247+
inputFileListPaths = (
248+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
249+
);
250+
name = "[CP] Embed Pods Frameworks";
251+
outputFileListPaths = (
252+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
253+
);
254+
runOnlyForDeploymentPostprocessing = 0;
255+
shellPath = /bin/sh;
256+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
257+
showEnvVarsInLog = 0;
258+
};
242259
9740EEB61CF901F6004384FC /* Run Script */ = {
243260
isa = PBXShellScriptBuildPhase;
244261
alwaysOutOfDate = 1;

0 commit comments

Comments
 (0)