Set iTunes (or any Mac music player) to pause every time you unplug your headphones and play when you plug them back in. BreakAway is a simple app for Mac that prevents you from filling a room with your music when you unplug your headphones.
If this sounds familiar, it should: my iPod shuffle used to automatically pause when I unplugged my headphones. It's a subtle thing, but it makes a lot of sense when you think about it: why should you miss any of your music or podcasts when your headphones aren't plugged in?
Most computers don't work this way, however: when you unplug your headphones, your music keeps playing from your speakers. This is perfect most of the time, but terrible at others. For example: you might accidentally unplug your headphones at work and reveal your embarrassing K-Pop habit to co-workers, who currently think you listen exclusively to Slayer. Or you might actually be listening to Slayer in the library when you accidentally unplug your headphones and annoy every single patron at once. It happens.
Whether you want to avoid such accidents or just want a quick way to pause your music while unplugging, Breakaway is probably right for you. Here's how it works.
Using Breakaway
Breakaway lives in the system tray; it's symbol is a "+" when your headphones are plugged in and a square when they are not. If you have music playing in iTunes, that music will pause when you remove your headphones from the jack on your Mac.
It's simple, and hard to demonstrate in screenshots, but I think you get the idea. There aren't a lot of preferences: starting the program at boot and whether or not the program shows up in the menubar.
By default Breakaway fades back in when you plug in your headphone jack. Don't like this, or want to tweak the fade? Head to the "Plugins" page of the preferences window and click the "iTunes" plugin. You'll find the fade settings here:
You can also, in theory, add plugins for other media players here. I couldn't find any plugins, personally, but that's okay because of AppleScript.
AppleScript!
So the seeming Internet-wide lack of plugins for non-iTunes media players is annoying, but don't panic: a built-in AppleScript plugin means you can easily add support for your various other music players. It just takes a little effort. Here's how.
First things first: you're going to need to write – or find – a pause/play script for your music player of choice. This isn't as complex as it sounds – the command itself looks something like this:
tell application "Spotify" to playpause
You might want more code then this – code that checks whether a given program is open before sending out the command, for example – but the above is the gist of what code you need.
You don't need to guess, though: there are plenty of great scripts for controlling various media players out there on the wider Internet, so Google away! I quickly found AppleScripts for controlling Spotify and AppleScripts for controlling VLC; I'm sure you can find others.
Once you have the code you want it's time to open AppleScript Editor. Paste what you've found here.
Not sure if it will work? Open your media player of choice, then test your script by pressing the "run" button at top.
Did your media player play/pause? Good! Go ahead and save the script wherever convenient, then open Breakaway's preferences and head back to the "Plugins" page. Turn on the AppleScripts plugin and add a new trigger. Drag the script you just saved from Finder to the "Run Script" box:
Check the boxes to set when the script will run (ie, when you unplug your headphones) and everything should start working immediately. Congratulations: you can now set your favorite programs to pause/play when you remove your headphone jack.
Conclusion
Breakaway is a simple app that does one thing: pause your music when you unplug your headphones. If you don't want to miss a moment of your music when you want to talk to someone – or risk blasting the library with your music every time you accidentally unplug your headphones – it's worth looking into.
Here are some more creative ways to control iTunes, if you're interested:
What are you using Breakaway for? Let me know in the comments below, along with links to any AppleScripts you're using the plugin with.