Exemple #1
0
        private async Task AddToQueueAsync(Song song)
        {
            if (QueueSongs.Any(p => p.SongId == song.Id))
            {
                return;
            }

            var prev = QueueSongs.LastOrDefault();

            // Create the new queue entry
            var newQueue = new QueueSong
            {
                SongId = song.Id,
                PrevId = prev == null ? 0 : prev.Id,
                Song   = song
            };

            using (var bg = _bgFunc())
            {
                await bg.InsertAsync(newQueue);

                if (prev != null)
                {
                    prev.NextId = newQueue.Id;
                    await bg.UpdateItemAsync(prev);
                }

                QueueSongsLookup.Add(newQueue.Id, newQueue);
                QueueSongs.Add(newQueue);
            }
        }
Exemple #2
0
        public bool Add(AllJoinedTable allJoinedTable)
        {
            if (!QueueSongs.Any(x => x == allJoinedTable))
            {
                QueueSongs.Add(allJoinedTable);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemple #3
0
        public void QueueSongRange(IEnumerable <AllJoinedTable> songs, int amount)
        {
            var filterCount = songs.Count() - 1;

            if (filterCount > 1)
            {
                _random = new Random();
                for (int i = 0; i < amount; i++)
                {
                    //Select random id from the fitlered count.
                    //Only add song if not already exisiting.
                    var id   = _random.Next(filterCount);
                    var song = songs.ElementAt(id);
                    if (!QueueSongs.Contains(song))
                    {
                        QueueSongs.Add(song);
                    }
                }
            }
        }