Locale Headphone Buttons Plugin

Locale Headphone Buttons Plugin is a plugin for the Locale Android app that simulates pressing a headphone or headset button. You can get it from the Android app store. Available buttons are the “hook” ie single headset button, Play/Pause, Play, Pause, Next, Previous, Fast Forward, Rewind, Stop. Also optionally checks whether anything is currently playing.

This is useful because headphone buttons automatically use the current “preferred” media player, which is usually the most recently used one, instead of any specific player.

I use this to restart whatever was playing last when I plug in my headphones. It’s nice that Android automatically pauses when they’re unplugged, but it’s annoying to have to unlock the screen, navigate through the player app, and press play again. Add a Locale situation with headphones connected as the condition and this plugin with “Play/Pause” as the setting, and voila, your music or podcast automatically restarts when you plug your headphones back in!

Warning: some media player apps don’t handle headphone buttons consistently, or even at all, even built-in apps. If this plugin doesn’t work with a specific app, check that it supports the headphone button you’ve selected, and/or try other buttons.

The app is open source and released into the public domain. Download the code.

For more, see my blog post Thoughts on writing my first Android app.

7 thoughts on “Locale Headphone Buttons Plugin

  1. Can you tell me what you use to tell if music is playing? This is functionality that would be very useful to me in Tasker (Locale). Thanks!

  2. Hi,

    thanks a lot for this application, it helps me a lot automating my life. :-) I have one question. At the moment, I’m creating a script in Tasker that lets me have incoming text messages read loud whn I’m connected to bluetooth. Before reading the text, I pause the currntly playing music with your plugin (if music is currently playing). After the text is read, I want to resume the music playback, but at that time I’m in an unknown state regarding if music was playing before or not… Is it possible for you to expose the isMusicActive() call to Locale/Tasker so that I will be able to resume music only if it was playing before? Thanks!

  3. sure! I can put it on my to-do list, at least, but it’ll take me a while to get to it. in the meantime, if you’re interested, feel free to grab the source from the link above and dive in!

  4. Hi Ryan,

    Your app sounds great and perfect for what I need, but I can’t seem to replicate the actions the buttons on two different types of bluetooth headphones have on my phone.

    I am trying to automatically play using the BBC iPlayer Radio app with Tasker, yet with every combination of button I use to press play after first opening the app it seems to just open Google Music!! With both headphones however I can get tasker to open the radio app only, then use the button to play. Are you able to help?

    Thanks

  5. hey calum, sorry for the trouble! you’re right, support for headphone buttons varies widely across apps and devices. it can definitely be hard to get them to do specific things in specific apps consistently. i haven’t really tried to tackle that problem in this plugin, and i don’t really have plans to. sorry. definitely keep me posted if you find a better solution though!

Leave a Reply

Your email address will not be published.