Example #1
0
 public static void initialize()
 {
     try
     {
         engine = new IrrKlang.ISoundEngine();
     }
     catch (Exception e)
     {
         return;
     }
 }
Example #2
0
        public void Play()
        {
            if (IsRecording)
            {
                throw new ApplicationException("Can't play while recording.");
            }

            if (_sound != null)
            {
                _engine.StopAllSounds();
            }

            if (!File.Exists(_path))
            {
                throw new FileNotFoundException("Could not find sound file", _path);
            }

            //turns out, the silly engine will keep playing the same recording, even
            //after we've chaned the contents of the file or even delete it.
            //so, we need to make a new engine.
            //   NO   _sound = _engine.Play2D(path, false);

            var engine = new IrrKlang.ISoundEngine();


            // we have to read it into memory and then play from memory,
            // because the built-in Irrklang play from file function keeps
            // the file open and locked
            byte[] audioData = File.ReadAllBytes(_path);                //REVIEW: will this leak?
            _soundSource = engine.AddSoundSourceFromMemory(audioData, _path);
            if (_sound != null)
            {
                _sound.Dispose();
            }
            _sound = engine.Play2D(_soundSource, false, false, false);
            _sound.setSoundStopEventReceiver(_irrklangEventProxy, engine);
        }
        public void Play()
        {
            if(IsRecording)
                throw new ApplicationException("Can't play while recording.");

            if (_sound != null)
            {
                _engine.StopAllSounds();
            }

            if(!File.Exists(_path))
                throw new FileNotFoundException("Could not find sound file", _path);

            //turns out, the silly engine will keep playing the same recording, even
            //after we've chaned the contents of the file or even delete it.
            //so, we need to make a new engine.
            //   NO   _sound = _engine.Play2D(path, false);

            var engine = new IrrKlang.ISoundEngine();

            // we have to read it into memory and then play from memory,
            // because the built-in Irrklang play from file function keeps
            // the file open and locked
            byte[] audioData = File.ReadAllBytes(_path);	//REVIEW: will this leak?
             _soundSource = engine.AddSoundSourceFromMemory(audioData, _path);
            if (_sound != null)
                _sound.Dispose();
            _sound = engine.Play2D(_soundSource, false, false, false);
            _sound.setSoundStopEventReceiver(_irrklangEventProxy,engine);
        }