public static IList <SonosItem> Parse(string xmlString)
        {
            var        xml  = XElement.Parse(xmlString);
            XNamespace ns   = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
            XNamespace dc   = "http://purl.org/dc/elements/1.1/";
            XNamespace upnp = "urn:schemas-upnp-org:metadata-1-0/upnp/";
            XNamespace r    = "urn:schemas-rinconnetworks-com:metadata-1-0/";

            var items = xml.Elements(ns + "item");

            var list = new List <SonosItem>();

            foreach (var item in items)
            {
                var track = new SonosTrack();
                track.Uri      = (string)item.Element(ns + "res");
                track.MetaData = (string)item.Element(r + "resMD");


                // fix didl if exist
                var didl = new SonosDIDL();
                didl.AlbumArtURI = (string)item.Element(upnp + "albumArtURI");
                didl.Artist      = (string)item.Element(dc + "creator");
                didl.Title       = (string)item.Element(dc + "title");
                didl.Description = (string)item.Element(r + "description");

                list.Add(new SonosItem
                {
                    Track = track,
                    DIDL  = didl
                });
            }

            return(list);
        }
Exemple #2
0
        public void SetAVTransportURI(SonosTrack track)
        {
            var arguments = new UPnPArgument[3];

            arguments[0] = new UPnPArgument("InstanceID", 0u);
            arguments[1] = new UPnPArgument("CurrentURI", track.Uri);
            arguments[2] = new UPnPArgument("CurrentURIMetaData", track.MetaData);
            AVTransport.InvokeAsync("SetAVTransportURI", arguments);
        }
Exemple #3
0
        public uint Enqueue(SonosTrack track, bool asNext = false)
        {
            var arguments = new UPnPArgument[8];

            arguments[0] = new UPnPArgument("InstanceID", 0u);
            arguments[1] = new UPnPArgument("EnqueuedURI", track.Uri);
            arguments[2] = new UPnPArgument("EnqueuedURIMetaData", track.MetaData);
            arguments[3] = new UPnPArgument("DesiredFirstTrackNumberEnqueued", 0u);
            arguments[4] = new UPnPArgument("EnqueueAsNext", asNext);
            arguments[5] = new UPnPArgument("FirstTrackNumberEnqueued", null);
            arguments[6] = new UPnPArgument("NumTracksAdded", null);
            arguments[7] = new UPnPArgument("NewQueueLength", null);
            AVTransport.InvokeSync("AddURIToQueue", arguments);

            return((uint)arguments[5].DataValue);
        }