示例#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;
 }