Sonos .NET Class Library

1,360 views
Skip to first unread message

carlr

unread,
Mar 16, 2008, 2:13:58 PM3/16/08
to Sonos Development
Hi,

New here, just wanted to share a .NET Class Library for Sonos control.
Read more and download and try it out from: http://www.norrbom.nu

Please bear in mind that it's and early alpha build, but anyone is
more than welcome to try it out in their projects.

/Carl

djMax

unread,
Apr 29, 2008, 10:22:03 AM4/29/08
to Sonos Development
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.

djMax

unread,
Apr 29, 2008, 10:36:51 AM4/29/08
to Sonos Development
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;
}
}
}
Reply all
Reply to author
Forward
0 new messages