STEPS TO REPRODUCE:
- Pair some bluetooth headphones with your device (e.g. AirPods). They need to be headphones that automatically connect and become the default output device.
- Turn those headphones off.
- Start playing a song in Spotify.
- Select a Spotify Connect destination from the Connect menu (e.g. a local Sonos device)
- Turn the headphones on/put them in your ears (depends on model - do whatever the thing is that causes them to connect and become the default output device)
EXPECTED RESULTS:
Spotify continues playing through the connected Sonos device.
ACTUAL RESULTS:
Spotify disconnects the Sonos device and starts playing back through headphones.
REGRESSION:
This behaviour is new as of the last few months - not sure the exact version when it changed, sorry! This was an old bug, but it was fixed a few years ago, becoming tied to the option to show Spotify controls on the lock screen. However that behaviour seems to have been reverted.
NOTES:
I think this happens due to a missed check in the notification handler for `AVAudioSession.routeChangeNotification`. My guess is that it interprets the `newDeviceAvailable` route change reason as meaning that the user has deliberately selected the output in Control Centre, whereas it can actually fire with essentially no user interaction at all. The handler should check if the user has selected a Spotify Connect destination or is currently playing back on "This iPhone" before making the decision to end Connect playback and resume playing on the device's new audio route.
For the tiny handful of people who actually want this behaviour (and I have to assume it's near zero), I would suggest having this be a configurable option. If you really wanted to make everyone happy, you could have this be configurable per device, like so:
When the "lock playback" switch is selected, a deliberate user interaction within the Spotify app is always required to switch the playback destination. System notifications can't change it. (There might have to be an asterisk to this with Sonos specifically, because the user could create a group from the Sonos app, but I think these kind of details can be worked out in user testing. The point is, it doesn't switch without the user tapping something that very clearly is going to switch playback off the current device.)
AFFECTED PLATFORMS:
iOS (maybe others, I don't know)