aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-11-20 21:53:30 -0800
committerScott Jackson <daneren2005@gmail.com>2012-11-20 21:53:30 -0800
commit4770337d1e8c78facb5fe4f5bf7bfcd428e2cfa9 (patch)
tree8732d3cc884da72f8963fbca71835da3d93c9d0c /subsonic-android
parentd276719f673c4e87a61cb2a2bb8c0723967f1302 (diff)
downloaddsub-4770337d1e8c78facb5fe4f5bf7bfcd428e2cfa9.tar.gz
dsub-4770337d1e8c78facb5fe4f5bf7bfcd428e2cfa9.tar.bz2
dsub-4770337d1e8c78facb5fe4f5bf7bfcd428e2cfa9.zip
Added Bluetooth metadata
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/AndroidManifest.xml6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/receiver/A2dpIntentReceiver.java48
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java29
3 files changed, 83 insertions, 0 deletions
diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml
index d786ff8f..90039be5 100644
--- a/subsonic-android/AndroidManifest.xml
+++ b/subsonic-android/AndroidManifest.xml
@@ -103,6 +103,12 @@
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
</intent-filter>
</receiver>
+
+ <receiver android:name="net.sourceforge.subsonic.androidapp.receiver.A2dpIntentReceiver">
+ <intent-filter>
+ <action android:name="android.music.playstatusrequest"/>
+ </intent-filter>
+ </receiver>
<receiver android:name="github.daneren2005.dsub.provider.DSubWidgetProvider" >
<intent-filter>
diff --git a/subsonic-android/src/github/daneren2005/dsub/receiver/A2dpIntentReceiver.java b/subsonic-android/src/github/daneren2005/dsub/receiver/A2dpIntentReceiver.java
new file mode 100644
index 00000000..c8c3a1f9
--- /dev/null
+++ b/subsonic-android/src/github/daneren2005/dsub/receiver/A2dpIntentReceiver.java
@@ -0,0 +1,48 @@
+package github.daneren2005.dsub.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.service.DownloadServiceImpl;
+
+public class A2dpIntentReceiver extends BroadcastReceiver {
+ private static final String PLAYSTATUS_RESPONSE = "com.android.music.playstatusresponse";
+ private String TAG = A2dpIntentReceiver.class.getSimpleName();
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "GOT INTENT " + intent);
+
+ DownloadService downloadService = DownloadServiceImpl.getInstance();
+
+ if (downloadService != null){
+
+ Intent avrcpIntent = new Intent(PLAYSTATUS_RESPONSE);
+
+ avrcpIntent.putExtra("duration", (long) downloadService.getPlayerDuration());
+ avrcpIntent.putExtra("position", (long) downloadService.getPlayerPosition());
+ avrcpIntent.putExtra("ListSize", (long) downloadService.getSongs().size());
+
+ switch (downloadService.getPlayerState()){
+ case STARTED:
+ avrcpIntent.putExtra("playing", true);
+ break;
+ case STOPPED:
+ avrcpIntent.putExtra("playing", false);
+ break;
+ case PAUSED:
+ avrcpIntent.putExtra("playing", false);
+ break;
+ case COMPLETED:
+ avrcpIntent.putExtra("playing", false);
+ break;
+ default:
+ return;
+ }
+
+ context.sendBroadcast(avrcpIntent);
+ }
+ }
+} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 7616964b..f8d108d3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -58,6 +58,7 @@ import github.daneren2005.dsub.domain.RepeatMode;
import github.daneren2005.dsub.domain.Version;
import github.daneren2005.dsub.provider.DSubWidgetProvider;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
+import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import org.apache.http.HttpEntity;
@@ -98,6 +99,9 @@ public final class Util {
public static final String EVENT_META_CHANGED = "github.daneren2005.dsub.EVENT_META_CHANGED";
public static final String EVENT_PLAYSTATE_CHANGED = "github.daneren2005.dsub.EVENT_PLAYSTATE_CHANGED";
+ public static final String AVRCP_PLAYSTATE_CHANGED = "com.android.music.playstatechanged";
+ public static final String AVRCP_METADATA_CHANGED = "com.android.music.metachanged";
+
private static boolean pauseFocus = false;
private static boolean lowerFocus = false;
private static int currentVolume = 0;
@@ -784,7 +788,9 @@ public final class Util {
* <p>Broadcasts the given song info as the new song being played.</p>
*/
public static void broadcastNewTrackInfo(Context context, MusicDirectory.Entry song) {
+ DownloadService downloadService = (DownloadServiceImpl)context;
Intent intent = new Intent(EVENT_META_CHANGED);
+ Intent avrcpIntent = new Intent(AVRCP_METADATA_CHANGED);
if (song != null) {
intent.putExtra("title", song.getTitle());
@@ -793,14 +799,31 @@ public final class Util {
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
intent.putExtra("coverart", albumArtFile.getAbsolutePath());
+
+ avrcpIntent.putExtra("track", song.getTitle());
+ avrcpIntent.putExtra("artist", song.getArtist());
+ avrcpIntent.putExtra("album", song.getAlbum());
+ avrcpIntent.putExtra("ListSize",(long) downloadService.getSongs().size());
+ avrcpIntent.putExtra("id", (long) downloadService.getCurrentPlayingIndex()+1);
+ avrcpIntent.putExtra("duration", (long) downloadService.getPlayerDuration());
+ avrcpIntent.putExtra("position", (long) downloadService.getPlayerPosition());
} else {
intent.putExtra("title", "");
intent.putExtra("artist", "");
intent.putExtra("album", "");
intent.putExtra("coverart", "");
+
+ avrcpIntent.putExtra("track", "");
+ avrcpIntent.putExtra("artist", "");
+ avrcpIntent.putExtra("album", "");
+ avrcpIntent.putExtra("ListSize",(long)0);
+ avrcpIntent.putExtra("id", (long) 0);
+ avrcpIntent.putExtra("duration", (long )0);
+ avrcpIntent.putExtra("position", (long) 0);
}
context.sendBroadcast(intent);
+ context.sendBroadcast(avrcpIntent);
}
/**
@@ -808,25 +831,31 @@ public final class Util {
*/
public static void broadcastPlaybackStatusChange(Context context, PlayerState state) {
Intent intent = new Intent(EVENT_PLAYSTATE_CHANGED);
+ Intent avrcpIntent = new Intent(AVRCP_PLAYSTATE_CHANGED);
switch (state) {
case STARTED:
intent.putExtra("state", "play");
+ avrcpIntent.putExtra("playing", true);
break;
case STOPPED:
intent.putExtra("state", "stop");
+ avrcpIntent.putExtra("playing", false);
break;
case PAUSED:
intent.putExtra("state", "pause");
+ avrcpIntent.putExtra("playing", false);
break;
case COMPLETED:
intent.putExtra("state", "complete");
+ avrcpIntent.putExtra("playing", false);
break;
default:
return; // No need to broadcast.
}
context.sendBroadcast(intent);
+ context.sendBroadcast(avrcpIntent);
}
/**