예제 #1
0
        public async Task <(QueueEntryInfo, ServiceResult)> GetNextSong()
        {
            var queue = await DbContext.GetGuildQueue(Guild.Id);

            int nextSong = 0;

            if (queue.Count != 1 && RepeatMode == RepeatMode.All)
            {
                RepeatAllPos++;
            }
            if (RepeatAllPos >= queue.Count)
            {
                RepeatAllPos = 0;
            }
            if (ShuffleMode == ShuffleMode.Off)
            {
                nextSong = queue[0].Position;
            }
            else
            {
                nextSong = queue[new Random().Next(0, queue.Count)].Position;
            }
            if (RepeatMode == RepeatMode.All)
            {
                nextSong = queue[RepeatAllPos].Position;
            }
            if (RepeatMode == RepeatMode.On)
            {
                nextSong = CurrentSong.Position;
            }
            var serviceManager = new ServiceResolver();
            var result         = await serviceManager.GetServiceResults(queue[nextSong].DBTrackInfo.Url,
                                                                        new ContentServiceMatch(queue[nextSong].DBTrackInfo.ContentService,
                                                                                                Playlist.No));

            return(queue[nextSong], result[0]);
        }