org.fourthline.cling.support.renderingcontrol.callback.SetVolume Java Examples

The following examples show how to use org.fourthline.cling.support.renderingcontrol.callback.SetVolume. 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: UpnpControlSet.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 设置音量
 */
public void setDeviceVolume(int volume) {
    ActionCallback setVolume = new SetVolume(renderingControlService, volume) {

        @Override
        public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) {
            onFailureCallBack(SET_VOLUME, arg2);
        }

        @Override
        public void success(ActionInvocation invocation) {
            onSuccessCallBack(SET_VOLUME);
        }
    };
    mUpnpService.getControlPoint().execute(setVolume);
}
 
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 setVolume(int volume) {
	if(volume < 0) {
		volume = 0;
	} else if(volume > device.volumeMax) {
		volume = device.volumeMax;
	}

	device.volume = volume;
	try {
		controlPoint.execute(new SetVolume(device.renderer.findService(new ServiceType("schemas-upnp-org", "RenderingControl")), volume) {
			@SuppressWarnings("rawtypes")
			@Override
			public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMessage) {
				Log.w(TAG, "Set volume failed: " + defaultMessage);
			}
		});
	} catch(Exception e) {
		Log.w(TAG, "Failed to set volume");
	}
}