aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java6
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java13
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java14
5 files changed, 16 insertions, 21 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index a6bbc327..1cf482ca 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1469,7 +1469,7 @@ public class DownloadService extends Service {
Notifications.hidePlayingNotification(this, this, handler);
}
if(mRemoteControl != null) {
- mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState());
+ mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState(), getCurrentPlayingIndex(), size());
}
if (playerState == STARTED) {
@@ -2842,6 +2842,8 @@ public class DownloadService extends Service {
final Integer duration = getPlayerDuration();
final boolean isSeekable = isSeekable();
final int position = getPlayerPosition();
+ final int index = getCurrentPlayingIndex();
+ final int queueSize = size();
synchronized(onSongChangedListeners) {
for (final OnSongChangedListener listener : onSongChangedListeners) {
@@ -2861,7 +2863,7 @@ public class DownloadService extends Service {
@Override
public void run() {
if(mRemoteControl != null) {
- mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState());
+ mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState(), index, queueSize);
}
}
});
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java
index 1f7035dc..4f9a27f0 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java
@@ -29,7 +29,7 @@ public abstract class RemoteControlClientBase {
public abstract void register(final Context context, final ComponentName mediaButtonReceiverComponent);
public abstract void unregister(final Context context);
- public abstract void setPlaybackState(int state);
+ public abstract void setPlaybackState(int state, int index, int queueSize);
public abstract void updateMetadata(Context context, MusicDirectory.Entry currentSong);
public abstract void metadataChanged(MusicDirectory.Entry currentSong);
public abstract void updateAlbumArt(MusicDirectory.Entry currentSong, Bitmap bitmap);
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
index 2a06e798..74076afb 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
@@ -54,7 +54,7 @@ public class RemoteControlClientICS extends RemoteControlClientBase {
audioManager.unregisterRemoteControlClient(mRemoteControl);
}
- public void setPlaybackState(final int state) {
+ public void setPlaybackState(final int state, int index, int queueSize) {
if(mRemoteControl == null) {
return;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
index e61e9a47..d10c8594 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java
@@ -1,17 +1,10 @@
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;
+
import github.daneren2005.dsub.util.SilentBackgroundTask;
@TargetApi(18)
@@ -36,13 +29,13 @@ public class RemoteControlClientJB extends RemoteControlClientICS {
return null;
}
}.execute();
- setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
+ setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING, 0, 0);
}
});
}
@Override
- public void setPlaybackState(final int state) {
+ public void setPlaybackState(final int state, int index, int queueSize) {
if(mRemoteControl == null) {
return;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
index df468155..d666afb2 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
@@ -39,7 +39,6 @@ import android.support.v7.media.MediaRouter;
import android.util.Log;
import android.view.KeyEvent;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -50,7 +49,6 @@ import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.MusicDirectory.Entry;
import github.daneren2005.dsub.domain.Playlist;
-import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.domain.SearchCritera;
import github.daneren2005.dsub.domain.SearchResult;
import github.daneren2005.dsub.service.DownloadFile;
@@ -123,8 +121,12 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
mediaSession.release();
}
+ private void setPlaybackState(int state) {
+ setPlaybackState(state, downloadService.getCurrentPlayingIndex(), downloadService.size());
+ }
+
@Override
- public void setPlaybackState(int state) {
+ public void setPlaybackState(int state, int index, int queueSize) {
PlaybackState.Builder builder = new PlaybackState.Builder();
int newState = PlaybackState.STATE_NONE;
@@ -156,7 +158,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
isSong = entry.isSong();
}
- builder.setActions(getPlaybackActions(isSong));
+ builder.setActions(getPlaybackActions(isSong, index, queueSize));
if(entry != null) {
addCustomActions(entry, builder);
@@ -240,14 +242,12 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
return mediaSession;
}
- protected long getPlaybackActions(boolean isSong) {
+ protected long getPlaybackActions(boolean isSong, int currentIndex, int size) {
long actions = PlaybackState.ACTION_PLAY |
PlaybackState.ACTION_PAUSE |
PlaybackState.ACTION_SEEK_TO |
PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM;
- int currentIndex = downloadService.getCurrentPlayingIndex();
- int size = downloadService.size();
if(isSong) {
if (currentIndex > 0) {
actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS;