private async Task <uBaseObject> GetMediaInfo() { var command = AvCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo"); if (command == null) { return(null); } var service = GetAvTransportService(); if (service == null) { throw new InvalidOperationException("Unable to find service"); } var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType), false) .ConfigureAwait(false); if (result == null || result.Document == null) { return(null); } var track = result.Document.Descendants("CurrentURIMetaData").FirstOrDefault(); if (track == null) { return(null); } var e = track.Element(uPnpNamespaces.items) ?? track; return(UpnpContainer.Create(e)); }
private async Task <uBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken) { var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo"); if (command == null) { return(null); } var service = GetAvTransportService(); if (service == null) { throw new InvalidOperationException("Unable to find service"); } var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, rendererCommands.BuildPost(command, service.ServiceType), false) .ConfigureAwait(false); if (result == null || result.Document == null) { return(null); } var track = result.Document.Descendants("CurrentURIMetaData").FirstOrDefault(); if (track == null) { return(null); } var e = track.Element(uPnpNamespaces.items) ?? track; var elementString = (string)e; if (!string.IsNullOrWhiteSpace(elementString)) { return(UpnpContainer.Create(e)); } track = result.Document.Descendants("CurrentURI").FirstOrDefault(); if (track == null) { return(null); } e = track.Element(uPnpNamespaces.items) ?? track; elementString = (string)e; if (!string.IsNullOrWhiteSpace(elementString)) { return(new uBaseObject { Url = elementString }); } return(null); }
public static uBaseObject CreateObjectFromXML(uParserObject uItem) { return(UpnpContainer.Create(uItem.Element)); }