This is sometime the very unusual condition when suddenly we remembered something and have to leave the pc as is it in the lock position using windows lock feature but the music players still plays back. So if your choice is that the Windows player should also stop playing then the Mute On Lock will be the best application for you.
Mute on Lock is a tiny utility that sits in the system tray and monitors your computer state: when you are locking your Windows workstation, it mutes the sound of your speakers. Using this tool you can mute or unmute your speakers when locking the computer.This is absolutely free to use.
Isn’t this utility you are looking for so go for a download from the link here