diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-11-04 21:43:19 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-11-04 21:43:19 -0800 |
commit | 00cb1123339b2e62891872efa867bcbe54760da3 (patch) | |
tree | 16f4e271aaee0b43157591290c3e3877c06b982c /src/github | |
parent | 8dcda6d5dc93b1888ed9da8fcba2c50b8263e680 (diff) | |
download | dsub-00cb1123339b2e62891872efa867bcbe54760da3.tar.gz dsub-00cb1123339b2e62891872efa867bcbe54760da3.tar.bz2 dsub-00cb1123339b2e62891872efa867bcbe54760da3.zip |
Change to stable since alpha seems to not even start
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/provider/DLNARouteProvider.java | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java index 11c29d28..d86ebf20 100644 --- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java +++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java @@ -33,15 +33,21 @@ import android.support.v7.media.MediaRouteProvider; import android.support.v7.media.MediaRouteProviderDescriptor; import android.util.Log; -import org.fourthline.cling.android.AndroidUpnpService; -import org.fourthline.cling.android.AndroidUpnpServiceImpl; -import org.fourthline.cling.model.meta.Device; -import org.fourthline.cling.model.meta.LocalDevice; -import org.fourthline.cling.model.meta.RemoteDevice; -import org.fourthline.cling.registry.Registry; -import org.fourthline.cling.registry.RegistryListener; +import org.teleal.cling.android.AndroidUpnpService; +import org.teleal.cling.android.AndroidUpnpServiceImpl; +import org.teleal.cling.model.action.ActionInvocation; +import org.teleal.cling.model.message.UpnpResponse; +import org.teleal.cling.model.meta.Device; +import org.teleal.cling.model.meta.LocalDevice; +import org.teleal.cling.model.meta.RemoteDevice; +import org.teleal.cling.model.meta.StateVariable; +import org.teleal.cling.model.meta.StateVariableAllowedValueRange; +import org.teleal.cling.registry.Registry; +import org.teleal.cling.registry.RegistryListener; +import org.teleal.cling.support.renderingcontrol.callback.GetVolume; import java.util.HashMap; +import java.util.List; import java.util.Map; import github.daneren2005.dsub.domain.DLNADevice; @@ -128,7 +134,7 @@ public class DLNARouteProvider extends MediaRouteProvider { dlnaService = null; } }; - context.bindService(new Intent(context, AndroidUpnpServiceImpl.class), dlnaServiceConnection,Context.BIND_AUTO_CREATE); + context.bindService(new Intent(context, AndroidUpnpServiceImpl.class), dlnaServiceConnection, Context.BIND_AUTO_CREATE); } private void broadcastDescriptors() { @@ -172,16 +178,35 @@ public class DLNARouteProvider extends MediaRouteProvider { return new DLNARouteController(downloadService); } - private void deviceAdded(Device device) { + private void deviceAdded(final Device device) { + final org.teleal.cling.model.meta.Service renderingControl = null; + if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) { - String id = device.getIdentity().getUdn().toString(); - String name = device.getDetails().getFriendlyName(); - String displayName = device.getDisplayString(); - Log.d(TAG, displayName); + dlnaService.getControlPoint().execute(new GetVolume(renderingControl) { + @Override + public void received(ActionInvocation actionInvocation, int currentVolume) { + int maxVolume = 100; + StateVariable volume = renderingControl.getStateVariable("Volume"); + if(volume != null) { + StateVariableAllowedValueRange volumeRange = volume.getTypeDetails().getAllowedValueRange(); + maxVolume = (int) volumeRange.getMaximum(); + } - DLNADevice newDevice = new DLNADevice(id, name, displayName, 0, 10); - devices.put(id, newDevice); - broadcastDescriptors(); + String id = device.getIdentity().getUdn().toString(); + String name = device.getDetails().getFriendlyName(); + String displayName = device.getDisplayString(); + + DLNADevice newDevice = new DLNADevice(id, name, displayName, currentVolume, maxVolume); + devices.put(id, newDevice); + broadcastDescriptors(); + } + + @Override + public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String s) { + Log.w(TAG, "Failed to get default volume for DLNA route"); + Log.w(TAG, "Reason: " + s); + } + }); } } private void deviceRemoved(Device device) { |