Sunday, February 24, 2013

DashClock Music API V1

There are several ways to add support for your app to the DashClock Music Extension.

1) The dashclock music api:

Intents:
gonemad.dashclock.music.metachanged - Whenever the currently playing song changes (or is first played)
gonemad.dashclock.music.playstatechanged - Changing between playing and pausing
gonemad.dashclock.music.playbackcomplete - When playback completes

Examples:
When starting to play music or a new song plays.. send:
Intent intent = new Intent(gonemad.dashclock.music.metachanged);
intent.putExtra("artist", "current artist");
intent.putExtra('album", "current album");
intent.putExtra("track ", "current track name");
intent.putExtra("playing", true);

context.sendBroadcast(intent);

When playback is paused or resumed:

Intent intent = new Intent(gonemad.dashclock.music.playstatechanged);
intent.putExtra("artist", "current artist");
intent.putExtra('album", "current album");
intent.putExtra("track ", "current track name");
intent.putExtra("playing", true or false);  //the only mandatory field for this intent

context.sendBroadcast(intent);

When playback is finished:

Intent intent = new Intent(gonemad.dashclock.music.playbackcomplete);
context.sendBroadcast(intent);

2) Implement the simple last.fm scrobbler api: http://code.google.com/p/a-simple-lastfm-scrobbler/wiki/Developers

3) Implement the scrobble droid api:  http://code.google.com/p/scrobbledroid/wiki/DeveloperAPI

4) Implement the official last.fm app's api.  Can't seem to find documentation on this currently

5) Implement the stock android music player intents:
com.android.music.playstatechanged
com.android.music.metachanged