[video_player] : Add video track selection support for Android and iOS#10688
[video_player] : Add video track selection support for Android and iOS#10688nateshmbhat wants to merge 132 commits intoflutter:mainfrom
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
camsim99
left a comment
There was a problem hiding this comment.
Android overall LGTM just have one question about how we force a video player re-render after selecting a new track.
...r/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java
Outdated
Show resolved
Hide resolved
| // position (e.g., top-left corner) or the old surface remains partially visible. | ||
| // By disabling the video track type, we force ExoPlayer to completely release the | ||
| // current renderer and decoder, ensuring a clean slate for the new resolution. | ||
| if (dimensionsChanged) { |
There was a problem hiding this comment.
This disabling/re-enabling hack make sense thanks to your explanation. However, I just want to make sure there's no more direct way to force a re-render. Is there some documentation that we can point to as to why we are handling it this way?
There was a problem hiding this comment.
updated with relevant details
There was a problem hiding this comment.
Those links don't clearly state why we need this approach. I did a little digging and found this Exoplayer issue that does seem relevant though: androidx/media#1631. My read on those issues is that the seamless changing of tracks with different formats is currently not supported and their suggested workaround is to disallow that, but please correct me if I'm wrong.
Unless we can find evidence for this solution of disabling/re-enabling the video track type with a delay being reliable, I would suggest that we move in that direction versus implementing a hack. For now, then, we could file an issue for supporting this in the future and follow up in the Exoplayer bug.
There was a problem hiding this comment.
The thing is, during my testing I was actually facing the visual glitches and that's why I had implement this approach after digging around for solutions.
There was a problem hiding this comment.
I think instead of landing this initially with a hack to support this on Android, we should not allow the switching of media formats for now and file an issue to follow up on that. Then a fix for the issue could potentially land as a follow up PR. I'm open to pushback, but I think we should invest in finding a reliable solution for this issue if possible. We can follow up in the ExoPlayer bug I linked, too.
There was a problem hiding this comment.
@nateshmbhat Thanks for the explanation! Ultimately, your logic as to keeping the workaround in makes sense to me and I'm okay moving forward.
If you don't mind, can you file an issue for the todo and link it here?
There was a problem hiding this comment.
done , added here flutter/flutter#183824
There was a problem hiding this comment.
Thank you! And sorry for being unclear but can you link it in the todo?
…or handling - Added a new method `enableAutoVideoQuality` to replace the previous method of selecting video tracks with -1 indices for auto quality. - Updated the Android implementation to utilize this new method, enhancing clarity and maintainability. - Introduced helper methods in `VideoPlayer.java` to streamline the extraction of format values, improving code readability. - Adjusted test cases to reflect the new method naming and functionality. - Cleaned up imports and formatting across various files for consistency.
|
@tarrinneal I believe this still needs your review for the cross-platform parts. |
tarrinneal
left a comment
There was a problem hiding this comment.
Seems like the non-platform code is pretty solid. I didn't review the platform code in depth, but I didn't see anything glaringly wrong there either.
| // position (e.g., top-left corner) or the old surface remains partially visible. | ||
| // By disabling the video track type, we force ExoPlayer to completely release the | ||
| // current renderer and decoder, ensuring a clean slate for the new resolution. | ||
| if (dimensionsChanged) { |
There was a problem hiding this comment.
Should leave a TODO: for these at least. Hopefully this workaround won't be necessary forever.
| /// For non-adaptive videos (MP4, MOV, etc.), this returns an empty list | ||
| /// as they have a single fixed quality that cannot be switched. |
There was a problem hiding this comment.
Is this always true? Could a non-adaptive video send a single track? I think it's possible in the platform implementations
There was a problem hiding this comment.
Good catch. I double-checked this and the previous wording was too narrow, so I updated it.
My read from the platform docs is that for non-adaptive video we can’t safely assume only “a single track or an empty list”:
On Android/Media3, a TrackGroup represents tracks with the same content in different formats, and the track selection docs/API also allow for multiple video groups such as alternate video feeds/camera angles:
Track selection guide
TrackGroup API
On Apple’s AVFoundation side, their docs note that a simple asset may have one video track, but more complex assets/compositions can have multiple video tracks:
Time and Media Representations
About AVFoundation
So I changed the doc to say that for non-adaptive videos, platform implementations may return one or more tracks, or an empty list, depending on the media and the metadata available.
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
…bhat/flutter_packages into feature/video-track-selection-v2
…workaround (#3) flutter/flutter#183824 Co-authored-by: Claude <noreply@anthropic.com>
|
@stuartmorgan-g are we good to create breakout PRs ? |
|
Hi, any update on when these changes will be merged? |
This PR adds video track selection (quality switching) support to the video_player plugin for Android and iOS platforms. This allows users to programmatically get available video quality variants and select a specific quality track, similar to the existing audio track selection feature.
Addresses issue : flutter/flutter#58854
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].///).