Pause iTunes when Youtube

I use to spend a lot of time drawing, or editing, or writing, with my computer; and I also usually procrastinate, watch videos, and hear song on my browser (Safari). I also use iTunes to listen to music, and when I watch a video from youtube I need to pause iTunes. Then the video ends, and I normally forget to play it again, so I've spent a lot of time in silence, with my headphones… Several hours. You know.

So, I'm just saying (and expecting someone with knowledge is listening):

Wouldn't be nice if someone wrote a program which detects the sound coming from Safari, or Chrome, or whatever; and pauses iTunes (Spotify, etc), to resume it again when the browser is silent?

ps: I've bee searching around and for now I've found HiJack Audio Pro, which could resume iTunes when the video is over, but only while recording the audio from Youtube, and creating lots of files.

ps2: sorry for my english