There's two solutions for the desktop already and I'm building it in flutter, which is cross platform, I don't have a Mac here to compile to iOS though
I think Tasker uses the option to 'draw on top of other apps' in order to maintain control of things. I think Poweramp uses some fancy notification settings (persistent, invisible?) to do the same. Poweramp is very good at retaining the ability to resume audio playback on device connect, independent of whether it was the last audio application playing audio. Tasker, I haven't used properly yet, but was interested in automating button functionality with it.
Another note: it might be neat to have a 'sync all account settings' option : )