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.

2 Comments

  1. Matt
    3/29/2012 #

    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. 3/30/2012 #

    sure! i use AudioManager.html.isMusicActive(). you can see it in context in the source tarball, in src/org/snarfed/android/headphonebuttons/receiver/FireReceiver.java.

    tasker is awesome, btw, i love it!

Post a comment...

Post a Comment

Your email is never published nor shared.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>