static void Main(string[] args) { string soundToPlay = "Airhorn.wav"; string currentDir = Environment.CurrentDirectory; if (args.Length < 1) { Console.WriteLine("Please specify which sound to play."); } else { soundToPlay = args[0]; } Console.WriteLine("Playing {0}", soundToPlay); //Get the list of installed sound devices. IrrKlang.ISoundDeviceList sdl = new IrrKlang.ISoundDeviceList(IrrKlang.SoundDeviceListType.PlaybackDevice); // start the sound engine int AudioDevice = 0; if (args.Length > 1) { int j; if (Int32.TryParse(args[1], out j)) { AudioDevice = j; } else { Console.WriteLine("String could not be parsed."); } } ISoundEngine engine = new ISoundEngine(IrrKlang.SoundOutputDriver.AutoDetect, IrrKlang.SoundEngineOptionFlag.DefaultOptions, sdl.getDeviceID(AudioDevice)); engine.Play2D("" + currentDir + "\\" + soundToPlay); do { //don't close me yet }while (engine.IsCurrentlyPlaying("" + currentDir + "\\" + soundToPlay)); }
public void Update(GameTime gameTime) { if ((int)map.Player.me.X >= minx && (int)map.Player.me.X <= maxx && (int)map.Player.me.Y >= miny && (int)map.Player.me.Y <= maxy) { onRoom = true; if (engine.IsCurrentlyPlaying("sounds/rooms/" + sound + ".mp3") == true) { return; } else { engine.Play2D("sounds/rooms/" + sound + ".mp3", true); } } else { onRoom = false; engine.RemoveAllSoundSources(); } }