public static IDirectoryObject InstansiateMediaLibraryObject(MediaItem item, string baseKey, BasicContainer parent, string title)
        {
            IDirectoryObject obj;
            // Choose the appropiate MediaLibrary* object for the media item
            if (item.Aspects.ContainsKey(DirectoryAspect.ASPECT_ID))
            {
                obj = new MediaLibraryContainer(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(AudioAspect.ASPECT_ID))
            {
                obj = new MediaLibraryMusicTrack(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(ImageAspect.ASPECT_ID))
            {
                obj = new MediaLibraryImageItem(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(VideoAspect.ASPECT_ID))
            {
                obj = new MediaLibraryVideoItem(baseKey, item);
            }
            else
            {
                obj = null;
            }

            // Assign the parent
            if (parent != null && obj != null)
            {
                parent.Add((TreeNode<object>)obj);
            }

            // Initialise the object
            if (obj is MediaLibraryContainer)
            {
                ((MediaLibraryContainer)obj).Initialise();                
            }
            else if (obj is MediaLibraryItem)
            {
                ((MediaLibraryItem)obj).Initialise();
            }
            if (obj != null)
            {
                ServiceRegistration.Get<ILogger>().Info("Created object of type {0} for MediaItem {1}", obj.GetType().Name, item.MediaItemId);
                if (title != null)
                {
                    obj.Title = title;
                }
            }      
      
            return obj;
        }
示例#2
0
        public static IDirectoryObject InstansiateMediaLibraryObject(MediaItem item, BasicContainer parent, string title)
        {
            BasicObject obj;

            Logger.Debug("Instantiate media library object from {0} {1} {2}", item != null ? item.MediaItemId.ToString() : "null", parent != null ? parent.Key : "null", title ?? "null");
            //Logger.Debug("Media library object title {0}", MediaItemAspect.GetAspect(item.Aspects, MediaAspect.Metadata));
            //Logger.Debug("Media library object title {0}", MediaItemAspect.GetAspect(item.Aspects, MediaAspect.Metadata).GetAttributeValue(MediaAspect.ATTR_TITLE));
            //Logger.Debug("Media library object title {0}", MediaItemAspect.GetAspect(item.Aspects, MediaAspect.Metadata).GetAttributeValue(MediaAspect.ATTR_TITLE).ToString());
            // Choose the appropiate MediaLibrary* object for the media item
            try
            {
                if (item.Aspects.ContainsKey(DirectoryAspect.ASPECT_ID))
                {
                    obj = new MediaLibraryBrowser(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(AudioAspect.ASPECT_ID))
                {
                    obj = new MediaLibraryMusicTrack(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(AudioAlbumAspect.ASPECT_ID))
                {
                    obj = new MediaLibraryAlbumItem(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(ImageAspect.ASPECT_ID))
                {
                    obj = new MediaLibraryImageItem(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(VideoAspect.ASPECT_ID))
                {
                    obj = new MediaLibraryVideoItem(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(SeriesAspect.ASPECT_ID))
                {
                    obj = new MediaLibrarySeriesItem(item, parent.Client);
                }
                else if (item.Aspects.ContainsKey(SeasonAspect.ASPECT_ID))
                {
                    obj = new MediaLibrarySeasonItem(item, parent.Client);
                }
                else
                {
                    Logger.Warn("MediaServer item {0} {1} contains no valid aspects", item.MediaItemId, title);
                    return(null);
                }
            }
            catch (DlnaAspectMissingException e)
            {
                //Unable to create DlnaItem
                Logger.Warn(e.Message);
                return(null);
            }
            //Logger.Debug("MediaServer converted {0}:[{1}] into {2}", item.MediaItemId, string.Join(",", item.Aspects.Keys), obj.GetType().Name);

            // Assign the parent
            if (parent != null)
            {
                parent.Add(obj);
            }

            // Initialise the object
            //if (obj is MediaLibraryItem)
            //{
            //  ((MediaLibraryItem)obj).Initialise();
            //}
            obj.Restricted = true;
            Logger.Debug("Created object of type {0} for MediaItem {1}", obj.GetType().Name, item.MediaItemId);
            if (title != null)
            {
                obj.Title = title;
            }
            return(obj);
        }
        public static IDirectoryObject InstansiateMediaLibraryObject(MediaItem item, string baseKey, BasicContainer parent, string title)
        {
            IDirectoryObject obj;
            // Choose the appropiate MediaLibrary* object for the media item
            if (item.Aspects.ContainsKey(DirectoryAspect.ASPECT_ID))
            {
                obj = new MediaLibraryContainer(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(AudioAspect.ASPECT_ID))
            {
                obj = new MediaLibraryMusicTrack(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(ImageAspect.ASPECT_ID))
            {
                obj = new MediaLibraryImageItem(baseKey, item);
            }
            else if (item.Aspects.ContainsKey(VideoAspect.ASPECT_ID))
            {
                obj = new MediaLibraryVideoItem(baseKey, item);
            }
            else
            {
                obj = null;
            }

            // Assign the parent
            if (parent != null && obj != null)
            {
                parent.Add((TreeNode<object>)obj);
            }

            // Initialise the object
            if (obj is MediaLibraryContainer)
            {
                ((MediaLibraryContainer)obj).Initialise();
            }
            else if (obj is MediaLibraryItem)
            {
                ((MediaLibraryItem)obj).Initialise();
            }
            if (obj != null)
            {
                ServiceRegistration.Get<ILogger>().Info("Created object of type {0} for MediaItem {1}", obj.GetType().Name, item.MediaItemId);
                if (title != null)
                {
                    obj.Title = title;
                }
            }

            return obj;
        }