0

I only ever unmute my phone when my headphones are plugged into it. I'm looking to automate this process. Here's what I want to happen:

if (headphones are unplugged) {

  mute all audio on the phone

} else {

  play audio through headphones

}

I've heard of automation apps like Tasker and Task, but I don't really know how to use them, or even if this is possible.

3
  • The system should automatically handle that for you. If you have your headphones unplugged and set the media volume to mute then plug them in, it should switch to (lets say) headphone mode. When you unplug them, it should switch back to mute for speakers.
    – CodeMonkey
    Commented Mar 12, 2019 at 15:23
  • Unfortunately this isn't the case with Do Not Disturb mode. Commented Mar 12, 2019 at 21:27
  • What phone and version of Android are you using?
    – CodeMonkey
    Commented Mar 12, 2019 at 22:53

1 Answer 1

2

I am using Macrodroid and Automate to demonstrate what you ask.

With Macrodroid

You will need to create 2 macros.

1st macro: Headset plugged

  • In the Trigger tab, select Headphones Insert/Remove, then choose Headphones Inserted followed by Any.

  • In the Actions tab, select Volume Change, then give the appropriate permissions. Set the level of each audio stream (see below picture on the left).

  • Give the macro a name, then save it. It will look like the picture on the right.

IMG: IMG:

2nd macro: Headset unplugged

  • In the Trigger tab, select Headphones Insert/Remove, then choose Headphones Removed.

  • In the Actions tab, select Volume Change, then give the appropriate permissions. Set the level of each audio stream to 0 (see below picture on the left).

  • Give the macro a name, then save it. It will look like the picture below on the right.

IMG: IMG:

With Automate

  • In the Interface section, select "Wire headset plugged?", then link its IN with the OK of the "Flow beginning" block.
  • In the Camera & Sound section, select "Audio stream mute state" twice.

    1. Click on the first block, set the state to Unmute, select an audio stream, then click Done. Link the IN to the Yes of the "When wire headset plugged" block, then Link the OK to the IN of the "When wire headset plugged" block.

    2. Click on the second block, set the state to Mute, then select an audio stream. Link the IN to the No of the "When wire headset plugged" block, then Link the OK to the IN of the "When wire headset plugged" block.

  • It will look like the image below. Give your flow a name then save it, then click on Start.

Note: I have selected Music stream for this example. Only the music will be muted/unmuted. Add more blocks for the other audio streams (voice call, alarm, system, etc).

IMG:

4
  • This is an excellent guide! Thank you very much for your input! I followed the Macrodroid steps and it's exactly what I wanted to achieve. Commented Mar 25, 2019 at 20:23
  • What an amazing walk through! Thank you for taking the time to do that. I dont even have a device that i believe can utilize this utility, but you lead me right along, and it was enjoyable even. Does macrodroid require root or any special permissions? Commented Mar 27, 2019 at 9:25
  • @Evileclipse Some features requires root but most don't. The most important is to give the appropriate permissions when required for the macros to work correctly. Commented Mar 27, 2019 at 12:24
  • @Evileclipse I was able to follow this guide using Macrodroid without needing to use any root access. Commented Mar 27, 2019 at 19:11

You must log in to answer this question.

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