aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-12-04 21:07:43 -0800
committerScott Jackson <daneren2005@gmail.com>2012-12-04 21:07:43 -0800
commit1e9153b147bacfa7c9a766ab729e9f8f467ea80a (patch)
tree64aa00c4f6ef3d70ebd53b5826b9d90e3d411065 /subsonic-android/src
parentad6592a3fac30177ab7201940b79bcf9b2f07b58 (diff)
downloaddsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.tar.gz
dsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.tar.bz2
dsub-1e9153b147bacfa7c9a766ab729e9f8f467ea80a.zip
Fixed volume lowering for app only instead of stream
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java7
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java6
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);
}
}
}