Tasker recognize when headphones are in and something starts playing
You can either use the plugin "Tasker Is Music Playing", for one dollar, or try the "Media Utilities" for free, which interface with Tasker but might or might not work with your specific media player.