Exemplo n.º 1
0
        /// <summary>
        /// Generiert die Zonen sowie die Player in diesen.
        /// </summary>
        /// <param name="zoneXml"></param>
        /// <param name="sz">List of SonosZones</param>
        private void CreateZone(XElement zoneXml, List <SonosZone> sz)
        {
            var list = zoneXml.Descendants("ZoneGroupMember").Where(x => x.Attribute("Invisible") == null).ToList();

            if (list.Count > 0)
            {
                var internalzone = new SonosZone((string)zoneXml.Attribute("Coordinator"));

                foreach (var playerXml in list)
                {
                    var player = new SonosPlayer
                    {
                        Name           = (string)playerXml.Attribute("ZoneName"),
                        UUID           = (string)playerXml.Attribute("UUID"),
                        DeviceLocation = new Uri((string)playerXml.Attribute("Location")),
                        ControlPoint   = ControlPoint,
                        CurrentState   = new PlayerState()
                    };
                    if (player.UUID == internalzone.CoordinatorUUID)
                    {
                        internalzone.Coordinator = player;
                    }
                    else
                    {
                        internalzone.AddPlayer(player);
                        Players.Add(player);
                    }

                    // This can happen before or after the topology event...
                    if (playerDevices.ContainsKey(player.UUID))
                    {
                        player.SetDevice(playerDevices[player.UUID]);
                    }
                    else
                    {
                        ControlPoint.ForceDeviceAddition(player.DeviceLocation);
                    }
                }
                if (!sz.Contains(internalzone))
                {
                    sz.Add(internalzone);
                }
                //Zones.Add(zone);
            }
        }