diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-12-04 21:07:43 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-12-04 21:07:43 -0800 |
commit | 1e9153b147bacfa7c9a766ab729e9f8f467ea80a (patch) | |
tree | 64aa00c4f6ef3d70ebd53b5826b9d90e3d411065 /subsonic-android | |
parent | ad6592a3fac30177ab7201940b79bcf9b2f07b58 (diff) | |
download | dsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.tar.gz dsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.tar.bz2 dsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.zip |
Fixed volume lowering for app only instead of stream
Diffstat (limited to 'subsonic-android')
3 files changed, 11 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index f68f8db6..4f5d2f17 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -126,4 +126,6 @@ public interface DownloadService { void stopSleepTimer(); boolean getSleepTimer(); + + void setVolume(float volume); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 4f76fab4..90cfd238 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -904,6 +904,13 @@ public class DownloadServiceImpl extends Service implements DownloadService { public boolean getSleepTimer() { return sleepTimer != null; } + + @Override + public void setVolume(float volume) { + if(mediaPlayer != null) { + mediaPlayer.setVolume(volume, volume); + } + } private void handleError(Exception x) { Log.w(TAG, "Media player error: " + x, x); diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 13341d64..76b9e56b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -104,7 +104,6 @@ public final class Util { private static boolean pauseFocus = false; private static boolean lowerFocus = false; - private static int currentVolume = 0; private static final Map<Integer, Version> SERVER_REST_VERSIONS = new ConcurrentHashMap<Integer, Version>(); @@ -777,8 +776,7 @@ public final class Util { int lossPref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_TEMP_LOSS, "0")); if(lossPref == 2 || (lossPref == 1 && focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK)) { lowerFocus = true; - currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)Math.ceil(currentVolume / 4.0), 0); + downloadService.setVolume(0.1f); } else if(lossPref == 0 || (lossPref == 1 && focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT)) { pauseFocus = true; downloadService.pause(); @@ -790,7 +788,7 @@ public final class Util { downloadService.start(); } else if(lowerFocus) { lowerFocus = false; - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0); + downloadService.setVolume(1.0f); } } } |