The Nokia N9 can detect when the headphone pin in plugged in or removed.
It would be great to have a tweak to automatically launch the Music app when the earphones are plugged in. Preferably, there can be a toggle in the Settings>Applications>Music to enable/disable the feature.