Tasker – Spotify Plug, Load and Play

Standard

Unti2rtled-1

 

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.

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.

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 or which you prefer,

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.

If you are using Android 5.0+ and it doesn’t play, try using Play/Pause instead.

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.

Screenshot_2015-03-05-16-32-23

About these ads

32 thoughts on “Tasker – Spotify Plug, Load and Play

  1. abcd

    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.

  2. 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

  3. Emil

    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.

  4. Quint

    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.

    • Quint

      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.

  5. Quint

    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.

  6. Scrat

    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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s