public async Task LoadNextSong() { CurrentSong?.Stop(); CurrentSong = null; if (SongQueue.Count != 0) { lock (_voiceLock) { CurrentSong = SongQueue[0]; SongQueue.RemoveAt(0); } } else { Stop(); 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 Task.Run(async() => 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 void PlaySong(string cueName) { if (CurrentSong != null) { CurrentSong.Stop(AudioStopOptions.Immediate); } CurrentSong = SoundBank.GetCue(cueName); CurrentSong.Play(); }
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(bool leave = false) { Stopped = true; SongQueue.Clear(); try { CurrentSong?.Stop(); } catch { } CurrentSong = null; if (leave) { VoiceClient?.Disconnect(); VoiceClient = null; MusicControls throwAwayValue; MusicModule.musicPlayers.TryRemove(_e.Server, out throwAwayValue); } }
public void Stop() { CurrentSong.MediaEnded -= CurrentSong_MediaEnded; CurrentSong.Stop(); }