private void Client_OnUserJoined(object sender, OnUserJoinedArgs e) { Console.WriteLine($"{e.Username} joined the channel. Welcome!"); // Check userSounds to see if the user has a sound file UserSound userSound = this.UserSounds.Find(s => s.Username.ToLower() == e.Username.ToLower()); if (userSound != null) { // User was found, play the sound if (SoundCommand.Exists(userSound.Sound)) { soundProcessor.Queue(new SoundCommand(userSound.Sound)); } } }
private void Client_OnChatCommandReceived(object sender, OnChatCommandReceivedArgs e) { Console.WriteLine($"Chat Command - {e.Command.ChatMessage.Username}: {e.Command.ChatMessage.Message}"); // TODO: We may want !stop to be a mod only command. Maybe? if (e.Command.CommandText.ToLower() == "stop") { Console.WriteLine("Stopping sounds"); soundProcessor.CurrentlyPlaying.Dispose(); soundProcessor.Dispose(); } else if (SoundCommand.Exists(e.Command.CommandText)) { soundProcessor.Queue(new SoundCommand(e.Command.CommandText)); } }
public static bool Exists(string name, out SoundCommand command) { string soundPath = _soundAssetsPath + name + ".mp3"; var f = new FileInfo(soundPath); if (f.Exists) { command = new SoundCommand(name); } else { command = null; } return(f.Exists); }
public void Process(int timeout = 100) { SoundCommand sound = null; try { while (Sounds.TryTake(out sound, timeout, canceller.Token)) { // Here we want to play the audio this.CurrentlyPlaying = sound; this.CurrentlyPlaying.Execute(); } } catch (Exception ex) { Console.WriteLine("We have encountered the following error: {0}", ex.Message); } }
public void Queue(SoundCommand sound) { this.Sounds.Add(sound); }