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

Return Control Center to the system when not needed anymore #1156

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

defagos
Copy link
Member

@defagos defagos commented Mar 4, 2025

Description

This PR improves Control Center integration by returning Control Center to the system once Pillarbox does not need it anymore. This allows any other app previously integrated with it to automatically claim ownership again.

Previously Control Center integration was preserved during item transitions. This ensured that Control Center was never returned to another app when in use, especially when navigating between playlist items from the Control Center itself. This approach was too greedy, though, and we never really properly relinquished ownership once the underlying queue player has consumed all its items.

Before After
cc_before.mp4
cc_after.mp4

Changes made

  • Distinguish between item transitions (where Control Center should never be totally empty) and playback end (at which point the Control Center should be returned to the system) by observing queue updates. If there is no current AVPlayerItem this means playback is not currently active and Control Center must be returned to the system.
  • Make this distinction obvious by replacing the NowPlaying struct with an enum (so that the totally empty state is now clearly identified).
  • Remove replay support from the Control Center play button. When playback ends the Control Center is returned to the system, so replaying is not possible anyway.
  • Avoid systematic insertion of MPNowPlayingInfoPropertyIsLiveStream in user info. This trick was used to preserve Control Center integration (which requires a non-empty dictionary). Instead, we now either use a totally empty dictionary (playback end) or a dictionary with at least an empty MPMediaItemPropertyTitle (when content is loaded in between items).

Checklist

  • APIs have been properly documented (if relevant).
  • The documentation has been updated (if relevant).
  • New unit tests have been written (if relevant).
  • The demo has been updated (if relevant).

@defagos defagos linked an issue Mar 4, 2025 that may be closed by this pull request
1 task
@defagos defagos enabled auto-merge March 4, 2025 10:49
@defagos defagos added this pull request to the merge queue Mar 4, 2025
Merged via the queue into main with commit e39b5b9 Mar 4, 2025
7 checks passed
@defagos defagos deleted the 1155-empty-system-player-after-playback-ended branch March 4, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Empty system player after playback ended
2 participants