Overnight, without me changing anything, my play/pause stopped working for the Music app and the AppleTV app on Sonoma but it was working for the Podcast app and when watching YouTube videos via Safari.
I went into Music and under the Account menu I went into Authorisations and chose to authorise my machine. It was already authorised so this just re-authorised it without affecting the number of authorised devices. I then went into AppleTV and re-authorised this machine there.
Now, after re-authorisation, the play/pause buttons are working as expected.
I've submitted a bug report to Apple using the Feedback Assistant app with diagnostics from when the play/pause wasn't working and then again from when it started working again.
The need to re-authorise the computer (even though it's not lost authorisation) is a long-standing bug with Apple that they really need to get round to fixing. If it needs to be periodically re-authorised then at least tell me, don't just randomly stop certain features from working.