Closed defagos closed 4 years ago
This one puzzled me a bit, but I understood what is the difference between the Advanced and Simple demo: The Advanced demo is integrated with the remote control center. Doing this once (even stopping afterwards) is sufficient to make the feature work correctly.
The SRGAirPlayButton
uses AVRoutePickerView
since iOS 11, which probably triggers what is needed internally so that AirPlay works.
This is in fact not a bug, but a subtle expected behavior. You have to look at the name of the app displayed in the control center. If this is your app, then tapping on the AirPlay button in the control center will affect players from this app that allow external playback (i.e. you will be able to enable AirPlay playback this way), otherwise not.
When the app enables some command from MPRemoteCommandCenter
, the app displayed in the control center becomes the current app, which will allow AirPlay playback to be enabled from the control center. This is why launching the advanced player demo magically fixes the behavior of the simple player, as the app change then persists.
AVRoutePickerView
, on the other hand, seems to cheat: It works, even if the name of the app is not changed in the control center (i.e. without remote command center integration). This is probably because this view has access to internal implementation details we cannot have (all we have is the allowsExternalPlayback
property basically).
We must not fix this in code. It would be tempting to register a dummy remote command center command to force the app using SRG Media Player to be the current one (so that AirPlay can be enabled from the control center), but this would change how things work usually. Apple apps don't do this, e.g. if you were using Spotify and launch Music, Spotify still resides in the control center until you play something.
Instead, I propose we update the documentation and add an AirPlay button to more demos.
In some cases, and even if
allowsExternalPlayback
isYES
for anSRGMediaPlayerController
associatedAVPlayer
(default behavior), attempting to send the content to an AirPlay receiver does not work from the control center.This works reliably when enabling from an
SRGAirPlayButton
.Issue type
Incorrect behavior
Environment information
Reproducibility
Always reproducible
Steps to reproduce
What is interesting is that AirPlay works if the Advanced custom demo is used before (just open it and close it).