예제 #1
0
        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 = VirtualMediaHelper.ShowVirtualMedia(_necessaryMIATypeIds);
                mediaItems = new List <MediaItem>(cd.BrowseAsync(_directoryId, _necessaryMIATypeIds, _optionalMIATypeIds, userProfile, showVirtual).Result);
                ICollection <MediaItem> childDirectories = cd.BrowseAsync(_directoryId, DIRECTORY_MIA_ID_ENUMERATION, EMPTY_ID_ENUMERATION, userProfile, showVirtual).Result;
                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;
            }
        }
예제 #2
0
 public async Task<IList<MediaItem>> BrowseAsync(Guid parentDirectoryId,
     IEnumerable<Guid> necessaryRequestedMIATypeIDs, IEnumerable<Guid> optionalRequestedMIATypeIDs, Guid? userProfile, bool includVirtual, uint? offset = null, uint? limit = null)
 {
   try
   {
     return await _contentDirectory.BrowseAsync(parentDirectoryId, necessaryRequestedMIATypeIDs, optionalRequestedMIATypeIDs, userProfile, includVirtual, offset, limit);
   }
   catch (Exception)
   {
     throw new DisconnectedException();
   }
 }