Fun with Android intents and Spotify

I was taking a look on how to make my life easier with Llama. I wanted to start Spotify when my phone connected to the Bluetooth adapter in my car, so instead of using the default “Launch Application” feature from Llama, I started looking around on how to improve it. I always start my starred playlist. So, I could directly show it by adding an Android Intent with the following parameters:

Or the equivalent, with ADB:

Taking a deeper look I could start to directly play something (note that not my starred playlist) using the android.media.action.MEDIA_PLAY_FROM_SEARCH feature:

I also managed to fake play/stop key presses, this one is trivial:

I’d be glad to hear from you if you manage to directly play your starred playlist, so I could even save a tap on my phone after getting into the car.

  • I have your answer! After a little bit of searching I found this little trick.

    First of all I don’t use Llama but I am a Tasker person (only app that I never regret paying for).

    So I don’t know if you can run shell commands within Llama, but anyways:

    By the way it seems you need to be able to execute these commands…

    First thing to do is to send a view intent so that your spotify playlist will open up (just like you did),

    And the second thing to do is to call a play/pause script just like you did with adb.

    You can -and should- directly use the constant name instead of using numbers. Even better thing is

    you have KEYCODE_MEDIA_PREVIOUS and NEXT which opened a whole new world for me.

    I was looking for a way to go to the previous track without having to get my phone out of my pocket just

    with my headset. Unfortunately one click on the media button acts for play/pause and double click on the

    media button acts for next track. So I solved my problem by writing a task for Volume Level 0. If volume

    level gets down to 0 while Spotify is On + Headset is Plugged I send PREVIOUS event. Hope this could be

    helpful for you.

    p.s. within all the things that I found, your blog was still the most useful one.

    Regards,

  • Shivan

    Hi,

    I’m trying this with the current version of the spotify app, which

    newly supports saving last played song.

    So I’m trying to implement “play” on BT-Connect with tasker. But currently I’ve got the following problems:

    using “simulate play” starts the samsung mp3 player
    using  “toggle play/pause” starts google music

    Both can’t be uninstalled.

    Any suggestions?

  • Corey Brown

    Hey Alp,
    Nice work. Do you put a delay of some sort between starting Spotify? I have both in a task, and have managed to get them to work individually, but not serially.
    Thanks,
    Corey

  • Gregory Parlett

    Hi

    I stumbled across this blog whilst looking for a way to create a play/pause button for my home screen using Llama. I don’t want to open the app, just play the next song on the playlist. Is this something that can be done?

    Unfortunately I am not a programmer but I can follow instructions. Any help – in simple terms 🙂 would be much appreciated. My phone is a rooted but otherwise unmolested Note 2, if that helps.

    Thanks.

  • stevenjoseph

    using the instructions i can get lama to start spotify and show the starred playlist but not start playing..

  • ryan

    I think that this would be a cool feature, but outside llama…you could use OK Google and just say “play spotify…” or “play…on spotify” If you are looking a specific band,album,and so on “play…” It’s that simple.

    The obvious downside being that you would have to unlock the phone and open Google+ unless you have it set up to listen from any screen.

    I understand this is not the answer to your question, but it’s the work around I’m using.