示例#1
0
        private MediaItem GetMediaItem(MediaListItem pMediaListItem)
        {
            if (pMediaListItem is FileSystemItem)
            {
                return(GetMediaItemFromFile(pMediaListItem as FileSystemItem));
            }
            else if (pMediaListItem is DigitalMediaItem)
            {
                return(GetMediaItemFromMediaLibrary(pMediaListItem as DigitalMediaItem));
            }

            throw new Exception("MediaListItem type can not be converted to MediaItem");
        }
示例#2
0
        private void MediaList_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
        {
            DragableListTextItem selectedItem = e.SelectedItem as DragableListTextItem;

            if (selectedItem == null)
            {
                throw new Exception("Selected item is null or wrong type");
            }

            if (selectedItem is RootItem)
            {
                RootItem rootItem = selectedItem as RootItem;

                switch (rootItem.ItemType)
                {
                case RootItemType.DigitalMediaLibrary:
                    MediaList.ClearAndFillNextList(MediaManager.GetMLRootLevelItems().ToArray());
                    MediaList.ChangeListForward();
                    break;

                case RootItemType.FileSystem:
                    MediaList.ClearAndFillNextList(MediaManager.GetFSRootLevelItems().ToArray());
                    MediaList.ChangeListForward();
                    break;
                }
            }
            else if (selectedItem is MediaListItem)
            {
                MediaListItem mediaItem = selectedItem as MediaListItem;

                if (mediaItem.ItemType == MediaItemType.Song)
                {
                    MediaManager.StartPlayback(mediaItem.TargetId);
                }
                else
                {
                    MediaList.ClearAndFillNextList(MediaManager.GetNewMediaList(mediaItem.TargetId).ToArray());
                    MediaList.ChangeListForward();
                }
            }
            else if (selectedItem is FileSystemItem)
            {
                FileSystemItem fsItem = selectedItem as FileSystemItem;

                switch (fsItem.ItemType)
                {
                case FileSystemItemType.HardDrive:
                case FileSystemItemType.MemoryCard:
                case FileSystemItemType.Directory:
                    MediaList.ClearAndFillNextList(MediaManager.GetNewFSMediaList(fsItem.FullPath).ToArray());
                    MediaList.ChangeListForward();
                    break;

                case FileSystemItemType.AudioFile:
                    MediaManager.StartPlayback(fsItem.FullPath);
                    break;
                }
            }
            else
            {
                throw new Exception("Unknown media item type");
            }
        }