The Spotify Android application introduced a 'Device Broadcast Status' switch in a recent release, I want to receive those broadcasts in my application. What broadcasts are available and how should I configure my BroadcastReceiver?
Long rambling version
I am integrating a now playing feature into my Android Application and have it working with most major audio media players. I wanted to hook it into Spotify as well as this is what I primarily use to play music.
com.spotify.mobile.android.playbackstatechanged and com.spotify.mobile.android.metadatachanged
I have used the Device Broadcast Status switch from within the Spotify application itself and I am happy that the switch de/activates these broadcast events.
The problem that I am having is that the messages only seem to be sent sporadically. I receive playstatechanged events when you might expect them (play, pause, next, previous) but they do not contain any information pertinent to the current track. metadatachanged events come through fairly infrequently and with no discernible pattern. Combined this makes it very difficult (read, impossible) to know which track (if any) is currently playing. On a good session things can all go well for hours, metadatachanged events triggered whenever a new song starts, at other times, I might only get one event during a whole session.
I did notice that a flurry of events can be triggered by switching WiFi On/Off, and (possibly) interestingly if I listen to the starred playlist then I get significantly more sensible results.
Some other posts suggested that I should be able to use the standard Android actions com.android.music.playbackcomplete, com.android.music.playstatechanged and com.android.music.metachanged but my version of the Spotify application did not appear to trigger these (I am using them for integration with the standard media player).
I am aware that this is a new feature in the Spotify application and as yet undocumented, but has anyone had any success on integrating this feature into their applications? If so can you share the configuration of your BroadcastReceiver. Or, if there is another better approach, I'd love to hear that too.
The version of the Spotify applicton that I am using is 0.7.4.606.
I've gotten the following Intent Filter actions to work using Spotify 22.214.171.1243: