Exemple #1
0
        internal async Task DeleteSavedPlaylist(SavedPlaylist savedPlaylist)
        {
            var library = this.library ?? await libraryLoadingTask;

            await library.PlaylistManager.DeleteFromLibrary(library, savedPlaylist);
        }
Exemple #2
0
        internal async void PlayPlaylist(SavedPlaylist savedPlaylist)
        {
            var library = this.library ?? await libraryLoadingTask;

            if (await library.PlaylistManager.LoadFromLibrary(savedPlaylist))
            {
                this.audioControls.Play();
                await this.Playlist.Reset();
            }
        }
 public async Task DeleteFromLibrary(MusicLibrary musicLibrary, SavedPlaylist savedPlaylist)
 {
     await databaseConnection.DeleteAsync(savedPlaylist);
     musicLibrary.SavedPlaylists.Remove(savedPlaylist);
 }
 public Task<bool> LoadFromLibrary(SavedPlaylist savedPlaylist)
 {
     return this.databaseConnection.TryRunInTransactionAsync(connection =>
     {
         connection.Execute("delete from CurrentPlaylistSong");
         connection.Execute("insert into CurrentPlaylistSong (SongId, Rank, ActualRank) select SongId, Rank, Rank from SavedPlaylistSong where PlaylistId = ?", savedPlaylist.Id);
         this.IsRandomOrder = false;
         this.CurrentIndex = 0;
     });
 }
        public async Task SaveToLibrary(MusicLibrary musicLibrary, string playlistName)
        {
            SavedPlaylist savedPlaylist = null;
            await this.databaseConnection.TryRunInTransactionAsync(connection =>
            {
                savedPlaylist = new SavedPlaylist() { Name = playlistName };

                var mostCommonArtistNames = connection.Query<Song>("select s.Artist from Song s, CurrentPlaylistSong c where s.Id = c.SongId group by s.Artist order by count(s.Artist) desc limit 4").Select(p => p.Artist);
                if (mostCommonArtistNames.Any())
                {
                    savedPlaylist.ShortDescription = string.Join(", ", mostCommonArtistNames.Take(3));
                    if (mostCommonArtistNames.Count() > 3)
                        savedPlaylist.ShortDescription += ", ...";
                }

                connection.Insert(savedPlaylist);

                connection.Execute("delete from SavedPlaylistSong where PlaylistId = ?", savedPlaylist.Id);
                connection.Execute("insert into SavedPlaylistSong (SongId, Rank, PlaylistId) select SongId, Rank, ? from CurrentPlaylistSong", savedPlaylist.Id);
            });
            musicLibrary.SavedPlaylists.Add(savedPlaylist);
        }