Hi,
my app plays local audio files (MP3/M4A) with an AVQueuePlayer. The audio session is set once at launch with AVAudioSession.sharedInstance().setCategory(.playback, mode: .default). Playback continues fine, and the AirPlay route works for track changes, track ends and manual skipping.
Problem: When I invoke Siri while the music is playing over AirPlay (to an AirPlay speaker), the iPhone keeps playing, but the output route switches to the iPhone speaker. About 9 seconds later it switches back to the AirPlay speaker.
Environment:
iOS [Version], iPhone [Modell]
Xcode [Version], Swift 5 language mode
Audio session: category .playback, mode .default, no options
Route change log (my app records every AVAudioSession.routeChangeNotification with its reason and the current outputs):
13:08:44 Category: Speaker → AirPlay speaker
13:08:44 Category unchanged (category, mode and options are the same as set at launch)
13:08:35 Category: AirPlay speaker → Speaker
13:08:35 Category unchanged
13:03:42 Device connected: Speaker → AirPlay speaker
What I checked:
The category, mode and categoryOptions of my session stay the same when the route changes. I read them back in the notification handler.
AVAudioSession.interruptionNotification fires only with .began and .ended for other events. Siri does not seem to produce an interruption, because playback keeps running.
Apple Music (on the same device, to the same AirPlay speaker) keeps the route during Siri invocation.
Question: Which mechanism moves the route when Siri is called, and how can an app keep an AirPlay route in that situation? Is there a session setting or a pattern I am missing?
Thanks in advance.