Esempio n. 1
0
        public async Task loadAndPlay(string query, IGuild guild)
        {
            List <AudioTrack> tracks;

            // If query is Url
            if (Uri.IsWellFormedUriString(query, UriKind.Absolute))
            {
                Console.WriteLine(query + " is url");
                tracks = await TrackLoader.LoadAudioTrack(query, fromUrl : true);
            }
            else
            {
                Console.WriteLine(query + " is not url");
                tracks = await TrackLoader.LoadAudioTrack(query, fromUrl : false);
            }

            if (tracks.Count == 0)
            {
                return;
            }

            Console.WriteLine("Loaded " + tracks.Count + " entri(es)");

            GuildVoiceState voiceState = MusicManager.GetGuildVoiceState(guild);

            foreach (AudioTrack track in tracks)
            {
                //await voiceState.Scheduler.EnqueueAsync(track);
                voiceState.Scheduler.Enqueue(track);
                Console.WriteLine("Enqueued " + track.TrackInfo.Title);
            }
        }
Esempio n. 2
0
        public async Task <AudioTrack> LoadAndPlay(string query, IGuild guild)
        {
            List <AudioTrack> tracks;

            // If query is Url
            bool wellFormedUri = Uri.IsWellFormedUriString(query, UriKind.Absolute);

            tracks = await TrackLoader.LoadAudioTrack(query, fromUrl : wellFormedUri).ConfigureAwait(false);

            if (tracks.Count == 0)
            {
                return(null);
            }

            Console.WriteLine("Loaded " + tracks.Count + " entri(es)");

            GuildVoiceState voiceState = GetVoiceState(guild);

            foreach (AudioTrack track in tracks)
            {
                Console.WriteLine("Enqueue " + track.Info.Title);
                await voiceState.Scheduler.Enqueue(track);

                return(track);
            }

            return(null);
        }