0

I used soundeffect instance to play the background music. But I'm not able to stop the sound. I used Common class to play and stop sounds.

Is there anyway to stop music while playing using soundeffectinstance?

1 Answers1

1

SoundEffect is fire-and forget:

Sounds play in a "fire and forget" fashion with Play; therefore, the lifetime of these sounds is managed by the framework. These sounds will play once, and then stop. They cannot be looped or 3D positioned. To loop a sound or apply 3D effects, call CreateInstance instead of Play, or call SoundEffectInstance.Play.

You need to create a SoundEffectInstance instead, then you can use SoundEffectInstance.Stop() ?

ColinE
  • 68,894
  • 15
  • 164
  • 232
  • yes, SoundEffectInstance.Stop() is not worked. Without creating SoundEffectInstance it works well. StreamResourceInfo SoundFileInfo = App.GetResourceStream(new Uri(SoundFilePath, UriKind.Relative)); // Create the SoundEffect from the Stream Sound = SoundEffect.FromStream(SoundFileInfo.Stream); – Charu Latha Jan 17 '12 at 11:40