NOTICE!
Since the method I posted before doesn’t work on Android L 5.0 and up, I’ve edited a few steps. This fix was mentioned by Quint in the comment section. Thanks Quint!
Introduction:
This tutorial explains how to make your Tasker app launch Spotify when you plug in your headphones, then raise the volume and play the last played track.
What You’ll Need:
Tasker by Crafty Apps EU
STEP 1
We will need to setup the profile that triggers when you plug your headphones in.
• Open your Tasker application.
• Select the “Profiles” tab in the top left.
• Click the “+” icon in the bottom right.
• Click on “State“.
• Select “Hardware“.
• Select “Headset Plugged” and leave the settings as they are and press back.
STEP 2
Now we will setup the task (actions) that will occur when the profile is triggered.
Loading Spotify
• Press the “New Task +” that appeared.
• Let’s name it “Spotify Plug Play“.
• Click the “+” icon at the bottom to add an action.
• Select the “App” category.
• Select “Load App“. Find Spotify and select it.
• Press back.
STEP 3
Add a Wait action.
(This is to make sure the app is fully loaded before pressing play.)
• Click the “+” at the bottom.
• Select the “Task” category.
• Select “Wait“.
• Set Seconds to 5 or which you prefer,
STEP 4
Raise the Volume
• Click the “+” icon at the bottom to add another action.
• Select the “Audio” category.
• Select “Media Volume” and set Level to your desired volume.
• Press back.
STEP 5
Getting Spotify to play.
• Click the “+” icon at the bottom.
• Select the “System” category.
• Select “Send Intent”
• Set these fields:
– Action: com.spotify.mobile.android.ui.widget.PLAY
– Cat: None
– Package: com.spotify.music
– Target: Broadcast Reciever
AND WE’RE DONE!
If you do not have any headphones to test this with, press the play icon down to the left.
It perfectly works!!! Thanks a lot!
Yeah, it works, thanks. I tried the input keyevent commands first to start playing, but that did not work with the screen off, this Media Utilities stuff works with the screen off.
how did you do that?
I’ve made this tasks… but the music don’t starts
Sorry for the very late reply.
Did you solve it or does it still not work?
Still not working for me
It works fine
Buenísimo! Muchas gracias funciona a la perfección!
Everything appeared to configure correctly but not doing anything this end. Tried smart play too. S5. Thanks for the method though, really helped. Will have a play will more than likely be some slight update to Spotify or music utils. Cheers Marc
Ok changed music utils to Samsung music app and worked fine. Spotify must be doing something funky in the new app update.
Funciona bem, porém se não tiver música no escutador, não executa
Muchas gracias!
No funcionaba,reinicie y listo!At first not work but reset my phone and work!
thank u!
NOICE, this works perfectly
Great tip. Thanks a lot! Any idea on how to launch a specific playlist?
hi, tx for the great tip & same question about a specific playlist…any idea please? tx
Check out this post
http://danny.gb.net/tasker-autoplay-spotify-playlist/
I use YouTube a lot and it was bugging me that it turned on spotify when I was watching YouTube. So I added an if statement in the beginning which checks if the screen is off, if it is off it starts Spotify, else it just sets the volume to 7.
Thanks man!
This doesn’t work anymore with Lollipop 5.0.1 update (using LG G3 D850 on AT&T)
Any other workaround?
As I do not have a device with Android L to test it on, I have not yet figured out a solution.
I will update it when it happens.
I would appreciate that, thanks Nick!
sadly, doesn’t work on lollipop (galaxy s5)..
It does work with android L just choose Play/pause instead of Play (Smart)
I do have a HTC One M8
Doesn’t work on Lollipop on my G3, but I found another way of doing this.
Using the Autoinput plugin for Tasker works.
Add an Autoinput Action with the following fields:
1) Action: Click
2) Field Type: Id
3) com.spotify.music:id:playPause
Use this in place of the Media Utilities command above.
Actually, I got tipped off to an even better solution.
Replace the Media Utilities plugin “Play” command with the following intent:
Action: com.spotify.mobile.android.ui.widget.PLAY
Cat: None
Package: com.spotify.music
Target: Broadcast Receiver
Works flawlessly. I am also using it in a Profile/Task that pauses Spotify whenever I get an email and reads the notification to me before resuming Spotify.
Confirmed. This works too. Are you using Android L 5.0+ ?
Yes. 5.0.1 on an LG G3.
I’ve updated the tutorial with your solution. Thanks alot.
Hello,
Is there a command to pause ? I tried “com.spotify.mobile.android.ui.widget.PAUSE” but doesn’t seem to work.
Same command as play. It’s a toggle, there is no direct intent command for the widget that is for pause that I am aware of.
Nice tip, thanks. Would you have a suggestion as to how can I close spotify once I remove the headphones?
Works perfectly for me.
Two question. Is it possible to shuffle the play List and then start playing it. And is it possible to slowly raise the volume. For example from 1 to 7 in 3 seconds.
Would be awesome if someone can tell me the Code
com.spotify.mobile.android.ui.widget.xxxxx
Works graet. Is it possible to start the app with a Spotify Connect device (Gramofon, Allplay Speaker)? This be very helpful. Also as already asked, to start in shuffle mode. Thanks
I’m using Sony Z3 Compact wuth Android 5.0.2. and it is not working.
It Spotify starts playing only, if I started Spotify manually, than tapped the Shuffle button,paused Spotify. Only then the intend is working. At that point I do not like Spotify.
In my case only AutoInput is working
It works very well, but only if i recenctly used spotify, if i’ve just rebooted my device, or havent used the app for a while, it doesn’t know what to play, it kinds of forgets the last played track, so it just opens and stays there. Does anyone have a solution for this? i’ve checked if any other app is force closing it but i think everything is fine, i don’t know how to fix this. Any thoughts?
Yes, same thing here. I’m looking for something that can put some random playlist do to the play or something like that. If i find i’ll tell u!
Guys, i guess i’ve found a solution when spotify doesn’t know what to play. (reboot device or havent used the app for a while)
I took this idea from an user call Navycow in reddit’s topic. He use in a diferrent way to set the play task (he uses run shell that requires root, very good idea thought!)
What you have to change here is the open app task
Don’t use Launch App. Use Net-Browse URL and put http://open.spotify.com/user//Starred
At first, you will need to choose spotify do open as aways.
Soo, what this command does?? He open your spotify with the player already.
of the rest use the same things.
Shit, the real link is Browse URL, http://open.spotify.com/user/“YourUserName”/Starred
Is there any way it can start playing songs? it only starts the spotify app for me
Im using a s5 and its not working completely. When I hit the test, it opens and does it perfectly, but when I plug in the headphones nothing happens. The task and profile say its activated but nothing happens. Did I do something wrong? is someone else having this issue?
Thanks again!
anyone test this on Samsung Galaxy S5?
Yeah can’t get it to work
Hi everyone,
i created an android app to start play spotify on headset/bluetooth device connect. Its currently in Alpa – for free. Anyone testing it would be appreciated -> https://play.google.com/apps/testing/com.dasanderl.spotifyautoplay
Bye, Andi
Do you need to be rooted to trigger the “PLAY” action? It launches just fine, but it does not start playing!?!?
You do not need to be rooted. But Spotify needs to have a Playlist running for this to work.
Ca’t get it to run on Nexus 5S with 6.0. Any workarounds ?
Not working with Sony E6533 upgraded to Marshmallow (nor previously with Lollipop). I saw a lot of forums citing Spotify does not start or play if the screen is locked. Any experience with that?