Haven't tested it, but I think it's doable.
First, add this wrapper to your spotify: https://github.com/johanlindquist/jahspotify. This will give you a REST interface to control playback.
Now, create a chrome (I assume that's what you're using. If not, there are probably similar options for other browsers as well) extension that works for everything on YouTube's domain and add this: http://stackoverflow.com/q/8152814/1456578. Change the code to pause/resume spotify when a certain event happens on YT player.
As I'm intrested in a solution myself as well, I'll probably try it out sometime soon and will then update this answer with the results. Will most likely create/use a lightweight node server to wrap Spotify instead, because Tomcat seems like an overkill and all you (I) actually need is the play/pause functionality.