public static UPnPService GetMediaServerService(this SonosSpeakerControlService service, string serviceName)
 {
     return(service.SpeakerDevice
            .SubDevices
            .FirstOrDefault(x => x.Services.Any(y => y.Type == UPnPSonosServiceTypes.ContentDirectory))
            .Services.FirstOrDefault(x => x.Type == serviceName));
 }
Beispiel #2
0
        public static async Task <List <SonosQueueItem> > GetQueue(this SonosSpeakerControlService service, int startIndex = 0, int maxItems = 100)
        {
            UPnPServiceControl           serviceControl = new UPnPServiceControl(service.GetMediaServerService(UPnPSonosServiceTypes.ContentDirectory));
            IDictionary <string, string> actionResult   = await serviceControl.SendAction("Browse",
                                                                                          new Dictionary <string, string>()
            {
                { "ObjectID", "Q:0" },
                { "BrowseFlag", "BrowseDirectChildren" },
                { "Filter", "*" },
                { "StartingIndex", startIndex.ToString() },
                { "RequestedCount", maxItems.ToString() },
                { "SortCriteria", "" }
            });

            return(new DidlParser().Parse(actionResult.FirstOrDefault(x => x.Key == "Result").Value));
        }