It’s also worth noting that Spotify can act as a remote for its own service across devices. So you can start a song playing on your phone and direct the output over AirPlay and then just interface with that session using the desktop client.
This is what I do on macOS. I press on the little megaphone icon (enable it in OS sound preferences) in menu bar and then I can choose my HomePod from the list, without any third party software. I am running Big Sur but in two previous versions I also did the same. Maybe I’m missing something here but I think it should work seamlessly.
This makes watching a "GIF" with audio (say browsing Reddit), opening a video, answering a slack call, etc. a very bad experience.
Spotify by itself supports its own protocol, whatever that may be, and chromecast. The iOS app should also support Airplay through the OS.
Personally I have a Spotify enabled receiver plugged to my audio system, it works really well.
The correct solution is for the application to support Airplay, so that for instance Spotify can stream music to your Airplay device, while the Mac sounds still goes to the speakers of the laptop/iMac.
Apple Music is still mostly worse without discovery, but at least lossless makes up the quality difference that use to be there.
When my girlfriend and I moved in together, we got rid of her Alexa devices because privacy and use HomePods. But Spotify doesn’t work with AirPlay for reasons I cannot fathom, so I set her up with a program that will AirPlay specific applications on her Mac.
That said, there are open source libraries and clients for AirPlay so it shouldn’t be too difficult to get them supported. I have a Raspberry Pi for streaming to “dumb” speakers.