Search in sources :

Example 1 with SonosZoneGroup

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;
}
Also used : SonosZoneGroup(org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup)

Example 2 with SonosZoneGroup

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;
    }
}
Also used : SonosEntry(org.eclipse.smarthome.binding.sonos.internal.SonosEntry) SonosZoneGroup(org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup) ArrayList(java.util.ArrayList)

Aggregations

SonosZoneGroup (org.eclipse.smarthome.binding.sonos.internal.SonosZoneGroup)2 ArrayList (java.util.ArrayList)1 SonosEntry (org.eclipse.smarthome.binding.sonos.internal.SonosEntry)1