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

Forced subtitles support #502

Closed
7 of 8 tasks
defagos opened this issue Aug 2, 2023 · 3 comments · Fixed by #533
Closed
7 of 8 tasks

Forced subtitles support #502

defagos opened this issue Aug 2, 2023 · 3 comments · Fixed by #533
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@defagos
Copy link
Member

defagos commented Aug 2, 2023

As a user I want forced subtitles to be automatically enabled when appropriate. I never want to see them or be able to select them directly.

Acceptance criteria

  • Forced subtitles are automatically enabled based on the currently selected audio language.
  • Forced subtitles are never returned from usual public player APIs.
  • Forced subtitles cannot be selected via the public player API.
  • Forced subtitles are not displayed in the demo.

Documentation

Tasks

  • Filter forced subtitles from subtitle lists.
  • Ensure forced subtitles cannot be selected from the public API, even if they were retrieved in some other way (e.g. directly from the queue player asset).
  • Automatically enable forced subtitles based on the currently selected audio language, when no subtitle track has been explicitly selected.
    • Enable when setting subtitles to Off.
    • Enable when setting subtitles to Automatic (if automatic selection does not enable unforced subtitles).
    • Update when changing the audio language, both for Off and Automatic selection already applied to subtitles.
  • Check behavior over AirPlay.
  • Document packaging requirements, most notably the use of AUTOSELECT for forced subtitles.
@defagos defagos added this to Pillarbox Aug 2, 2023
@defagos defagos converted this from a draft issue Aug 2, 2023
@defagos defagos added this to the Tracks milestone Aug 2, 2023
@defagos defagos added the enhancement New feature or request label Aug 2, 2023
@defagos defagos moved this from 📋 Backlog to 🚧 In Progress in Pillarbox Aug 15, 2023
@defagos defagos self-assigned this Aug 15, 2023
@defagos
Copy link
Member Author

defagos commented Aug 17, 2023

In fact forced subtitles are quite easy to implement:

  • Subtitles must be marked as AUTOSELECT.
  • We set the Media Accessibility preferences to .forcedOnly.
  • We call selectMediaOptionAutomatically(in:) to enable automatic selection.

This can be easily observed by downloading the Apple Basic 16:9 example playlist, changing the AUTOSELECT flag to YES for all forced subtitles, and mapping the corresponding call to the local edited file with Charles. We can also change one of the audio languages to fre and verify that changing the audio language changes the forced subtitles accordingly.

This behavior works well with Play CH test streams which have this flag correctly set for forced subtitles.

AVPlayer then behaves correctly. What we need is therefore only to filter forced subtitles and to provide documentation about how packaging must be made.

Still providing the ability to implement custom MediaSelectors can be helpful but we can keep things simple for the default implementation, providing that the packaging is done right.

The only issue is that we don't really have test streams for this use case, but since the implementation is quite simple I think this is less of a problem.

@defagos
Copy link
Member Author

defagos commented Aug 18, 2023

Over AirPlay:

  • When changing options on mobile with the TV selection menu open, the TV selection is not updated visually but the player correctly switches to the newly selected option.
  • When changing options on TV with the mobile selection menu open, the mobile selection is correctly updated for Off and unforced options. Since the TV system UI displays forced subtitles (incorrectly IMHO) selecting a forced subtitle makes menu item selection disappear on device, a minor annoyance, though.
  • There is still an initial selection system bug, see Report AirPlay media selection issues to Apple #511, but a rather minor annoyance as well.

@defagos defagos linked a pull request Aug 18, 2023 that will close this issue
5 tasks
@defagos defagos moved this from 🚧 In Progress to 🍿 Code Review in Pillarbox Aug 18, 2023
@defagos
Copy link
Member Author

defagos commented Aug 18, 2023

For reference there is an interesting AVMediaSelectionOption.associatedMediaSelectionOption(in:) API which is able to find related options in different groups, e.g. forced subtitles. Not useful but still interesting to know.

@github-project-automation github-project-automation bot moved this from 🍿 Code Review to ✅ Done in Pillarbox Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant