What to use to play sound effects in silverlight for wp7

I know that I can reference XNA for the SoundEffect class and what I have done so far, but I was wondering if there was a better way than what I did.

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

using (var stream = TitleContainer.OpenStream("test.mp3"))
{
          var effect = SoundEffect.FromStream(stream);
          FrameworkDispatcher.Update();
          effect.Play();
}

For my test application, I have 20 sounds, every 1 second, which I want to play when the button is pressed. I play with different tricks, but if possible, I would like to know how professionals do this before making an application based on the sound effect. Small things, such as loading a sound effect or loading it, a button will be pressed, a pressed button.

Thank.

+5
source share
2

, PhoneyTools SoundEffectPlayer

SoundEffect XNA. , . :

public partial class MediaPage : PhoneApplicationPage
{
  // ...

  SoundEffectPlayer _player = null;

  private void playButton_Click(object sender, RoutedEventArgs e)
  {
    var resource = Application.GetResourceStream(new Uri("alert.wav", UriKind.Relative));
    var effect = SoundEffect.FromStream(resource.Stream);
    _player = new SoundEffectPlayer(effect);
    _player.Play();

  }
}
+2

, AppHub. , . .

, XNA Framework SoundEffect SoundEffectInstance Silverlight Windows . DispatchTimer FrameworkDispatcher.Update , XNA . , , , SoundEffect.

+2

All Articles