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

            await library.PlaylistManager.DeleteFromLibrary(library, savedPlaylist);
        }
示例#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();
            }
        }
示例#3
0
 public async Task DeleteFromLibrary(MusicLibrary musicLibrary, SavedPlaylist savedPlaylist)
 {
     await databaseConnection.DeleteAsync(savedPlaylist);
     musicLibrary.SavedPlaylists.Remove(savedPlaylist);
 }
示例#4
0
 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;
     });
 }
示例#5
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);
        }