This is close enough to my solution, just using the playback state instead of a boolean variable. I discovered that when I upgraded to Monterey this month my MPMusicPlayerControllerNowPlayingItemDidChange notification began giving me the same treatment: work once and done, leading to yet another code around. I posted about it here around the time I came across this post. If you have the same problem, please drop a comment about any ideas you might have as well!
Post
Replies
Boosts
Views
Activity
I resigned myself to this a while back, and have employed a similar workaround as you describe here. Thanks for the acknowledgment, though!
I came across this post while searching for a solution to my Mac Catalyst music app not functioning upon upgrading to Sonoma. It seems the MPMusicPlayerController class no longer responds to calls within a SystemMusicPlayer setting, leaving labels displaying song title, artist, etc. blank, and of course, no ability to set queues! It would appear Apple is intent on herding everyone into its pay-to-play MusicKit and leaving tinkerers like me out to dry. Way to go😒
Ha, ha, so after 24 hours of scrambling, I find changing the class variable from system… to application music player solves the issue, and my app is back up and running. But the writing is still on the wall…