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; }
private static void InitialiseContainerTree() { RootContainer = new BasicContainer("0") { Title = "MediaPortal Media Library" }; var audioContainer = new BasicContainer("A") { Title = "Audio" }; RootContainer.Add(audioContainer); var pictureContainer = new BasicContainer("P") { Title = "Picture" }; RootContainer.Add(pictureContainer); var videoContainer = new BasicContainer("V") { Title = "Video" }; RootContainer.Add(videoContainer); videoContainer.Add(new MediaLibraryGenreContainer("VG") { Title = "Genres" }); RootContainer.Add(new MediaLibraryShareContainer("S") { Title = "Shares" }); }