Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is it possible to know what's spotify is playing from an external Android app?

I just found out this settings option in Spotify for Android settings screen:

"Device broadcast status - allow other apps on your device to see what you are listening to"

I guess that means any other app can access what's being played via Spotify. How can this be implemented? Is there any documentation around?

Thanks

like image 288
Romain Piel Avatar asked Jun 21 '13 13:06

Romain Piel


People also ask

How does Spotify integrate with Android apps?

Download and install the Spotify Android SDK. Also, go to google play store and download the Spotify app. Install it and log in with the email and password or register. Inside your android app code, go to the service you want to integrate with Spotify, if you do not have one create a service or activity.

What is device broadcast status in Spotify?

"Device broadcast status - allow other apps on your device to see what you are listening to"

How does Spotify integrate with the app?

Install Spotify App App Remote SDK requires the Spotify app to be installed on the device. Install the latest version of Spotify from Google Play on the device you want to use for development. Run the Spotify app and login or sign up.

Is Spotify a native Android app?

When we talk about apps, we're really talking about native apps. Your Facebook app, your Twitter app, your Spotify app: all these apps are native.


2 Answers

Spotify broadcasts using the standard com.android.music.metachanged intent-action. Register a BroadcastReceiver for that intent-action, then just pick out metadata using

String artist = intent.getStringExtra("artist");
String album = intent.getStringExtra("album");
String track = intent.getStringExtra("track");

like image 75
Freddroid Avatar answered Oct 11 '22 18:10

Freddroid


Spotify has the following intent-actions:

metadatachanged, playbackstatechanged, and queuechanged.

queuechanged contains no extra data.
playbackstatechanged has a boolean value for "playing", and a value for playbackPosition.
metadatachanged contains artist, album, track, length, and id values.

You can get Artist, Track, and Album names when the track is changed (manually or automatically) by using com.spotify.mobile.android.metadatachanged

If Spotify is paused and started again, only playbackstatechanged is broadcast.

like image 38
iamgeef Avatar answered Oct 11 '22 18:10

iamgeef