Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loaders"></param>
        /// <param name="fileSystem"></param>
        public void Initialize(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem)
        {
            StopMusic();
            soundEngine.StopAllSounds();

            if (sounds != null)
            {
                foreach (var soundSource in sounds.Values)
                {
                    if (soundSource != null)
                    {
                        soundSource.Dispose();
                    }
                }
            }

            this.loaders    = loaders;
            this.fileSystem = fileSystem;
            Func <ISoundFormat, ISoundSource> loadIntoMemory = soundFormat => soundEngine.AddSoundSourceFromMemory(
                soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate);

            sounds = new Cache <string, ISoundSource>(filename => LoadSound(filename, loadIntoMemory));

            currentSounds = new Dictionary <uint, ISound>();
            video         = null;
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     if (FEngine != null)
     {
         FEngine.StopAllSounds();
         FEngine.RemoveAllSoundSources();
         FEngine = null;
     }
 }
 public void StopPlaying()
 {
     if (_sound != null && !_sound.Finished)
     {
         _sound.Stop();
     }
     if (IsPlaying)
     {
         _player.Stop();
     }
     try
     {
         _engine.RemoveAllSoundSources();
     }
     catch (Exception)
     {
         // We'll just ignore any errors on stopping the sounds (they probably aren't playing).
     }
     _engine.StopAllSounds();
     if (_sound != null)
     {
         _sound.Dispose();
     }
     _sound = null;
 }
Exemplo n.º 4
0
        private void tTimer_Tick(object sender, EventArgs e)
        {
            if (iCounter > iBeatsPerSequence)
            {
                iCounter = 1;
            }

            if (iPlayedBeats[iCounter - 1] != 0)
            {
                if (!Rested)
                {
                    sePlayer.StopAllSounds();
                    sePlayer.Play2D(strSoundslot);
                }
            }
            iCounter++;
        }
Exemplo n.º 5
0
 // Window.Closing event handler for this application
 // Writing back to registr & stoping all sound...
 void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     WriteRegistrys();
     if (sound_player != null)
     {
         soundEngine.StopAllSounds();
     }
 }
Exemplo n.º 6
0
 public void Stop()
 {
     if (_soundPlaying != null)
     {
         _soundPlaying.Stop();
         _soundPlaying = null;
         _soundEngine.RemoveAllSoundSources();
         _soundEngine.StopAllSounds();
     }
 }
Exemplo n.º 7
0
        private void Disable(bool value)
        {
            if (enabled == value)
            {
                return;
            }

            enabled = value;

            if (!value)
            {
                soundEngine.StopAllSounds();
                musicEngine.StopAllSounds();
            }
            else
            {
                SetMusicVolume(float.Parse(GameProperties.Props.Get(PropertyKey.MUSIC_VOLUME), CultureInfo.InvariantCulture));
                music.ForEach(sound => StartPlayingInfinite(sound));
            }
        }
Exemplo n.º 8
0
        public static void Stop()
        {
            if (CurrentSong != null)
            {
                CurrentSong.IsPlaying = false;
                CurrentSong.Style     = Text.Styles.Regular;
            }

            IsPlaying = false;
            Engine.StopAllSounds();
        }
Exemplo n.º 9
0
 private void StopAllSounds()
 {
     fadeOut(PitLane);
     fadeOut(Crowd);
     fadeOut(EnvAmbience);
     fadeOut(Announcer);
     fadeOut(Guns);
     fadeOut(Siren);
     fadeOut(Repair);
     fadeOut(Music);
     fadeOut(Fueling);
     Engine.StopAllSounds();
     Engine.Dispose();
 }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 public void Play(string filename = null)
 {
     if (filename == null)
     {
         playerStopWatch.Start();
         engine.SetAllSoundsPaused(false);
     }
     else
     {
         playerStopWatch.Restart();
         engine.StopAllSounds();
         currentSound = engine.Play2D(filename);
     }
     IsPlaying = true;
 }
Exemplo n.º 12
0
        private void btnChooseFile_Click(object sender, EventArgs e)
        {
            eng.StopAllSounds();
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                path            = ofd.FileName;
                name            = ofd.SafeFileName;
                tbFileName.Text = name;
                S = eng.Play2D(path, false, false, StreamMode.AutoDetect, true);
                int length = Convert.ToInt32(S.PlayLength / 1000);
                tbarProgress.Maximum = length;
                superflag            = 1;
            }
        }
Exemplo n.º 13
0
 public void DisposeHandle()
 {
     if (MediaControl != null)
     {
         MediaControl.Stop();
     }
     timer1.Stop();
     soundengine.StopAllSounds();
     if (pictureBox1.Image != null)
     {
         pictureBox1.Image.Dispose();
     }
     CleanUp();
     if (currentSound != null)
     {
         currentSound.Dispose();
     }
     tlp.Visible = false;
 }
Exemplo n.º 14
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (BGM.Count > 0)
            {
                bgmEngine.SoundVolume -= ((float)gameTime.ElapsedGameTime.TotalSeconds / 2);

                if (bgmEngine.SoundVolume <= 0)
                {
                    string song = BGM.Dequeue();
                    bgmEngine.StopAllSounds();
                    bgmEngine.Play2D($"content/audio/{song}.ogg", true);
                }
            }
            else
            {
                if (bgmEngine.SoundVolume < 1)
                {
                    bgmEngine.SoundVolume += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
            }
        }
Exemplo n.º 15
0
 public static void StopBGM()
 {
     IBGM.StopAllSounds();
 }
Exemplo n.º 16
0
 public override void Dispose()
 {
     soundEngine.StopAllSounds();
     soundEngine.RemoveAllSoundSources();
     soundEngine = null;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            if (Keyboard.GetState().IsKeyDown(Keys.D1))
            {
                previousLevel = currentLevel;
                currentLevel  = 1;
                SetupLevel();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D2))
            {
                previousLevel = currentLevel;
                currentLevel  = 2;
                SetupLevel();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D3))
            {
                previousLevel = currentLevel;
                currentLevel  = 3;
                SetupLevel();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.M))
            {
                playSound = !playSound;
                soundMode = playSound ? "on" : "off";
                if (!playSound)
                {
                    engine.StopAllSounds();
                }
                else if (playGame && !firstStart)
                {
                    engine.Play2D("Content/iceMove.wav", true);
                }
            }

            DeltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (playGame && !firstStart)
            {
                batSpownTimer += DeltaTime;
                UpdateTimer();
                if (batSpownTimer >= 8)
                {
                    director = new Director(new BatBuilder());
                    GameObject bat = director.Construct(new Vector2(rnd.Next(450, 750), rnd.Next(50, 500)));
                    bat.LoadContent(Content);
                    gameObjects.Add(bat);
                    batSpownTimer = 0;
                    if (playSound)
                    {
                        engine.Play2D("Content/bat1.wav", false);
                    }
                }

                ClearLists();

                foreach (GameObject go in gameObjects)
                {
                    go.Update();
                }

                if (restartGame == true)
                {
                    restartGame = false;
                }
            }
            base.Update(gameTime);
        }
Exemplo n.º 18
0
 public void StopAudio()
 {
     soundEngine.StopAllSounds();
 }
Exemplo n.º 19
0
 protected override void DisposeInternal()
 {
     engine.StopAllSounds();
     engine.RemoveAllSoundSources();
 }
Exemplo n.º 20
0
 public static void DisposeSoundEngine()
 {
     SoundEngine.StopAllSounds();
     SoundEngine.Dispose();
 }
Exemplo n.º 21
0
 static public void stop()
 {
     bgm.StopAllSounds();
     bgm.Dispose();
     bgm = new ISoundEngine();
 }
Exemplo n.º 22
0
 public static void StopBackgroundMusic()
 {
     backgroundEngine.StopAllSounds();
 }
Exemplo n.º 23
0
 private void button2_Click(object sender, EventArgs e)
 {
     //player.Stop();
     //       mciSendString("close MediaFile", null, 0, IntPtr.Zero);
     soundPlayer.StopAllSounds();
 }
Exemplo n.º 24
0
 public void stopPlaying()
 {
     engine.StopAllSounds();
 }
Exemplo n.º 25
0
 public static void StopAll( )
 {
     SE.StopAllSounds( );
 }
Exemplo n.º 26
0
 public void StopSound()
 {
     engine.StopAllSounds();
 }
Exemplo n.º 27
0
        } // end DoSoundEffects

        //=============================================================================
        public void StopSoundEffects()
        {
            effectsEngine.StopAllSounds();
        }
Exemplo n.º 28
0
 /// <summary>
 /// Stops currently playing song and ISoundStopEventReceiver plays the next one.
 /// </summary>
 public void PlayNextSong()
 {
     engine.StopAllSounds();
 }