private void AddToPlaylistExecute(BaseEntry baseEntry)
        {
            List<Song> songs;

            if (baseEntry is Artist)
            {
                songs = (baseEntry as Artist).Songs.ToList();
            }
            else
            {
                songs = (baseEntry as Album).Songs.ToList();
            }

            CollectionHelper.AddToPlaylistDialog(songs);
        }
        private async void AddToQueueExecute(BaseEntry baseEntry)
        {
            List<Song> songs;
            var ignoreInsertMode = true;

            if (baseEntry is Artist)
            {
                songs = (baseEntry as Artist).Songs.ToList();
            }
            else
            {
                songs = (baseEntry as Album).Songs.ToList();
            }

            if (App.Locator.Settings.AddToInsert && App.Locator.Player.IsPlayerActive)
            {
                songs.Reverse();
                ignoreInsertMode = false;
            }

            await CollectionHelper.AddToQueueAsync(songs, ignoreInsertMode);
        }
Example #3
0
        public static async Task DeleteEntryAsync(BaseEntry item, bool showSuccessMessage = true)
        {
            var name = "unknown";

            try
            {
                if (item is Song)
                {
                    var song = item as Song;
                    name = song.Name;

                    var playbackQueue = App.Locator.CollectionService.PlaybackQueue;
                    var queue = playbackQueue.FirstOrDefault(p => p.SongId == song.Id);

                    if (queue != null && App.Locator.Player.IsPlayerActive)
                    {
                        if (playbackQueue.Count == 1)
                        {
                            await App.Locator.AudioPlayerHelper.ShutdownPlayerAsync();
                        }
                        else if (queue == App.Locator.Player.CurrentQueue)
                        {
                            App.Locator.AudioPlayerHelper.NextSong();
                        }
                    }

                    await App.Locator.CollectionService.DeleteSongAsync(song);
                    ExitIfAlbumEmpty(song.Album);
                }
                else if (item is Playlist)
                {
                    var playlist = (Playlist) item;
                    name = playlist.Name;

                    await App.Locator.CollectionService.DeletePlaylistAsync(playlist);
                }
                else if (item is Artist)
                {
                    var artist = (Artist) item;
                    name = artist.Name;

                    App.Locator.CollectionService.Artists.Remove(artist);

                    var artistSongs = artist.Songs.ToList();
                    var taskList = new List<Task>();

                    foreach (var song in artistSongs)
                    {
                        var playbackQueue = App.Locator.CollectionService.PlaybackQueue;
                        var queue = playbackQueue.FirstOrDefault(p => p.SongId == song.Id);

                        if (queue != null)
                        {
                            if (playbackQueue.Count == 1)
                            {
                                await App.Locator.AudioPlayerHelper.ShutdownPlayerAsync();
                            }
                            else if (queue == App.Locator.Player.CurrentQueue)
                            {
                                App.Locator.AudioPlayerHelper.NextSong();
                            }
                        }

                        taskList.Add(App.Locator.CollectionService.DeleteSongAsync(song));
                    }

                    ExitIfArtistEmpty(artist);
                }
                else if (item is Album)
                {
                    var album = (Album) item;
                    name = album.Name;

                    App.Locator.CollectionService.Albums.Remove(album);

                    var albumSongs = album.Songs.ToList();
                    var taskList = new List<Task>();

                    foreach (var song in albumSongs)
                    {
                        var playbackQueue = App.Locator.CollectionService.PlaybackQueue;
                        var queue = playbackQueue.FirstOrDefault(p => p.SongId == song.Id);

                        if (queue != null && App.Locator.Player.IsPlayerActive)
                        {
                            if (playbackQueue.Count == 1)
                            {
                                await App.Locator.AudioPlayerHelper.ShutdownPlayerAsync();
                            }
                            else if (queue == App.Locator.Player.CurrentQueue)
                            {
                                App.Locator.AudioPlayerHelper.NextSong();
                            }
                        }

                        taskList.Add(App.Locator.CollectionService.DeleteSongAsync(song));
                    }

                    ExitIfAlbumEmpty(album);
                }

                if (showSuccessMessage)
                {
                    CurtainPrompt.Show("EntryDeletingSuccess".FromLanguageResource(), name);
                }
            }
            catch
            {
                CurtainPrompt.ShowError("EntryDeletingError".FromLanguageResource(), name);
            }
        }
 public async void DeleteClickExecute(BaseEntry item)
 {
     await CollectionHelper.DeleteEntryAsync(item);
 }
        private async void EntryPlayClickExecute(BaseEntry item)
        {
            List<Song> queueSongs = null;

            if (item is Artist)
            {
                var artist = item as Artist;
                queueSongs = artist.Songs.ToList();
            }
            else if (item is Album)
            {
                var album = item as Album;
                queueSongs = album.Songs.ToList();
            }
            else if (item is Playlist)
            {
                var playlist = item as Playlist;
                queueSongs = playlist.Songs.Select(p => p.Song).ToList();
            }

            if (queueSongs != null)
            {
                await CollectionHelper.PlaySongsAsync(queueSongs, forceClear: true);
            }
        }