Can you post the source for this library somewhere? I'm going to try
and use it but there are some things I want to change. (Happy to
provide them back, it'd just speed up my development if I didn't have
to go back and forth)
As a first example, DeviceFinder.FindZonePlayers should not return
"object", it should return an actual type with properties that
indicate what was found.
On Mar 16, 2:13 pm, carlr <ca...@norrbom.nu> wrote:
I'm in C#, so this isn't an easy translation, but here's my version of
FindZonePlayers. I'm using log4net from the Apache Foundation, which
I highly recommend you switch to rather than rolling your own logging.
public class DeviceFinder
{
public class ZonePlayerInfo
{
public ZonePlayerInfo(string name, string id)
{
Name = name;
DeviceId = id;
}
public string DeviceId { get; private set; }
public string Name { get; private set; }
}
public List<ZonePlayerInfo> FindZonePlayers()
{
object obj2;
UPnPDeviceFinder finder = new UPnPDeviceFinderClass();
object[] vInActionArgs = new object[1];
object[] objArray2 = new object[1];
try
{
UPnPDevices devices = finder.FindByType("urn:schemas-upnp-
org:device:ZonePlayer:1", 0);
if (devices.Count == 0)
{
return null;
}
var zones = new List<ZonePlayerInfo>();
object[] attrs = new object[1];
foreach (UPnPDevice device in devices)
{
device.Services["urn:upnp-
org:serviceId:DeviceProperties"].InvokeAction("GetZoneAttributes",
vInActionArgs, ref attrs);
zones.Add(new ZonePlayerInfo(attrs[0], device.UniqueDeviceName));
}
return zones;
}
catch (Exception exception)
{
_Log.Warn("FindZonePlayers failed", exception);
return null;
}