Пример #1
0
        public async Task AddRandomSongAsync()
        {
            var song = await SelectRandomSongAsync().ConfigureAwait(false);

            // if for some reason could not find new song to play
            // then just add currently playing track to upcoming songs
            // (the same logic is implemented in synchronous version as well)
            UpcomingSongs.Add(song ?? CurrentSong);
        }
Пример #2
0
        /// <summary>
        /// Method removes song by its ID from the list of upcoming songs
        /// and adds new randonly selected song to the list (to keep its size constant)
        /// </summary>
        public void RemoveSong(int songId)
        {
            for (var i = 0; i < MaxSongs; i++)
            {
                if (UpcomingSongs[i].Id != songId)
                {
                    continue;
                }

                UpcomingSongs.RemoveAt(i);
                UpcomingSongs.Add(SelectRandomSong());

                return;
            }
        }
Пример #3
0
 public void AddRandomSong() => UpcomingSongs.Add(SelectRandomSong() ?? CurrentSong);