Пример #1
0
        public Task<bool> PlayFromSource(SongSource songSource, int firstSongId)
        {
            return this.databaseConnection.TryRunInTransactionAsync(connection =>
            {
                this.CurrentIndex = 0;

                connection.Execute("delete from CurrentPlaylistSong");

                AddToList(connection, 0, songSource);

                if (IsRandomOrder)
                    ShufflePlaylist(connection, firstSongId);
                else
                    this.CurrentIndex = connection.Table<CurrentPlaylistSong>().First(p => p.SongId == firstSongId).Rank;

                Debug.WriteLine("CurrentIndex: " + this.CurrentIndex);
            });
        }
Пример #2
0
 public AllSongsFilter(ResourceLoader resourceLoader, Func<Song, bool> includeInList, SongSource songSource)
     : base(resourceLoader, "AllSongsItemHeader", "Songs")
 {
     this.includeInList = includeInList ?? ((s) => true);
     this.SongSource = songSource;
 }
Пример #3
0
 internal async void AddToPlayNext(SongSource songSource)
 {
     await library.PlaylistManager.AddNext(songSource);
     await Playlist.Reset();
 }
Пример #4
0
 internal async void GoToPlayMode(Song song, SongSource songSource)
 {
     var library = this.library ?? await libraryLoadingTask;
     if (await library.PlaylistManager.PlayFromSource(songSource, song.Id))
         this.audioControls.Play();
 }
Пример #5
0
        private void AddToList(SQLiteConnection connection, int index, SongSource songSource)
        {
            connection.Execute("create temp table NewPlaylistSongs as select Id as SongId " + songSource.Sql, songSource.SqlArguments);

            var addCount = connection.Query<Song>("select count(*) as Id from NewPlaylistSongs").First().Id;

            if (index <= this.CurrentIndex)
                this.CurrentIndex += addCount;

            connection.Execute("update CurrentPlaylistSong set Rank = Rank + ?, ActualRank = Rank + ? where Rank >= ?", addCount, addCount, index);

            connection.Execute("insert into CurrentPlaylistSong select NULL as Id, SongId as SongId, rowid + ? as Rank, rowid + ? as ActualRank from NewPlaylistSongs", index - 1, index - 1);
            connection.Execute("drop table NewPlaylistSongs");
        }
Пример #6
0
        public Task<bool> AddToEnd(SongSource songSource)
        {
            return this.databaseConnection.TryRunInTransactionAsync(connection =>
            {
                CheckRandomOrderDisabled(connection);

                int count = connection.Table<CurrentPlaylistSong>().Count();
                AddToList(connection, count + 1, songSource);
            });
        }
Пример #7
0
        public Task<bool> AddNext(SongSource songSource)
        {
            return this.databaseConnection.TryRunInTransactionAsync(connection =>
            {
                CheckRandomOrderDisabled(connection);

                AddToList(connection, this.CurrentIndex + 1, songSource);
            });
        }