What I ideally want to achieve: TTS for any text I see on my phone, with the user experience similar to my podcast app.

My current approach: Use Android Select to Speak functionality.
This works to read the text on the screen, works in the background, etc which is great. But it totally ignores any attempt to control the playback using media buttons on my headphones.

How do I make Select to Speak work with media buttons on headphones:

  • Play/pause
  • Skip back/forward (ideally allowing me specify time interval for this)

Or is there an alternative to Select to Speak that works better with media controls?

  • Hello. Are you trying to develop an app or is this an end user problem? Former is off-topic here.
    – Firelord
    May 17, 2022 at 9:26
  • 1
    Hi, I'm very much trying not to develop an app 😭. I just want to find something that works (alternative to Select to Speak or a way to fix it)
    – Stvad
    May 17, 2022 at 17:02
  • I'm potentially open to building a small companion app that would redirect the media signals in a way Select to Speak would understand (or if it's Open Source - contributing it to the main codebase?). But not re-implementing the full thing
    – Stvad
    May 17, 2022 at 17:49

1 Answer 1


You may be able to set up a custom accessibility service (https://developer.android.com/guide/topics/ui/accessibility/service) and listen for KEYCODE_MEDIA_PLAY_PAUSE using a background service (https://stackoverflow.com/questions/21175914/determine-if-headphones-are-plugged-in-through-appwidgetprovider-pause-music-wh).

Then, as you described, the custom accessibility service could detect that you've short-pressed (KEYCODE_MEDIA_PLAY_PAUSE) or long-pressed (KEYCODE_VOICE_ASSIST) the button on your headphones.

  • yeah, I can imagine I can build something that would listen for media events, but can this allow me to control Select to Speak somehow? or would I need to re-implement the whole thing from ground up?
    – Stvad
    May 17, 2022 at 21:30
  • I agree that I described an awful lot of work. What are you trying to hear when you use Select to Speak? play.google.com/store/apps/details?id=com.hyperionics.avar will let you use the headphone button. play.google.com/store/apps/details?id=com.messageloud doesn't appear at first glance to support headphone buttons but it claims to present a large on-screen button.
    – Zian Choy
    May 21, 2022 at 8:28
  • Something like "select any text on the screen and read it" mostly in the browser, but sometimes in other apps too. Ideally showing what is being read in the context. I've tried @voice before for browser use-case, it didn't seem to work that well. will try again
    – Stvad
    May 24, 2022 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .