Java Code Examples for org.fourthline.cling.controlpoint.ControlPoint#execute()

The following examples show how to use org.fourthline.cling.controlpoint.ControlPoint#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemService.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
public void setSelectedDevice(Device selectedDevice, ControlPoint controlPoint) {
    if (selectedDevice == mSelectedDevice) return;

    Log.i(TAG, "Change selected device.");
    mSelectedDevice = selectedDevice;
    //End last device's subscriptions
    if (mAVTransportSubscriptionCallback != null) {
        mAVTransportSubscriptionCallback.end();
    }
    //Init Subscriptions
    mAVTransportSubscriptionCallback = new AVTransportSubscriptionCallback(mSelectedDevice.findService(SystemManager.AV_TRANSPORT_SERVICE));
    controlPoint.execute(mAVTransportSubscriptionCallback);

    Intent intent = new Intent(Intents.ACTION_CHANGE_DEVICE);
    sendBroadcast(intent);
}
 
Example 2
Source File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
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");
            }
        });
    }
}
 
Example 3
Source File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
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");
            }
        });
    }
}
 
Example 4
Source File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
public static void stop() {
    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 Stop(avtService) {
            @Override
            public void success(ActionInvocation invocation) {
                Log.i(TAG, "Stop success.");
            }

            @Override
            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
                Log.e(TAG, "Stop failed");
            }
        });
    }
}
 
Example 5
Source File: PlaybackCommand.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
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");
            }
        });
    }
}
 
Example 6
Source File: DMCControl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public void setMute(boolean paramBoolean) {
	try {
		Service localService = this.executeDeviceItem.getDevice()
				.findService(new UDAServiceType("RenderingControl"));
		if (localService != null) {
			ControlPoint localControlPoint = this.upnpService
					.getControlPoint();
			localControlPoint.execute(new SetMuteCalllback(localService,
					paramBoolean, mHandle));
		} else {
			Log.e("null", "null");
		}
	} catch (Exception localException) {
		localException.printStackTrace();
	}
}