It knows which device is currently playing. Anything you do sends it to the currently playing device. You can pull up a list of all connected devices and select which one you want to be playing. It then starts on the new device from where the old one left off.
It works really well. I have my raspberry pi plugged into my amplifier, and play through that. I control it with my phone or laptop, whichever is nearer.