public static void StopAll(bool immediate = false) { AudioCategory c = m_audioEngine.GetCategory("Default"); c.Stop(immediate ? AudioStopOptions.Immediate : AudioStopOptions.AsAuthored); c = m_audioEngine.GetCategory("Music"); c.Stop(immediate ? AudioStopOptions.Immediate : AudioStopOptions.AsAuthored); }
/// <summary> /// Stops playing anything from an audio category. /// </summary> /// <param name="audioCategoryName">The name of the audio category to stop playing from.</param> public static void StopAudioCategory(string audioCategoryName) { AudioCategory category = audioEngine.GetCategory(audioCategoryName); if (category.Name != null) { category.Stop(); } }
public static void StopEffects() { AudioCategory c = audioEngine.GetCategory("Default"); c.Stop(AudioStopOptions.AsAuthored); }
} // StartMusic() /// <summary> /// Stop music /// </summary> public static void StopMusic() { musicCategory.Stop(AudioStopOptions.Immediate); } // StopMusic()
public void Update(GameTime gameTime) { if (currentMusic == null) { currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist)); //Fake 3D Sound for Surround Effect ;) currentMusic.Apply3D(new AudioListener(), new AudioEmitter()); currentMusic.Play(); popUpText.Text = currentPlaylist[currentMusic.Name]; StartPopUp(); } if (currentMusic.IsStopped) { currentMusicindex++; if (currentMusicindex >= playList.Keys.Count) { currentMusicindex = 0; } currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist)); currentMusic.Apply3D(new AudioListener(), new AudioEmitter()); currentMusic.Play(); popUpText.Text = currentPlaylist[currentMusic.Name]; StartPopUp(); } if (transition) { oldVolume -= gameTime.GetElapsedTotalSecondsFloat(); oldVolume = MathHelper.Clamp(oldVolume, 0, options.MusicVolumeFloat); currentVolume += gameTime.GetElapsedTotalSecondsFloat(); if (currentVolume >= options.MusicVolumeFloat) { transition = false; currentVolume = MathHelper.Clamp(currentVolume, 0, options.MusicVolumeFloat); oldCategory.Stop(AudioStopOptions.Immediate); oldMusic.Stop(AudioStopOptions.Immediate); } oldCategory.SetVolume(oldVolume); currentCategory.SetVolume(currentVolume); } if (popUpActive) { if (popUpFloatIn) { popUp.Y += (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat()); AlignPopUpText(); if (popUp.Y >= 0) { popUpFloatIn = false; } } else { popUpStillStandelpasedTime += gameTime.GetElapsedTotalSecondsFloat(); if (popUpStillStandelpasedTime >= popUpStillStandThreshold) { popUp.Y -= (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat()); if (popUp.X <= -(int)(options.Resolution.ScreenHeight * 0.1)) { popUpActive = false; } AlignPopUpText(); } } } }