예제 #1
0
파일: MusicControls.cs 프로젝트: ZR2/l
        public async Task LoadNextSong() {
            CurrentSong?.Stop();
            CurrentSong = null;
            if (SongQueue.Count != 0) {
                CurrentSong = SongQueue[0];
                SongQueue.RemoveAt(0);
            } else {
                VoiceClient?.Disconnect();
                VoiceClient = null;
                return;
            }

            try {
                if (VoiceClient == null) {
                    Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]");
                    //todo add a new event, to tell people nadeko is trying to join
                    VoiceClient = await VoiceChannel.JoinAudio();
                    Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]");
                }
                await Task.Factory.StartNew(async () => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap();
            } catch (Exception ex) {
                Console.WriteLine($"Starting failed: {ex}");
                CurrentSong?.Stop();
                CurrentSong = null;
            }
        }
예제 #2
0
 public MusicStreamer(StreamRequest parent, string directUrl)
 {
     this.parent = parent;
     this.buffer = new DualStream();
     this.Url    = directUrl;
     State       = StreamState.Queued;
 }
예제 #3
0
        public async Task LoadNextSong()
        {
            CurrentSong?.Stop();
            CurrentSong = null;
            if (SongQueue.Count != 0)
            {
                CurrentSong = SongQueue[0];
                SongQueue.RemoveAt(0);
            }
            else
            {
                VoiceClient?.Disconnect();
                VoiceClient = null;
                return;
            }

            try {
                if (VoiceClient == null)
                {
                    Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]");
                    //VoiceClient =


                    //todo add a new event, to tell people nadeko is trying to join
                    VoiceClient = await Discord.Audio.AudioExtensions.JoinAudio(VoiceChannel);

                    Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]");
                }
                await Task.Factory.StartNew(async() => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap();
            } catch (Exception ex) {
                Console.WriteLine($"Starting failed: {ex}");
                CurrentSong?.Stop();
                CurrentSong = null;
            }
        }
예제 #4
0
파일: MusicControls.cs 프로젝트: ZR2/l
        internal void Stop() {
            Stopped = true;
            SongQueue.Clear();
            CurrentSong?.Stop();
            CurrentSong = null;
            VoiceClient?.Disconnect();
            VoiceClient = null;

            MusicControls throwAwayValue;
            MusicModule.musicPlayers.TryRemove(_e.Server, out throwAwayValue);
        }
예제 #5
0
        internal void Stop()
        {
            Stopped = true;
            SongQueue.Clear();
            CurrentSong?.Stop();
            CurrentSong = null;
            VoiceClient?.Disconnect();
            VoiceClient = null;

            MusicControls throwAwayValue;

            MusicModule.Music.musicPlayers.TryRemove(_e.Server, out throwAwayValue);
        }
예제 #6
0
 public MusicStreamer(StreamRequest parent, string directUrl) {
     this.parent = parent;
     this.buffer = new DualStream();
     this.Url = directUrl;
     State = StreamState.Queued;
 }