org.fourthline.cling.support.avtransport.callback.Pause Java Examples

The following examples show how to use org.fourthline.cling.support.avtransport.callback.Pause. 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: 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 #2
Source File: DLNAController.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void stop() {
	try {
		controlPoint.execute(new Pause(getTransportService()) {
			@Override
			public void success(ActionInvocation invocation) {
				int secondsSinceLastUpdate = (int) ((System.currentTimeMillis() - lastUpdate.get()) / 1000L);
				currentPosition += secondsSinceLastUpdate;

				downloadService.setPlayerState(PlayerState.PAUSED);
			}

			@Override
			public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String msg) {
				Log.w(TAG, "Failed to pause playing: " + msg);
			}
		});
	} catch(Exception e) {
		Log.w(TAG, "Failed to stop", e);
	}
}