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

Automatically show closed captioning/hard of hearing track based on accessibility settings #5749

Closed
sobbe81 opened this issue Apr 11, 2019 · 6 comments
Assignees

Comments

@sobbe81
Copy link

sobbe81 commented Apr 11, 2019

Hi,

I'm using ExoPlayer for playback of DASH-content. I'm looking for a way to

  • Pick a certain language as default for subtitles, now done by using setPreferredTextLanguage
  • Pick cc/hard of hearing track if this setting in accessibility settings is enabled.

The DefaultTrackSelector has an API to setPreferredTextLanguage which works fine for displaying subtitle tracks.

However, my app needs to support both subtitles and closed captions and my problem is that if I use setPreferredTextLanguage it will always display the closed captions since these are using the same language code.

The CaptioningManager, https://developer.android.com/reference/android/view/accessibility/CaptioningManager, offers an API to read accessibility settings. From what I understand, ExoPlayer uses this setting to determine the styling of the closed captions but not to determine whether text should be shown or not.

Is there any way to get the ExoPlayer automatically enable closed captioning based on accessibility settings? And that setPreferredTextLanguage only applies to subtitles and not closed captions?

Thanks,
Martin

@tonihei
Copy link
Collaborator

tonihei commented Apr 11, 2019

Thanks for the detailed description of the problem. I think there are two enhancements in here that need to be addressed:

  1. Automatically select closed captions if CaptioningManager.isEnabled() is true. This should only be done if a closed caption track for CaptioningManager.getLocale() is available. Or the closed caption track has no language and the selectUndeterminedTextLanguage option is enabled.
  2. If the preferredTextLanguage option is set and multiple matching text tracks are found, choose the closed caption track if CaptioningManager.isEnabled() is true, and the subtitle track otherwise.

Does that summarize your proposal correctly?

@sobbe81
Copy link
Author

sobbe81 commented Apr 11, 2019

Yes, that's sounds like it would solve my problem.

Just a clarification for one scenario:
if CaptioningManager.isEnabled() is false and preferredTextLanguage is set to "swe" and there is a closed captioning track, i.e. AdaptationSet with role=caption, available with language code "swe" this track would not be displayed. Correct?

@tonihei
Copy link
Collaborator

tonihei commented Apr 11, 2019

Yes, that's my understanding of the isEnabled flag.

@sobbe81
Copy link
Author

sobbe81 commented Apr 11, 2019

Great!

@ojw28
Copy link
Contributor

ojw28 commented Jun 21, 2019

It should also be possible for apps to do everything that they need in the case where they get subtitle/caption settings from somewhere other than CaptioningManager (e.g. for API levels prior to 19, where CaptioningManager doesn't exist, or for apps that store their users' preferences in the cloud to sync them across multiple platforms).

So I think setPreferredTextLanguage probably needs generalizing somehow to also allow preferred (and/or allowed) role flags. Exactly how that's done probably requires some thought. Once it's done, apps should be able to easily map CaptioningManager settings onto this generalized API. Whether we change the default behavior of DefaultTrackSelector is then somewhat less important (although quite possibly still worth doing!).

@tonihei
Copy link
Collaborator

tonihei commented Sep 20, 2019

This is auto-enabled now and also be set triggered manually by using setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings.

@tonihei tonihei closed this as completed Sep 20, 2019
tonihei added a commit that referenced this issue Sep 20, 2019
…tings

This option allows to set the preferred text language and role flags based
on the user's accessiblity captioning settings.

Issue:#5749
PiperOrigin-RevId: 270233205
@google google locked and limited conversation to collaborators Nov 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants