Disable Bluetooth Autoplay

3,476 views
Skip to first unread message

sal...@salguod.net

unread,
Nov 6, 2017, 3:47:46 PM11/6/17
to Automate
Hello,

I transitioned from Tasker to Automate and love the easier to use interface.  There's one task I'm having an issue trying to duplicate, however.

I automatically connect to bluetooth in the car, but I often don't want to play any music or podcasts.  However, Android (in this case 7.0 on my Samsung Galaxy S8+) automatically starts playing either my podcast app (Stitcher) or Spotify, whichever was playing last, when I connect to bluetooth.  I want to prevent this behavior.

I used this how-to to setup Tasker to prevent this and it worked well:


Can this be done with Automate?  I can detect a bluetooth device is connected, but I'm not sure how to grab the media button key event.

Or if there's another way to do it with Automate, I'd be interested in that as well.

Thanks,


Henrik "The Developer" Lindqvist

unread,
Nov 7, 2017, 2:18:45 PM11/7/17
to Automate

sal...@salguod.net

unread,
Nov 7, 2017, 3:18:53 PM11/7/17
to Automate
Can you be more specific?  I had figured out that these were the blocks I likely needed, but I'm not sure how they should be set up and it's not obvious  to me from the documentation.

The device connected block is clear (proceed when changed, leave the device name & address blank to apply to all devices) but what needs to be set in the media button block?  No I need to pick a button?  Should "override apps" be set?  I'm guessing no button need be picked and override should be off, correct?

Thanks,

kri...@gmail.com

unread,
Nov 8, 2017, 10:19:14 AM11/8/17
to Automate
You are a day ahead of me in the learning curve so I thought you might have come across the way to solve my problem.

I would like to turn phone ringer off when connected to a particular Bluetooth device and turn the ringer back on when I disconnect.

Automate seems to be the 'cats ass' for these kinds of things just requires a lot of learning.

Thanks

K

sal...@salguod.net

unread,
Nov 8, 2017, 11:42:30 AM11/8/17
to Automate
You'll need the Bluetooth device connected block and set it to look for the connection you want.

Yes should point to a block to set the ringer to mute, no should point to setting the ringer to the volume level you want.

The key things are:
  • Each of those should point back to the bluetooth connected block to start the thing over
  • The bluetooth connected block needs to be set to wait to proceed until the state changes.
I'm a bit new to this myself, but I've done something similar with wifi and that's worked well for me.

BTW - The learning curve for this is nothing compared to Tasker.

Henrik "The Developer" Lindqvist

unread,
Nov 8, 2017, 2:23:38 PM11/8/17
to Automate
   Flow beginning
         |
+------->+
|BT device connected -------------+
|        |                        |
|      Fork --> (see below)   Fiber stop
|     childUri                 childUri
+--------+------------------------+

 (see above)
      |
+---->+
|Media button
+-----+

sal...@salguod.net

unread,
Nov 9, 2017, 8:36:42 AM11/9/17
to Automate
I'm not sure exactly what your diagram means.  I think what you're suggesting is what I've set up and it does not work reliably.  I've attached screenshots of what I've set up, what am I missing?

  


The help page for the "Media Button" block says:


The fiber will pause until a button has been pressed.

If it pauses until a button is pressed, does that mean a button on the UI or if an app "presses" a button by starting playback automatically?  IF the former, then this block won't work here. Also it says:

If an audio player is launched after this block it will capture all media button presses unless override is enabled.

Does the second "it" refer to the audio player or to the fiber?  In other words, does it mean "If an audio player is launched after this block the fiber will capture all media button presses unless override is enabled." or "If an audio player is launched after this block the media player will capture all media button presses unless override is enabled."

Thanks,

Henrik "The Developer" Lindqvist

unread,
Nov 13, 2017, 2:14:40 PM11/13/17
to Automate
  1. The "Media button" block pauses until an media button is reported as being pressed, that would likely be a user pressing it or an app simulating a press. How ever i don't see how it would affect auto-play, as described in the Tasker post.
  2. Usually the "override" option should always be enabled, otherwise other apps will intercept the presses and prevent the "Media button" block from doing so.
The example given was only a untested suggestion, it may not work.

ans...@gmail.com

unread,
Mar 5, 2018, 4:02:35 PM3/5/18
to Automate
Sal, were you ever able to get this working? I'm attempting the same thing now

ans...@gmail.com

unread,
Mar 5, 2018, 4:40:51 PM3/5/18
to Automate
FYI: I was able to work around this thanks to a tip from the Tasker community, if you play a sound (I'm playing a ringtone on the notification channel) before you try to capture the media button listener, it will work.

ryan...@gmail.com

unread,
Mar 22, 2018, 1:36:35 AM3/22/18
to Automate
Hey Ansel, I downloaded your Block Bluetooth Autoplay automate script...is it possible to make it so the Bluetooth media control buttons never work? I mean is it possible to prevent the media buttons from ever associating with any music player?

Thanks
Ryan

Message has been deleted

sal...@salguod.net

unread,
Mar 23, 2018, 5:26:59 PM3/23/18
to Automate
Ansel,

Sorry I never got back to you, but I never was able to get it to work reliably.  Part of the problem was that when connecting to a bluetooth device like my car, I didn't always get an app that would try to auto play.  So I couldn't tell if the script was working or if there simply wasn't an auto play attempt made.

It looks like you figured it out, so I'll look for it to download.

P Chan

unread,
Apr 28, 2018, 9:40:09 AM4/28/18
to Automate
The only way I make it work is to force using Google music to start playing every time bluetooth connected and pause playing after 3 seconds

Seems like it is because there is a delay after Bluetooth is connected, so it is not that reliable.

Please share if any one can make the stop playing work.

I end up using this app
https://play.google.com/store/apps/details?id=com.cp2.bluetooth.connect.and.stop.play

kurtka...@gmail.com

unread,
Sep 18, 2020, 10:11:06 AM9/18/20
to Automate
For anyone that experiences the dreaded autoplay of [audio player app] when a car's Bluetooth system connects, here's a workaround that can be customized for any(?) BT device and app; I hope it's useful to others:
(Each line represents a block)

"When BT device connected [your car]"

Delay 4s (may require longer/shorter)

Set audio volume %10 (don't want to hear it, really)

Delay 6s (may require longer/shorter)

Audio player control [Command stop, Method media button], Package [audio player app], Receiver class [see what works]

Delay 2s (may require longer/shorter)

Audio player control [Command stop, Method media button], Package [audio player app], Receiver class [see what works]
Yes, again, just in case it's really stubborn!

Set audio volume %50 (or whatever you'd prefer)
I suppose, if you want, you might be able to query the original volume before you begin, assign it to a variable, and then set the volume back to the variable when this script is over.

I don't know if this will work for everyone, but I've been scared out of my wits enough times by the car's unanticipated high-volume Play Start that I had to do something!  None of the other solutions seemed to work. Improvements welcomed.

Fran T

unread,
Sep 18, 2020, 6:00:20 PM9/18/20
to Automate
You can also use this flow which monitors the volume on each of your Bluetooth devices and sets it back to the volume you left it at the next time you connect to it 🙂

https://llamalab.com/automate/community/flows/30959

kurtka...@gmail.com

unread,
Sep 19, 2020, 3:22:29 PM9/19/20
to Automate
Yes, that could be handy, but my flow is really designed for a single device (my car), and a single app (a podcast player).  Under no other conditions do I have this autoplay problem, so I don't really need to account for any other devices here. If it happened on multiple devices, then I might consider just lowering the volume upon any BT connection.
Reply all
Reply to author
Forward
0 new messages