Me and others have had an annoying problem with AirPlay:
After the computer has auto connected to AirPods, the computer refuses to connect to an AirPlay device, showing an error message saying "Could not connect to [name of the AirPlay device]."
The only fix I and others had previously found was rebooting the computer.
Finally I found the cause and the fix:
The issue appears to be triggered when macOS automatically connects/switches audio to AirPods. After the automatic switch, the AirPlayXPCHelper system process seems to get stuck in a bad state. AirPlay devices are still discoverable via Bonjour/mDNS, but macOS can no longer establish an AirPlay connection. Manually switching to AirPods does not seem to trigger the problem.
Workaround: Restarting AirPlayXPCHelper immediately restores AirPlay without rebooting the Mac, using Terminal with this command:
sudo killall AirPlayXPCHelper
You can then connect to the Airplay device again. Works every time.
Would like to submit this bug report to Apple but I don't know how to do it.