Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to control the spotify desktop client from a browser with custom controls?

Tags:

spotify

I am a developer for playmoss where users can create playlists with different music services.

We are planning on adding Spotify support to our playlists in a way similar to what bop.fm does.

Context

Taking for example this playlist (in which all songs are available on spotify, at least in Spain)… https://bop.fm/p/o12l

…if we have the spotify client installed in our computer (tested with a Mac) As soon as the playlist starts playing we can click the spotify icon on the top right [picture]and we will be playing the songs through spotify.

BOP control interface

Using the bop.fm control interface we can pause, play, skip next, even skip to a point in the track with progress bar. This is similar but even more powerful than the official spotify play button, see an example here: http://jsfiddle.net/insonorizate/a5jf39yn/

With the play button there is previous, play, pause, next functionality but not seek.

Of course it can not be customized in any way nor called from javascript. (in bop.fm is possible to open a debuger console and call

Bop.Player.pause()

or

Bop.Player.play()

to pause or play the track beeing played in bop.fm via spotify)

Fiddling a little with the bop.fm page there are some interesting things. Ther is an iframe in the main page poiting to:

https://embed.spotify.com/remote-control-bridge/

Viewing this iframe source we find something like this:

// Expose the OAuth Token to the Javascript
var tokenData = 'NAowChgKB1Nwb3RpZnkSABoGmAEByAEBJReQCFQSFG2Ynvz1oBKgxv2mE1XXz_1Au-cg';

// Pass the remote control to the bridge
var remoteControlBridge = new Spotify.RemoteControlBridge();
remoteControlBridge.init(tokenData);

There's no documentation for Spotify.RemoteControlBridge (0 results for "Spotify.RemoteControlBridge" on google) and there isn't any thing in the documentation of the different apis even close to controling the spotify player in a way similar to this.

Question

How can I control the spotify desktop app from a browser?

Does bop.fm have any special arrangment with spotify and they are using some "secret api"?

Are they exploiting some functionality that I fail to find?

Is it possible to replicate it?

Is it in accordance with the Spotify terms?

Thanks!

like image 906
Miquel Adell Avatar asked Sep 04 '14 12:09

Miquel Adell


1 Answers

You can't control the Spotify Client or Listen to Events the Spotify Web Helper is emitting. Imagine everybody could: every website could potentially play a song without your permission or even know instantly what you are listening to. To prevent this Spotify only allows approved partners to use this feature.

As you figured out the remote-control-bridge provides this functionality. It can communicate with the Spotify Web Helper running on your system, which is secured by an OAuth and a CSRF Token. In the remote-control-bridge you even can see the allowed partners:

  • Spotify (who knew)
  • Yahoo
  • last.fm
  • coachella.com
  • bop.fm
  • sandpit.us
  • echonest
  • musixmatch

You can contact them and ask for a partnership. I'm sure they won't bite.

like image 165
Timo Mämecke Avatar answered Oct 15 '22 20:10

Timo Mämecke