Exemplo n.º 1
0
		private void UpdateTopology(string value)
		{          
			var xml = XElement.Parse(value);
			Console.WriteLine(value);

			Zones.Clear();

			foreach (var zoneNode in xml.Elements("ZoneGroup"))
			{
				var zone = new SonosZone();
				foreach (var playerNode in zoneNode.Elements("ZoneGroupMember"))
				{
                    // We ignore invisible units (bonded, bridges, stereopairs)
                    if (String.Equals((string)playerNode.Attribute("Invisible"), "1")) continue;
				    
                    var url = new Uri( (string)playerNode.Attribute( "Location" ) );
					var baseUrl = string.Format( "{0}://{1}", url.Scheme, url.Authority );
					var player = new SonosPlayer( (string)playerNode.Attribute( "UUID" ), (string)playerNode.Attribute( "ZoneName" ), baseUrl );
					if ((string)zoneNode.Attribute("Coordinator") == player.Uuid)
					{
						zone.Coordinator = player;
					}

					zone.Members.Add(player);
				}
                if (zone.Members.Count > 0)
				    Zones.Add( zone );
			}

			TopologyChanged.Invoke(null, new TopologyChangedEventHandlerArgs {});
		}
        private void UpdateTopology(string value)
        {
            var xml = XElement.Parse(value);

            Console.WriteLine(value);

            foreach (var groups in xml.Elements("ZoneGroups"))
            {
                foreach (var zoneNode in groups.Elements("ZoneGroup"))
                {
                    var zone = new SonosZone();
                    foreach (var playerNode in zoneNode.Elements("ZoneGroupMember"))
                    {
                        // We ignore invisible units (bonded, bridges, stereopairs)
                        if (String.Equals((string)playerNode.Attribute("Invisible"), "1"))
                        {
                            continue;
                        }

                        var url     = new Uri((string)playerNode.Attribute("Location"));
                        var baseUrl = string.Format("{0}://{1}", url.Scheme, url.Authority);
                        var player  = new SonosPlayer((string)playerNode.Attribute("UUID"), (string)playerNode.Attribute("ZoneName"), baseUrl);
                        if ((string)zoneNode.Attribute("Coordinator") == player.Uuid)
                        {
                            zone.Coordinator = player;
                        }

                        zone.Members.Add(player);
                    }
                    if (zone.Members.Count > 0)
                    {
                        Zones.Add(zone);
                    }
                }
            }

            TopologyChanged.Invoke(null, new TopologyChangedEventHandlerArgs {
            });
        }
Exemplo n.º 3
0
	    private async void StartPlayer(SonosPlayer player, string streamUrl)
	    {
            await player.SetAvTransportUri(streamUrl);
            await player.Play();
	    }