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 <IActionResult> GetAlbum(SubsonicRequest request) { var authResult = await AuthenticateUser(request).ConfigureAwait(false); if (authResult != null) { return(authResult); } var result = await SubsonicService.GetAlbum(request, SubsonicUser).ConfigureAwait(false); return(BuildResponse(request, result, "album")); }
protected override IServiceResultBase <Client.Common.Models.Subsonic.Album> GetResult(int id) { return(SubsonicService.GetAlbum(id)); }
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); } } }
protected override IServiceResultBase <Album> GetResult(int id) { return(SubsonicService.GetAlbum(id)); }