public GenericMediaModel(ISubsonicModel subsonicModel) : this(subsonicModel.Type) { Id = subsonicModel.Id; Name = subsonicModel.Name; _description = subsonicModel.GetDescription(); }
public static void NavigateByModelType <T>(this T navigationService, ISubsonicModel subsonicModel) where T : INavigationService { var id = subsonicModel.Id; switch (subsonicModel.Type) { case SubsonicModelTypeEnum.Song: case SubsonicModelTypeEnum.Video: navigationService.NavigateToViewModel <PlaybackViewModel>(id); break; case SubsonicModelTypeEnum.Album: navigationService.NavigateToViewModel <AlbumViewModel>(id); break; case SubsonicModelTypeEnum.MusicDirectory: navigationService.NavigateToViewModel <MusicDirectoryViewModel>(id); break; case SubsonicModelTypeEnum.Artist: navigationService.NavigateToViewModel <ArtistViewModel>(id); break; } }
public void TestInitialize() { IoC.GetInstance = (type, s) => null; _expandedArtist = new ExpandedArtist { Id = 42, AlbumCount = 12, Name = "artist" }; _artistMenuItemViewModel = _expandedArtist.AsMenuItemViewModel(); _artistMusicDirectoryChild = _artistMenuItemViewModel.Item.As <ISubsonicModel>(); _album = new Common.Models.Subsonic.Album { Id = 24, SongCount = 12, Name = "album" }; _albumMenuItemViewModel = _album.AsMenuItemViewModel(); _albumMusicDirectoryChild = _albumMenuItemViewModel.Item.As <ISubsonicModel>(); _song = new Song { Id = 12, Title = "song", Artist = "artist", Album = "album" }; _songMenuItemViewModel = _song.AsMenuItemViewModel(); _songMusicDirectoryChild = _songMenuItemViewModel.Item.As <ISubsonicModel>(); }
public GenericMediaModel(ISubsonicModel subsonicModel) : this(subsonicModel.Type) { Id = subsonicModel.Id; Name = subsonicModel.Name; _description = subsonicModel.GetDescription(); }
public void TestInitialize() { IoC.GetInstance = (type, s) => null; _expandedArtist = new ExpandedArtist { Id = 42, AlbumCount = 12, Name = "artist" }; _artistMenuItemViewModel = _expandedArtist.AsMenuItemViewModel(); _artistMusicDirectoryChild = _artistMenuItemViewModel.Item.As<ISubsonicModel>(); _album = new Common.Models.Subsonic.Album { Id = 24, SongCount = 12, Name = "album" }; _albumMenuItemViewModel = _album.AsMenuItemViewModel(); _albumMusicDirectoryChild = _albumMenuItemViewModel.Item.As<ISubsonicModel>(); _song = new Song { Id = 12, Title = "song", Artist = "artist", Album = "album" }; _songMenuItemViewModel = _song.AsMenuItemViewModel(); _songMusicDirectoryChild = _songMenuItemViewModel.Item.As<ISubsonicModel>(); }
private async Task AddItemToPlaylist(ISubsonicModel item) { if (item.Type == SubsonicModelTypeEnum.Song || item.Type == SubsonicModelTypeEnum.Video) { var addItemsMessage = new AddItemsMessage { Queue = new List <Client.Common.Models.PlaylistItem>(new[] { await LoadModel(item) }) }; EventAggregator.Publish(addItemsMessage); if (_playNextItem) { _playNextItem = false; EventAggregator.Publish(new PlayNextMessage()); } } else { var children = new List <ISubsonicModel>(); switch (item.Type) { case SubsonicModelTypeEnum.Album: { await SubsonicService.GetAlbum(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Songs)) .Execute(); } break; case SubsonicModelTypeEnum.Artist: { await SubsonicService.GetArtist(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Albums)) .Execute(); } break; case SubsonicModelTypeEnum.MusicDirectory: { await SubsonicService.GetMusicDirectory(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Children)) .Execute(); } break; case SubsonicModelTypeEnum.Index: { children.AddRange(((IndexItem)item).Artists); } break; } foreach (var subsonicModel in children) { await AddItemToPlaylist(subsonicModel); } } }
public async Task HandleItemSelection(ISubsonicModel subsonicModel) { if (subsonicModel.Type == SubsonicModelTypeEnum.Song || subsonicModel.Type == SubsonicModelTypeEnum.Video) { var playlistItem = await LoadPlaylistItem(subsonicModel); var addItemsMessage = new AddItemsMessage { Queue = new List <PlaylistItem> { playlistItem }, StartPlaying = true }; EventAggregator.Publish(addItemsMessage); } NavigationService.NavigateByModelType(subsonicModel); }
private async Task AddItemToPlaylist(ISubsonicModel item) { if (item.Type == SubsonicModelTypeEnum.Song || item.Type == SubsonicModelTypeEnum.Video) { var addItemsMessage = new AddItemsMessage { Queue = new List<Client.Common.Models.PlaylistItem>(new[] { await LoadModel(item) }) }; EventAggregator.Publish(addItemsMessage); if (_playNextItem) { _playNextItem = false; EventAggregator.Publish(new PlayNextMessage()); } } else { var children = new List<ISubsonicModel>(); switch (item.Type) { case SubsonicModelTypeEnum.Album: { await SubsonicService.GetAlbum(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Songs)) .Execute(); } break; case SubsonicModelTypeEnum.Artist: { await SubsonicService.GetArtist(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Albums)) .Execute(); } break; case SubsonicModelTypeEnum.MusicDirectory: { await SubsonicService.GetMusicDirectory(item.Id) .WithErrorHandler(this) .OnSuccess(result => children.AddRange(result.Children)) .Execute(); } break; case SubsonicModelTypeEnum.Index: { children.AddRange(((IndexItem)item).Artists); } break; } foreach (var subsonicModel in children) { await AddItemToPlaylist(subsonicModel); } } }
private async Task AddItemToPlaylist(ISubsonicModel item) { if (item.Type == SubsonicModelTypeEnum.Song || item.Type == SubsonicModelTypeEnum.Video) { var playlistItems = new List<PlaylistItem>(new[] { await LoadPlaylistItem(item) }); var addItemsMessage = new AddItemsMessage { Queue = playlistItems }; if (_playNextItem) { _playNextItem = false; addItemsMessage.StartPlaying = true; } EventAggregator.Publish(addItemsMessage); } else { var children = new List<ISubsonicModel>(); switch (item.Type) { case SubsonicModelTypeEnum.Album: { await SubsonicService.GetAlbum(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Songs)) .Execute(); } break; case SubsonicModelTypeEnum.Artist: { await SubsonicService.GetArtist(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Albums)) .Execute(); } break; case SubsonicModelTypeEnum.MusicDirectory: { await SubsonicService.GetMusicDirectory(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Children)) .Execute(); } break; case SubsonicModelTypeEnum.Index: { children.AddRange(((IndexItem)item).Artists); } break; case SubsonicModelTypeEnum.Folder: { await SubsonicService.GetIndex(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Artists)) .Execute(); } break; } foreach (var subsonicModel in children) { await AddItemToPlaylist(subsonicModel); } } }
private async Task AddItemToPlaylist(ISubsonicModel item) { if (item.Type == SubsonicModelTypeEnum.Song || item.Type == SubsonicModelTypeEnum.Video) { var playlistItems = new List <PlaylistItem>(new[] { await LoadPlaylistItem(item) }); var addItemsMessage = new AddItemsMessage { Queue = playlistItems }; if (_playNextItem) { _playNextItem = false; addItemsMessage.StartPlaying = true; } EventAggregator.Publish(addItemsMessage); } else { var children = new List <ISubsonicModel>(); switch (item.Type) { case SubsonicModelTypeEnum.Album: { await SubsonicService.GetAlbum(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Songs)) .Execute(); } break; case SubsonicModelTypeEnum.Artist: { await SubsonicService.GetArtist(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Albums)) .Execute(); } break; case SubsonicModelTypeEnum.MusicDirectory: { await SubsonicService.GetMusicDirectory(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Children)) .Execute(); } break; case SubsonicModelTypeEnum.Index: { children.AddRange(((IndexItem)item).Artists); } break; case SubsonicModelTypeEnum.Folder: { await SubsonicService.GetIndex(item.Id) .WithErrorHandler(ErrorDialogViewModel) .OnSuccess(result => children.AddRange(result.Artists)) .Execute(); } break; } foreach (var subsonicModel in children) { await AddItemToPlaylist(subsonicModel); } } }