This question already has an answer here:
I lock my work iMac Pro every night, but sometimes when I get in the next morning music is leaking out of my headphones. I've discovered that the "unmute" and "play" keyboard buttons are still effective when the OS is locked. It would seem that the cleaner running a cloth over the keyboard "makes things happen" even when the machine should be locked.
Short of remembering to close any app that can play media before I lock the machine, can this be disabled? Ideally I'd like these keyboard shortcuts to do nothing while the machine is locked. It doesn't seem quite right that somebody can control my computer to some degree without logging in!