Workaround for crash when Windows Media Player is active.
This commit is contained in:
parent
33c6eababa
commit
d950487610
1 changed files with 38 additions and 33 deletions
|
@ -490,40 +490,45 @@ public class RemotePlayService extends Service implements RegistryListener {
|
||||||
device instanceof RemoteDevice) {
|
device instanceof RemoteDevice) {
|
||||||
mDevices.put(device.getIdentity().getUdn().toString(), device);
|
mDevices.put(device.getIdentity().getUdn().toString(), device);
|
||||||
|
|
||||||
mUpnpService.getControlPoint().execute(
|
try {
|
||||||
new GetVolume(rc) {
|
mUpnpService.getControlPoint().execute(new GetVolume(rc) {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void failure(ActionInvocation invocation,
|
public void failure(ActionInvocation invocation,
|
||||||
UpnpResponse operation, String defaultMessage) {
|
UpnpResponse operation, String defaultMessage) {
|
||||||
Log.w(TAG, "Failed to get current Volume: " + defaultMessage);
|
Log.w(TAG, "Failed to get current Volume: " + defaultMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void received(ActionInvocation invocation, int currentVolume) {
|
public void received(ActionInvocation invocation, int currentVolume) {
|
||||||
int maxVolume = 100;
|
int maxVolume = 100;
|
||||||
if (rc.getStateVariable("Volume") != null) {
|
if (rc.getStateVariable("Volume") != null) {
|
||||||
StateVariableAllowedValueRange volumeRange =
|
StateVariableAllowedValueRange volumeRange =
|
||||||
rc.getStateVariable("Volume").getTypeDetails().getAllowedValueRange();
|
rc.getStateVariable("Volume").getTypeDetails().getAllowedValueRange();
|
||||||
maxVolume = (int) volumeRange.getMaximum();
|
maxVolume = (int) volumeRange.getMaximum();
|
||||||
}
|
}
|
||||||
|
|
||||||
Message msg = Message.obtain(null, Provider.MSG_RENDERER_ADDED, 0, 0);
|
Message msg = Message.obtain(null, Provider.MSG_RENDERER_ADDED, 0, 0);
|
||||||
msg.getData().putParcelable("device", new Provider.Device(
|
msg.getData().putParcelable("device", new Provider.Device(
|
||||||
device.getIdentity().getUdn().toString(),
|
device.getIdentity().getUdn().toString(),
|
||||||
device.getDisplayString(),
|
device.getDisplayString(),
|
||||||
device.getDetails().getManufacturerDetails().getManufacturer(),
|
device.getDetails().getManufacturerDetails().getManufacturer(),
|
||||||
currentVolume,
|
currentVolume,
|
||||||
maxVolume));
|
maxVolume));
|
||||||
try {
|
try {
|
||||||
mListener.send(msg);
|
mListener.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue