protected internal override void ReLoadItemsAndSubViewSpecifications(out IList <MediaItem> mediaItems, out IList <ViewSpecification> subViewSpecifications) { mediaItems = null; subViewSpecifications = null; IContentDirectory cd = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory; if (cd == null) { return; } try { mediaItems = new List <MediaItem>(cd.Browse(_directoryId, _necessaryMIATypeIds, _optionalMIATypeIds)); ICollection <MediaItem> childDirectories = cd.Browse(_directoryId, DIRECTORY_MIA_ID_ENUMERATION, EMPTY_ID_ENUMERATION); subViewSpecifications = new List <ViewSpecification>(childDirectories.Count); foreach (MediaItem childDirectory in childDirectories) { MediaItemAspect ma = childDirectory.Aspects[MediaAspect.ASPECT_ID]; MediaItemAspect pra = childDirectory.Aspects[ProviderResourceAspect.ASPECT_ID]; MediaLibraryBrowseViewSpecification subViewSpecification = new MediaLibraryBrowseViewSpecification( (string)ma.GetAttributeValue(MediaAspect.ATTR_TITLE), childDirectory.MediaItemId, (string)pra.GetAttributeValue(ProviderResourceAspect.ATTR_SYSTEM_ID), ResourcePath.Deserialize((string)pra.GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH)), _necessaryMIATypeIds, _optionalMIATypeIds); subViewSpecifications.Add(subViewSpecification); } } catch (UPnPRemoteException e) { ServiceRegistration.Get <ILogger>().Error("SimpleTextSearchViewSpecification.ReLoadItemsAndSubViewSpecifications: Error requesting server", e); mediaItems = null; subViewSpecifications = null; } }
protected internal override void ReLoadItemsAndSubViewSpecifications(out IList <MediaItem> mediaItems, out IList <ViewSpecification> subViewSpecifications) { mediaItems = null; subViewSpecifications = null; IContentDirectory cd = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory; if (cd == null) { return; } Guid? userProfile = null; IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>(); if (userProfileDataManagement != null && userProfileDataManagement.IsValidUser) { userProfile = userProfileDataManagement.CurrentUser.ProfileId; } try { bool showVirtual = ShowVirtualSetting.ShowVirtualMedia(_necessaryMIATypeIds); mediaItems = new List <MediaItem>(cd.Browse(_directoryId, _necessaryMIATypeIds, _optionalMIATypeIds, userProfile, showVirtual)); ICollection <MediaItem> childDirectories = cd.Browse(_directoryId, DIRECTORY_MIA_ID_ENUMERATION, EMPTY_ID_ENUMERATION, userProfile, showVirtual); subViewSpecifications = new List <ViewSpecification>(childDirectories.Count); foreach (MediaItem childDirectory in childDirectories) { SingleMediaItemAspect ma = null; MediaItemAspect.TryGetAspect(childDirectory.Aspects, MediaAspect.Metadata, out ma); IList <MultipleMediaItemAspect> pras = null; MediaItemAspect.TryGetAspects(childDirectory.Aspects, ProviderResourceAspect.Metadata, out pras); foreach (MultipleMediaItemAspect pra in pras) { MediaLibraryBrowseViewSpecification subViewSpecification = new MediaLibraryBrowseViewSpecification( (string)ma.GetAttributeValue(MediaAspect.ATTR_TITLE), childDirectory.MediaItemId, (string)pra.GetAttributeValue(ProviderResourceAspect.ATTR_SYSTEM_ID), ResourcePath.Deserialize((string)pra.GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH)), _necessaryMIATypeIds, _optionalMIATypeIds); subViewSpecifications.Add(subViewSpecification); } } } catch (UPnPRemoteException e) { ServiceRegistration.Get <ILogger>().Error("SimpleTextSearchViewSpecification.ReLoadItemsAndSubViewSpecifications: Error requesting server", e); mediaItems = null; subViewSpecifications = null; } }
public static void Test() { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress)); host.AddServiceEndpoint(typeof(IContentDirectory), GetBinding(), ""); host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); host.Open(); Console.WriteLine("Host opened"); ChannelFactory <IContentDirectory> factory = new ChannelFactory <IContentDirectory>(GetBinding(), new EndpointAddress(baseAddress)); IContentDirectory proxy = factory.CreateChannel(); //string result; //ulong ul1, ul2, ul3; //proxy.Browse(null, null, null, 0, 0, null, out result, out ul1, out ul2, out ul3); proxy.Browse(new BrowseRequest { BrowseFlag = null, Filter = null, ObjectID = null, RequestedCount = 0, SortCriteria = null, StartingIndex = 0 }); ((IClientChannel)proxy).Close(); factory.Close(); Console.Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); }
public ICollection <MediaItem> Browse(Guid parentDirectoryId, IEnumerable <Guid> necessaryRequestedMIATypeIDs, IEnumerable <Guid> optionalRequestedMIATypeIDs) { try { return(_contentDirectory.Browse(parentDirectoryId, necessaryRequestedMIATypeIDs, optionalRequestedMIATypeIDs)); } catch (Exception) { throw new DisconnectedException(); } }
public IList <MediaItem> Browse(Guid parentDirectoryId, IEnumerable <Guid> necessaryRequestedMIATypeIDs, IEnumerable <Guid> optionalRequestedMIATypeIDs, uint?offset = null, uint?limit = null) { try { return(_contentDirectory.Browse(parentDirectoryId, necessaryRequestedMIATypeIDs, optionalRequestedMIATypeIDs, offset, limit)); } catch (Exception) { throw new DisconnectedException(); } }