use of org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup in project smarthome by eclipse.
the class ZonePlayerHandler method getCurrentZoneGroup.
/**
* Returns the current zone group
* (of which the player receiving the command is part)
*
* @return {@link SonosZoneGroup}
*/
private SonosZoneGroup getCurrentZoneGroup() {
String zoneGroupState = stateMap.get("ZoneGroupState");
if (zoneGroupState != null) {
Collection<SonosZoneGroup> zoneGroups = SonosXMLParser.getZoneGroupFromXML(zoneGroupState);
for (SonosZoneGroup zoneGroup : zoneGroups) {
if (zoneGroup.getMembers().contains(getUDN())) {
return zoneGroup;
}
}
}
logger.debug("Could not fetch Sonos group state information");
return null;
}
use of org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup in project smarthome by eclipse.
the class ZonePlayerHandler method publicAddress.
public boolean publicAddress() {
// check if sourcePlayer has a line-in connected
if (isAnalogLineInConnected() || isOpticalLineInConnected()) {
// first remove this player from its own group if any
becomeStandAlonePlayer();
List<SonosZoneGroup> currentSonosZoneGroups = new ArrayList<SonosZoneGroup>();
for (SonosZoneGroup grp : SonosXMLParser.getZoneGroupFromXML(stateMap.get("ZoneGroupState"))) {
currentSonosZoneGroups.add((SonosZoneGroup) grp.clone());
}
// add all other players to this new group
for (SonosZoneGroup group : currentSonosZoneGroups) {
for (String player : group.getMembers()) {
try {
ZonePlayerHandler somePlayer = getHandlerByName(player);
if (somePlayer != this) {
somePlayer.becomeStandAlonePlayer();
somePlayer.stop();
addMember(StringType.valueOf(somePlayer.getUDN()));
}
} catch (IllegalStateException e) {
logger.debug("Cannot add to group ({})", e.getMessage());
}
}
}
try {
ZonePlayerHandler coordinator = getCoordinatorHandler();
// set the URI of the group to the line-in
SonosEntry entry = new SonosEntry("", "", "", "", "", "", "", ANALOG_LINE_IN_URI + getUDN());
if (isOpticalLineInConnected()) {
entry = new SonosEntry("", "", "", "", "", "", "", OPTICAL_LINE_IN_URI + getUDN() + SPDIF);
}
coordinator.setCurrentURI(entry);
coordinator.play();
return true;
} catch (IllegalStateException e) {
logger.debug("Cannot handle command ({})", e.getMessage());
return false;
}
} else {
logger.debug("Line-in of {} is not connected", getUDN());
return false;
}
}
Aggregations