Search code examples
javaandroidspotifyremote-accesslibspotify

How can an Android application function as a remote controller to a desktop application? (Spotify)


I am in the planning stages of developing an Android application to control my Spotify player. Since I am running Debian on my system, the options that are available on the Play Store are quite limited (I can't find any functioning apps). Therefore, the programmer inside me tells me to build one. I haven't built an Android application before, but I have good experience with working with APIs so I think this could be a pretty decent starter project for me.

However, I am having some difficulties grasping some of the concepts on how I could implement this. With some research of the Spotify API documentation, I believe the Spotify Apps API is the one I should be using to control playback on the desktop.

On the Android side of things, I would imagine I would use the Spotify Apps API in conjunction with the Libspotify API to receive metadata and display what the application is getting from the desktop playback.

What I am having troubles understanding is how does the Android application talk with the Spotify desktop client? I have a few ideas, but I am unsure...

My thought process so far is as follows:

  1. have a local webserver on the desktop open up and begin listening
  2. on the Android application, connect to the desktop's webserver (how do you do this?)
  3. once connected, the desktop sends metadata/other information to populate the Android application
  4. from the Android UI, hitting a UI button will send a request to the webserver, where it parses the data, completes an action, and then returns the response to the Android application

I am a little lost on what tools I need to learn and use to get this working. Any suggestions to the implementation are greatly appreciated!

Thank you!


Solution

  • Your approach is correct.

    On host (desktop), open a socket and listen on port 80 (or another port if you wish) and listen. It doesn't need to be a full web server.

    On client (Android), to start with send an http request to the desktop' ip address. Desktop responds with a simple web page.

    That's how you get the two communicating.

    Then you can start POSTing data to the desktop and returning data in the web page.

    Then you can move to communicating using JSON rather than web pages.

    You can program both the host and client using Qt. You can develop both on the desktop and move the client to Android (or iPad) when you have got it working.