SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
159 stars 33 forks source link

SDH accessibility setting is not taken into account in automatic mode #91

Closed defagos closed 4 years ago

defagos commented 4 years ago

When the SDH accessibility preference has been set, and if an appropriate SDH track is available, it is not automatically selected in Automatic mode.

Issue type

Incorrect behavior

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Change your phone language to French.
  2. Open any content in SRG Player demo and set subtitles to Automatic mode.
  3. Check that the Accessibility > Subtitles & Captioning > Closed Captions + SDH is disabled.
  4. Open SRG Media Player demo and play "Bonjour la Suisse". No subtitles are selected. Close the player.
  5. Now toggle on Accessibility > Subtitles & Captioning > Closed Captions + SDH.
  6. Open SRG Media Player demo and play "Bonjour la Suisse" again. French SDH subtitles are selected (the system automatically does it when enabling the accessibility setting).
  7. Switch to Automatic mode. The French SDH track should remain the one used.
  8. Close the player and open the same content. The French SDH track should be selected in Automatic mode (but is currently not).
defagos commented 4 years ago

The bug is due to the fact that we ignore accessibility settings when finding the default subtitle track. The bug has been fixed on the feature/sdh-fix branch.

Note that, as described above in the Steps to reproduce, enabling the SDH setting for the first time manually sets the corresponding language at the system level (i.e. if Automatic was previously selected it will be selected). This behavior is a system one and affects AVPlayerViewController in the same way. What is important, though, is that Automatic mode then properly chooses this very same track while the Accessibility SDH setting remains enabled, which was the bug reported in this issue.

defagos commented 4 years ago

When enabling the SDH setting, the system in fact saves (probably with the media accessibility API) the current system language as latest manual choice. This is easy to see:

  1. Set the phone language to French.
  2. Enable the SDH setting.
  3. Set the phone language to English.
  4. Open a content. You’ll see that French (the phone language at the time the setting was enabled) is the current language.
defagos commented 4 years ago

For some RTS content (at least), we have no track language information. The condition had to be fixed to take this fact into account and check for subtitles first.

pyby commented 4 years ago

4.4. The presence of closed captions MUST be declared via an EXT-X-MEDIA tag that contains a LANGUAGE attribute.

It's part of 4. Accessibility requirements. Nothing required in #EXT-X-STREAM-INF about language.

Your fix takes care of this optional information. 👍🏻

defagos commented 4 years ago

Use cases have been tested again (note that the case described in this issue was actually part of them 😃, but of course not correctly validated according to the above discussion).