How To: Loop a Sound

Demonstrates how to loop a sound.

The Complete Sample

The code in this topic shows you the technique. You can download a complete code sample for this topic, including full source code and any additional supporting files required by the sample.

Simple Sound Looping

  1. Declare a SoundEffect using the method shown in How To: Play a Sound.

  2. Declare a SoundEffectInstance, and set it to the return value of SoundEffect.CreateInstance.

  3. Set SoundEffectInstance.IsLooped to true.

  4. Call SoundEffectInstance.Play to play the looping sound.

SoundEffectInstance instance = soundEffect.CreateInstance();
instance.IsLooped = true;
instance.Play();

Community Additions

ADD
Show: