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; } }
public MusicStreamer(StreamRequest parent, string directUrl) { this.parent = parent; this.buffer = new DualStream(); this.Url = directUrl; State = StreamState.Queued; }
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; } }
internal void Stop() { Stopped = true; SongQueue.Clear(); CurrentSong?.Stop(); CurrentSong = null; VoiceClient?.Disconnect(); VoiceClient = null; MusicControls throwAwayValue; MusicModule.musicPlayers.TryRemove(_e.Server, out throwAwayValue); }
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); }