This is a problem for me only in the morning when I get to work and when I go home. Something was playing when I put my macbook to sleep and when it wakes up it resumes at full volume behind the unlock screen. However if I go to lunch for example I like it that my music resumes. Ideally I would like an API to control this behavior - eg mute on wake up only if sleeping for more than 3 hours.
Maybe you could use SleepWatcher (running with Mac OS X 10.5 to OS X 10.10).
Is a command line tool (daemon) for OS X that monitors sleep, wakeup and idleness of a Mac. It can be used to execute a Unix command when the Mac or the display of the Mac goes to sleep mode or wakes up, after a given time without user interaction or when the user resumes activity after a break or when the power supply of a Mac notebook is attached or detached. It also can send the Mac to sleep mode or retrieve the time since last user activity. A little bit knowledge of the Unix command line is required to benefit from this software.