Demonstrates how to play a sound.
To play a sound without using XACT, you will use the SoundEffect or SoundEffectInstance classes. Using these classes is simpler than using XACT and the classes required by XACT.
Because XACT is not available on Zune, the SoundEffect and SoundEffectInstance will be the only option for Zune games.
SoundEffect and SoundEffectInstance are also available for Xbox and Windows XNA games.
Simple Sound Playing
Declare SoundEffect.
C#
// Audio objects SoundEffect soundEffect; string soundName = "kaboom";
Play the sound.
C#
ContentManager contentManager = new ContentManager(this.Services, @"Content\"); soundEffect = contentManager.Load<soundeffect>(soundName); soundEffect.Play();
- 本文固定链接: http://www.wy182000.com/2009/02/22/how-to-play-a-sound/
- 转载请注明: wy182000 于 Studio 发表