Export (0) Print
Expand All

How To: Play a Sound

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.

// Audio objects
SoundEffect soundEffect;
string soundName = "kaboom";

Play the sound.

ContentManager contentManager = new ContentManager(this.Services, @"Content\");
soundEffect = contentManager.Load<SoundEffect>(soundName);
soundEffect.Play();

Community Additions

ADD
Show:
© 2014 Microsoft