use of org.fourthline.cling.model.meta.Service in project BeyondUPnP by kevinshine.
the class PlaybackCommand method play.
public static void play() {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
if (avtService != null) {
ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new Play(avtService) {
@Override
public void success(ActionInvocation invocation) {
Log.i(TAG, "Play success.");
}
@Override
public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
Log.e(TAG, "Play failed");
}
});
}
}
use of org.fourthline.cling.model.meta.Service in project libresonic by Libresonic.
the class ClingRouter method findConnectionService.
/**
* Returns the UPnP service used for port mapping.
*/
private static Service findConnectionService(UpnpService upnpService) {
class ConnectionServiceDiscoverer extends PortMappingListener {
ConnectionServiceDiscoverer() {
super(new PortMapping[0]);
}
@Override
public Service discoverConnectionService(Device device) {
return super.discoverConnectionService(device);
}
}
ConnectionServiceDiscoverer discoverer = new ConnectionServiceDiscoverer();
Collection<Device> devices = upnpService.getRegistry().getDevices();
for (Device device : devices) {
Service service = discoverer.discoverConnectionService(device);
if (service != null) {
return service;
}
}
return null;
}
use of org.fourthline.cling.model.meta.Service in project BeyondUPnP by kevinshine.
the class PlaybackCommand method getPositionInfo.
public static void getPositionInfo(final Handler handler) {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
if (avtService != null) {
ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new GetPositionInfo(avtService) {
@Override
public void received(ActionInvocation invocation, PositionInfo positionInfo) {
Message msg = Message.obtain(handler, NowplayingFragment.GET_POSITION_INFO_ACTION);
msg.obj = positionInfo;
msg.sendToTarget();
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
Log.e(TAG, "GetPositionInfo failed");
}
});
}
}
use of org.fourthline.cling.model.meta.Service in project BeyondUPnP by kevinshine.
the class PlaybackCommand method getVolume.
public static void getVolume(final Handler handler) {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
Service rcService = device.findService(SystemManager.RENDERING_CONTROL_SERVICE);
if (rcService != null) {
ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new GetVolume(rcService) {
@Override
public void received(ActionInvocation actionInvocation, int currentVolume) {
//Send currentVolume to handler.
Log.i(TAG, "GetVolume:" + currentVolume);
Message msg = Message.obtain(handler, NowplayingFragment.GET_VOLUME_ACTION, currentVolume, 0);
msg.sendToTarget();
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
Log.e(TAG, "GetVolume failed");
}
});
}
}
use of org.fourthline.cling.model.meta.Service in project BeyondUPnP by kevinshine.
the class PlaybackCommand method pause.
public static void pause() {
Device device = SystemManager.getInstance().getSelectedDevice();
//Check selected device
if (device == null)
return;
Service avtService = device.findService(SystemManager.AV_TRANSPORT_SERVICE);
if (avtService != null) {
ControlPoint cp = SystemManager.getInstance().getControlPoint();
cp.execute(new Pause(avtService) {
@Override
public void success(ActionInvocation invocation) {
Log.i(TAG, "Pause success.");
}
@Override
public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
Log.e(TAG, "Pause failed");
}
});
}
}
Aggregations