From d74ccceed909d22a52b08a1f6050ad97324ee88d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 30 Jan 2013 21:18:12 -0800 Subject: Broadcast position constantly to AVRCP --- .../src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 1 + subsonic-android/src/github/daneren2005/dsub/util/Util.java | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'subsonic-android') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 72198850..3d1813ba 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -755,6 +755,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { if(mediaPlayer != null && getPlayerState() == STARTED) { try { cachedPosition = mediaPlayer.getCurrentPosition(); + Util.broadcastCurrentPosition(DownloadServiceImpl.this, cachedPosition); } catch(Exception e) { executorService.shutdown(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 0b7118d0..1936c3f3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -929,6 +929,12 @@ public final class Util { context.sendBroadcast(intent); context.sendBroadcast(avrcpIntent); } + + public static void broadcastCurrentPosition(Context context, int currentPosition){ + Intent avrcpIntent = new Intent(AVRCP_METADATA_CHANGED); + avrcpIntent.putExtra("position", (long)currentPosition); + context.sendBroadcast(avrcpIntent); + } /** * Resolves the default text color for notifications. -- cgit v1.2.3 From 5caffddaf8c4a83132ca87f68dc0926b66a81c62 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 31 Jan 2013 18:44:09 -0800 Subject: Fix broadcasting at regular interval --- subsonic-android/AndroidManifest.xml | 4 ++-- .../src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 2 +- subsonic-android/src/github/daneren2005/dsub/util/Util.java | 8 ++------ 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'subsonic-android') diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index 0f915865..44609b37 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="36" + android:versionName="3.7.3"> diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 3d1813ba..f639e666 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -755,7 +755,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { if(mediaPlayer != null && getPlayerState() == STARTED) { try { cachedPosition = mediaPlayer.getCurrentPosition(); - Util.broadcastCurrentPosition(DownloadServiceImpl.this, cachedPosition); + Util.broadcastNewTrackInfo(DownloadServiceImpl.this, currentPlaying.getSong()); } catch(Exception e) { executorService.shutdown(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 1936c3f3..83a9c988 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -879,6 +879,7 @@ public final class Util { avrcpIntent.putExtra("id", (long) downloadService.getCurrentPlayingIndex()+1); avrcpIntent.putExtra("duration", (long) downloadService.getPlayerDuration()); avrcpIntent.putExtra("position", (long) downloadService.getPlayerPosition()); + avrcpIntent.putExtra("coverart", albumArtFile.getAbsolutePath()); } else { intent.putExtra("title", ""); intent.putExtra("artist", ""); @@ -892,6 +893,7 @@ public final class Util { avrcpIntent.putExtra("id", (long) 0); avrcpIntent.putExtra("duration", (long )0); avrcpIntent.putExtra("position", (long) 0); + avrcpIntent.putExtra("coverart", ""); } context.sendBroadcast(intent); @@ -929,12 +931,6 @@ public final class Util { context.sendBroadcast(intent); context.sendBroadcast(avrcpIntent); } - - public static void broadcastCurrentPosition(Context context, int currentPosition){ - Intent avrcpIntent = new Intent(AVRCP_METADATA_CHANGED); - avrcpIntent.putExtra("position", (long)currentPosition); - context.sendBroadcast(avrcpIntent); - } /** * Resolves the default text color for notifications. -- cgit v1.2.3 From d200272df9a7753dbba058476349d49816fa0303 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 31 Jan 2013 19:06:22 -0800 Subject: Closes #103 Don't pause when in jukebox mode --- .../daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 2 +- subsonic-android/src/github/daneren2005/dsub/util/Util.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'subsonic-android') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 130a00f6..6ff45dee 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -253,7 +253,7 @@ public class DownloadServiceLifecycleSupport { switch (state) { case TelephonyManager.CALL_STATE_RINGING: case TelephonyManager.CALL_STATE_OFFHOOK: - if (downloadService.getPlayerState() == PlayerState.STARTED) { + if (downloadService.getPlayerState() == PlayerState.STARTED && !downloadService.isJukeboxEnabled()) { resumeAfterCall = true; downloadService.pause(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 83a9c988..bbbb0573 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -826,7 +826,7 @@ public final class Util { audioManager.requestAudioFocus(new OnAudioFocusChangeListener() { public void onAudioFocusChange(int focusChange) { DownloadServiceImpl downloadService = (DownloadServiceImpl)context; - if(focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) { + if((focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) && !downloadService.isJukeboxEnabled()) { if(downloadService.getPlayerState() == PlayerState.STARTED) { SharedPreferences prefs = getPreferences(context); int lossPref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_TEMP_LOSS, "1")); @@ -846,7 +846,7 @@ public final class Util { lowerFocus = false; downloadService.setVolume(1.0f); } - } else if(focusChange == AudioManager.AUDIOFOCUS_LOSS) { + } else if(focusChange == AudioManager.AUDIOFOCUS_LOSS && !downloadService.isJukeboxEnabled()) { hasFocus = false; downloadService.pause(); audioManager.abandonAudioFocus(this); -- cgit v1.2.3