aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-11-04 16:53:42 -0800
committerdaneren2005 <daneren2005@gmail.com>2013-11-04 16:53:42 -0800
commit1d25d45bc08e9427bdcb465201473e8cda507893 (patch)
treef4ce1704408cf7b907cc55f7a65f37273a9cc942 /src
parentef189890cf2fc4afc8c5736e36d2ef5197d6d791 (diff)
downloaddsub-1d25d45bc08e9427bdcb465201473e8cda507893.tar.gz
dsub-1d25d45bc08e9427bdcb465201473e8cda507893.tar.bz2
dsub-1d25d45bc08e9427bdcb465201473e8cda507893.zip
Create Remote Control Client for JB devices
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
new file mode 100644
index 00000000..f0008a9b
--- /dev/null
+++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
@@ -0,0 +1,50 @@
+package github.daneren2005.dsub.util.compat;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.ImageLoader;
+import android.annotation.TargetApi;
+import android.app.PendingIntent;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.media.MediaMetadataRetriever;
+import android.media.RemoteControlClient;
+import github.daneren2005.dsub.activity.SubsonicActivity;
+import github.daneren2005.dsub.service.DownloadService;
+
+@TargetApi(16)
+public class RemoteControlClientJB extends RemoteControlClientICS {
+ @Override
+ public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
+ super.register(context, mediaButtonReceiverComponent);
+
+ mRemoteControl.setOnGetPlaybackPositionListener(new RemoteControlClient.OnGetPlaybackPositionListener() {
+ @Override
+ public long onGetPlaybackPosition() {
+ return downloadService.getPlayerPosition();
+ }
+ });
+ mRemoteControl.setPlaybackPositionUpdateListener(new RemoteControlClient.OnPlaybackPositionUpdateListener() {
+ @Override
+ public void onPlaybackPositionUpdate(long newPosition) {
+ downloadService.seekTo((int) newPosition);
+ }
+ });
+ }
+
+ @Override
+ public void setPlaybackState(final int state) {
+ long position = -1;
+ if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
+ position = downloadService.getPlayerPosition();
+ }
+ mRemoteControl.setPlaybackState(state, position, 1.0f);
+ }
+
+ @Override
+ protected int getTransportFlags() {
+ return super.getTransportFlags() | RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE;
+ }
+
+}