Skip to content
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

Fix caption auto-selection not reflected in player GUI #8150

Merged
merged 3 commits into from
Apr 14, 2022

Conversation

karyogamy
Copy link
Contributor

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR fixes an issue introduced by #8020, where CustomTrackSelector was replaced by DefaultTrackSelector, delegating preferred caption language selection to ExoPlayer instead. When transitioning from a video with manual subtitles selected, e.g. english, to a video with only auto-generated subtitles, e.g. english (auto-generated), ExoPlayer would apply the previously selected language as preferred language and use the auto-generated subtitles instead of disabling captions. This is not reflected in the GUI since it is still trying to find that previously selected language in the list of available languages for the second video, which isn't there, so the GUI shows No Captions. This is fixed by looking at the currently select tracks onTracksInfoChanged, and show the ExoPlayer's selected tracks instead.

This change also fixes an unreported caption bug when selecting language variants, where a video has one caption language with multiple formats in parentheses, e.g. english (auto-generated) and english (united kingdom) in this order. When any variant of a language is selected (e.g. english (auto-generated)), the selected caption would jump to the last variant of a language group instead, in this case, english (united kingdom). This happens because of parentheses detection logic when setting userPreferredLanguage, and is also fixed by delegating preferred language selection to ExoPlayer.

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@AudricV AudricV added bug Issue is related to a bug player Issues related to any player (main, popup and background) labels Apr 5, 2022
@AudricV

This comment was marked as outdated.

@karyogamy

This comment was marked as resolved.

@AudricV

This comment was marked as resolved.

fixed: player caption selection skipping on multiple language variants.
@Redirion
Copy link
Member

Redirion commented Apr 8, 2022

I have tested a bit, so far so good. But now having english (united kingdom) and choosing a video with english (automatic) or vise versa unselects the captions.

I preferred the previous behaviour actually. If I understood correctly you wanted to make sure that if both (united kingdom) and (automatic) are available it would keep the previous. But this now feels like a downgrade when not both are available at the same time.

@karyogamy
Copy link
Contributor Author

But now having english (united kingdom) and choosing a video with english (automatic) or vise versa unselects the captions.

I think this is the default behavior for Youtube browser player, probably why it is replicated on ExoPlayer as default behavior.
This was remedied by that auto-generated caption seeking logic that converts english (united kingdom) to english (automatic), but as mentioned, it has a bug that breaks selection on multiple language variants, which is problematic for videos like this that has 6 variants of Chinese captions.

This is now fixed by using multiple preferred languages in ExoPlayer caption support, though it requires parsing for the "stem" of language descriptor: e.g. english (united kingdom) -> english. So when english (united kingdom) is selected, both english (united kingdom) and english will be applied, in that order, and ExoPlayer will try to find a caption in the same order when the next video starts playing. Proper support of this should probably be included in the extractor, though that is out of scope on my side time-wise, at least in the near future.

@Redirion
Copy link
Member

Tested again.

I just tested a video with english (united kingdom) and then switched to another video which has both english (automatisch erzeugt) and english (united states).

It appears to be random / nondeterministic. Sometimes cc even get's competely unselected. I don't know what's happening there.

@karyogamy
Copy link
Contributor Author

I just tested a video with english (united kingdom) and then switched to another video which has both english (automatisch erzeugt) and english (united states).

Thanks for testing, not sure how I missed this one.
It seems to be caused by auto-generated tracks sharing the same priority inside DefaultTrackSelector as manual tracks since both tracks have the same stems (english) with no track having an exactly matching language name as the preferred. Thankfully there is a way to distinguish auto-generated tracks in the resolver and tracks are now given different roles that ExoPlayer can use in track selection. The updated track selection order is left as a comment.

Sometimes cc even get's competely unselected.

I'm not able to reprod this one. Could you test the updated apk and provide some steps if this still happens?

@sonarcloud
Copy link

sonarcloud bot commented Apr 12, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Redirion Redirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again, working now as expected. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants