diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-12-10 15:29:26 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-12-10 15:29:26 -0800 |
commit | 22d7ca9e2d67fcac6966b3abc3c5d43884ebd145 (patch) | |
tree | 075c31630dbec5830339bf8c7e1083cff4891bcf /src | |
parent | 62043e9f81f52cec492a7736f3514acc54789ff8 (diff) | |
download | dsub-22d7ca9e2d67fcac6966b3abc3c5d43884ebd145.tar.gz dsub-22d7ca9e2d67fcac6966b3abc3c5d43884ebd145.tar.bz2 dsub-22d7ca9e2d67fcac6966b3abc3c5d43884ebd145.zip |
Hide actual volume quantity behind 10 volume increments
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/provider/DLNARouteProvider.java | 8 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DLNAController.java | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java index 4a1ea067..e2450f1f 100644 --- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java +++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java @@ -161,13 +161,17 @@ public class DLNARouteProvider extends MediaRouteProvider { for(Map.Entry<String, DLNADevice> deviceEntry: devices.entrySet()) { DLNADevice device = deviceEntry.getValue(); + int increments = device.volumeMax / 10; + int volume = controller == null ? device.volume : (int) controller.getVolume(); + volume = volume / increments; + MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder(device.id, device.name); routeBuilder.addControlFilter(routeIntentFilter) .setPlaybackStream(AudioManager.STREAM_MUSIC) .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE) .setDescription(device.description) - .setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10)) - .setVolumeMax(device.volumeMax) + .setVolume(volume) + .setVolumeMax(10) .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); providerBuilder.addRoute(routeBuilder.build()); } diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java index 522bf586..b863068b 100644 --- a/src/github/daneren2005/dsub/service/DLNAController.java +++ b/src/github/daneren2005/dsub/service/DLNAController.java @@ -232,6 +232,12 @@ public class DLNAController extends RemoteController { @Override
public void setVolume(int volume) {
+ if(volume < 0) {
+ volume = 0;
+ } else if(volume > device.volumeMax) {
+ volume = device.volumeMax;
+ }
+
device.volume = volume;
controlPoint.execute(new SetVolume(device.renderer.findService(new ServiceType("schemas-upnp-org", "RenderingControl")), volume) {
@SuppressWarnings("rawtypes")
@@ -244,7 +250,8 @@ public class DLNAController extends RemoteController { @Override
public void updateVolume(boolean up) {
- setVolume(device.volume + (up ? 1 : -1));
+ int increment = device.volumeMax / 10;
+ setVolume(device.volume + (up ? increment : -increment));
}
@Override
|