From d950487610af0fa17f8cb8d5370827f37e026481 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 16 Dec 2013 01:21:58 +0100 Subject: [PATCH] Workaround for crash when Windows Media Player is active. --- .../controldlna/upnp/RemotePlayService.java | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/src/com/github/nutomic/controldlna/upnp/RemotePlayService.java b/src/com/github/nutomic/controldlna/upnp/RemotePlayService.java index a6d959a..83b0937 100644 --- a/src/com/github/nutomic/controldlna/upnp/RemotePlayService.java +++ b/src/com/github/nutomic/controldlna/upnp/RemotePlayService.java @@ -490,40 +490,45 @@ public class RemotePlayService extends Service implements RegistryListener { device instanceof RemoteDevice) { mDevices.put(device.getIdentity().getUdn().toString(), device); - mUpnpService.getControlPoint().execute( - new GetVolume(rc) { + try { + mUpnpService.getControlPoint().execute(new GetVolume(rc) { - @SuppressWarnings("rawtypes") - @Override - public void failure(ActionInvocation invocation, - UpnpResponse operation, String defaultMessage) { - Log.w(TAG, "Failed to get current Volume: " + defaultMessage); - } - - @SuppressWarnings("rawtypes") - @Override - public void received(ActionInvocation invocation, int currentVolume) { - int maxVolume = 100; - if (rc.getStateVariable("Volume") != null) { - StateVariableAllowedValueRange volumeRange = - rc.getStateVariable("Volume").getTypeDetails().getAllowedValueRange(); - maxVolume = (int) volumeRange.getMaximum(); - } - - Message msg = Message.obtain(null, Provider.MSG_RENDERER_ADDED, 0, 0); - msg.getData().putParcelable("device", new Provider.Device( - device.getIdentity().getUdn().toString(), - device.getDisplayString(), - device.getDetails().getManufacturerDetails().getManufacturer(), - currentVolume, - maxVolume)); - try { - mListener.send(msg); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - }); + @SuppressWarnings("rawtypes") + @Override + public void failure(ActionInvocation invocation, + UpnpResponse operation, String defaultMessage) { + Log.w(TAG, "Failed to get current Volume: " + defaultMessage); + } + + @SuppressWarnings("rawtypes") + @Override + public void received(ActionInvocation invocation, int currentVolume) { + int maxVolume = 100; + if (rc.getStateVariable("Volume") != null) { + StateVariableAllowedValueRange volumeRange = + rc.getStateVariable("Volume").getTypeDetails().getAllowedValueRange(); + maxVolume = (int) volumeRange.getMaximum(); + } + + Message msg = Message.obtain(null, Provider.MSG_RENDERER_ADDED, 0, 0); + msg.getData().putParcelable("device", new Provider.Device( + device.getIdentity().getUdn().toString(), + device.getDisplayString(), + device.getDetails().getManufacturerDetails().getManufacturer(), + currentVolume, + maxVolume)); + try { + mListener.send(msg); + } catch (RemoteException e) { + e.printStackTrace(); + } + } + }); + } + catch (IllegalArgumentException e) { + e.printStackTrace(); + return; + } } }