[video_player] Adding support for preferred audio language
Added support for preferred audio language to video_player on Android. If underlaying stream/video supports it this will communicate to exoplayer that audio stream for sepcific language should be used if available.
To use this feature developer should pass preferredAudioLanguage as a 2 character ISO langauge code to VideoPlayerOptions when initializing VideoPlayerController. This code should match one of the language specified in the stream, for example (HLS):
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Italian",LANGUAGE="it",DEFAULT=NO,AUTOSELECT=YES,URI="audio/italian.m3u8"
Platforms that don't have implementation yet will silently ignore this.
This PR implements https://github.com/flutter/flutter/issues/166411
Pre-Review Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter.
- [ ] I signed the CLA.
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I linked to at least one issue that this PR fixes in the description above.
- [x] I updated
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]. - [x] I updated
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]. - [x] I updated/added any relevant documentation (doc comments with
///). - [x] 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].
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Hi, thank you for your contribution! This looks like a great feature to support, but it looks like the tests are failing. Before we review the PR, please see what you can do to resolve the test failures. If you are unsure how to proceed, please reach out for help on the #hackers-new channel.
@camsim99 sorry about that, my first packages PR, still wrapping my head around it. I've updated the code and fixed the tests, flutter test is now passing in all the submodules.
Please see step 1 of the instructions for multi-package PRs for the instructions on how to make this PR something that the CI can run tests on without failing all of the checks.
@stuartmorgan-g followed the instructions and updated pubspecs to use local path dependencies.
Thanks; it looks like CI is now flagging a number of real failures caused by the PR (analysis, Android lint, macOS native tests). The "View details" links for the failing tests will lead to the stdout of the failures.
@frontyard , any update on this ? did you get a chance to look at the failing tests to resolve them ?
@nateshmbhat I had family emergency and wasn't able to work for couple of weeks. I'll get this sorted asap 🙏
do you also plan to add ios implementation also ? @frontyard
@nateshmbhat I have zero experience with ios. I believe the change I made will fail gracefully on platforms not supporting this feature (yet). I'll see if I can figure out how to make it work on ios but it won't be in the initial PR.
A sidenote, I also made a change to video_player_web_hls which I plan to open a PR for once platform change is in.
@frontyard i can also help out with ios implementation. i'm not fully familiiar with ios syntax but with all the recent ai tools, i'm sure i can help out in a some way.
I ran the video_player_avfoundation example project from iphone simulator from the frontyard:preferred-audio-language branch and it crashed during the app launch.
It works fine when i run the app on flutter's branch though.
@frontyard Are you still planning on working on this PR? There are a number of failures in the tests run by CI that need to be addressed.
Thank you for your contribution. Since there are outstanding comments but the PR hasn’t been updated in several months, I’m going to close it so that our PR queue reflects active PRs. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks!