本文整理匯總了Java中org.openhab.binding.pulseaudio.internal.items.Sink類的典型用法代碼示例。如果您正苦於以下問題:Java Sink類的具體用法?Java Sink怎麽用?Java Sink使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Sink類屬於org.openhab.binding.pulseaudio.internal.items包,在下文中一共展示了Sink類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDeviceStateChanged
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
@Override
public void onDeviceStateChanged(ThingUID bridge, AbstractAudioDeviceConfig device) {
if (device.getPaName().equals(name)) {
updateStatus(ThingStatus.ONLINE);
logger.debug("Updating states of {} id: {}", device, PulseaudioBindingConstants.VOLUME_CHANNEL);
updateState(PulseaudioBindingConstants.VOLUME_CHANNEL, new PercentType(device.getVolume()));
updateState(PulseaudioBindingConstants.MUTE_CHANNEL, device.isMuted() ? OnOffType.ON : OnOffType.OFF);
updateState(PulseaudioBindingConstants.STATE_CHANNEL,
device.getState() != null ? new StringType(device.getState().toString()) : new StringType("-"));
if (device instanceof SinkInput) {
updateState(PulseaudioBindingConstants.ROUTE_TO_SINK_CHANNEL,
((SinkInput) device).getSink() != null
? new StringType(((SinkInput) device).getSink().getPaName())
: new StringType("-"));
}
if (device instanceof Sink && ((Sink) device).isCombinedSink()) {
updateState(PulseaudioBindingConstants.SLAVES_CHANNEL,
new StringType(StringUtils.join(((Sink) device).getCombinedSinkNames(), ",")));
}
}
}
示例2: setCombinedSinkSlaves
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* changes the combined sinks slaves to the given <code>sinks</code>
*
* @param combinedSink the combined sink which slaves should be changed
* @param sinks the list of new slaves
*/
public void setCombinedSinkSlaves(Sink combinedSink, List<Sink> sinks) {
if (combinedSink == null || !combinedSink.isCombinedSink()) {
return;
}
List<String> slaves = new ArrayList<String>();
for (Sink sink : sinks) {
slaves.add(sink.getPaName());
}
// 1. delete old combined-sink
_sendRawCommand(CMD_UNLOAD_MODULE + " " + combinedSink.getModule().getId());
// 2. add new combined-sink with same name and all slaves
_sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSink.getPaName()
+ " slaves=" + StringUtils.join(slaves, ","));
// 3. update internal data structure because the combined sink has a new number + other slaves
update();
}
示例3: setCombinedSinkSlaves
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* changes the combined sinks slaves to the given <code>sinks</code>
*
* @param combinedSink the combined sink which slaves should be changed
* @param sinks the list of new slaves
*/
public void setCombinedSinkSlaves(Sink combinedSink, List<Sink> sinks) {
if (combinedSink == null || !combinedSink.isCombinedSink()) {
return;
}
List<String> slaves = new ArrayList<String>();
for (Sink sink : sinks) {
slaves.add(sink.getName());
}
// 1. delete old combined-sink
_sendRawCommand(CMD_UNLOAD_MODULE + " " + combinedSink.getModule().getId());
// 2. add new combined-sink with same name and all slaves
_sendRawCommand(CMD_LOAD_MODULE + " " + MODULE_COMBINE_SINK + " sink_name=" + combinedSink.getName()
+ " slaves=" + StringUtils.join(slaves, ","));
// 3. update internal data structure because the combined sink has a new number + other slaves
update();
}
示例4: onDeviceAdded
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
@Override
public void onDeviceAdded(Bridge bridge, AbstractAudioDeviceConfig device) {
String uidName = device.getPaName();
logger.debug("device {} found", device);
ThingTypeUID thingType = null;
Map<String, Object> properties = new HashMap<String, Object>();
// All devices need this parameter
properties.put(PulseaudioBindingConstants.DEVICE_PARAMETER_NAME, uidName);
if (device instanceof Sink) {
if (((Sink) device).isCombinedSink()) {
thingType = PulseaudioBindingConstants.COMBINED_SINK_THING_TYPE;
} else {
thingType = PulseaudioBindingConstants.SINK_THING_TYPE;
}
} else if (device instanceof SinkInput) {
thingType = PulseaudioBindingConstants.SINK_INPUT_THING_TYPE;
} else if (device instanceof Source) {
thingType = PulseaudioBindingConstants.SOURCE_THING_TYPE;
} else if (device instanceof SourceOutput) {
thingType = PulseaudioBindingConstants.SOURCE_OUTPUT_THING_TYPE;
}
if (thingType != null) {
logger.trace("Adding new pulseaudio {} with name '{}' to smarthome inbox",
device.getClass().getSimpleName(), uidName);
ThingUID thingUID = new ThingUID(thingType, bridge.getUID(), device.getUIDName());
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
.withBridge(bridge.getUID()).withLabel(device.getUIDName()).build();
thingDiscovered(discoveryResult);
}
}
示例5: getSink
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* retrieves a {@link Sink} by its name
*
* @return the corresponding {@link Sink} to the given <code>name</code>
*/
public Sink getSink(String name) {
for (AbstractAudioDeviceConfig item : items) {
if (item.getPaName().equalsIgnoreCase(name) && item instanceof Sink) {
return (Sink) item;
}
}
return null;
}
示例6: getItemCommandName
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* returns the item names that can be used in commands
*
* @param item
* @return
*/
private String getItemCommandName(AbstractAudioDeviceConfig item) {
if (item instanceof Sink) {
return ITEM_SINK;
} else if (item instanceof Source) {
return ITEM_SOURCE;
} else if (item instanceof SinkInput) {
return ITEM_SINK_INPUT;
} else if (item instanceof SourceOutput) {
return ITEM_SOURCE_OUTPUT;
}
return null;
}
示例7: moveSinkInput
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* sets the sink a sink-input should be routed to
*
* @param sinkInput the sink-input to be rerouted
* @param sink the new sink the sink-input should be routed to
*/
public void moveSinkInput(SinkInput sinkInput, Sink sink) {
if (sinkInput == null || sink == null) {
return;
}
_sendRawCommand("move-sink-input " + sinkInput.getId() + " " + sink.getId());
sinkInput.setSink(sink);
}
示例8: suspendSink
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* suspend a sink
*
* @param sink the sink which state should be changed
* @param suspend suspend it or not
*/
public void suspendSink(Sink sink, boolean suspend) {
if (sink == null) {
return;
}
if (suspend) {
_sendRawCommand("suspend-sink " + sink.getId() + " 1");
sink.setState(State.SUSPENDED);
} else {
_sendRawCommand("suspend-sink " + sink.getId() + " 0");
// unsuspending the sink could result in different states (RUNNING,IDLE,...)
// update to get the new state
update();
}
}
示例9: getSink
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* retrieves a {@link Sink} by its name
*
* @return the corresponding {@link Sink} to the given <code>name</code>
*/
public Sink getSink(String name) {
for (AbstractAudioDeviceConfig item : items) {
if (item.getName().equalsIgnoreCase(name) && item instanceof Sink) {
return (Sink) item;
}
}
return null;
}
示例10: getItemCommandName
import org.openhab.binding.pulseaudio.internal.items.Sink; //導入依賴的package包/類
/**
* returns the item names that can be used in commands
*
* @param item
* @return
*/
private String getItemCommandName(AbstractAudioDeviceConfig item) {
if (item instanceof Sink) {
return ITEM_SINK;
} else if (item instanceof Source) {
return ITEM_SOURCE;
} else if (item instanceof SinkInput) {
return ITEM_SINK_INPUT;
} else if (item instanceof SourceOutput) {
return ITEM_SOURCE_OUTPUT;
}
return null;
}