Windows Phone 7 doesn't support multiple MediaElement. In order to play multiple sounds in the same page, you may use the following approach.
Add a reference to Microsoft.Xna.Framework

Add the following using statementsā¦
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
Add the sound files and ensure that Copy to Output directory is set to Content

Add the following method to your pageā¦
public void PlaySound(string soundFile)
{
using (var stream = TitleContainer.OpenStream(soundFile))
{
var effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();
//Thread.Sleep(effect.Duration);
}
}
You can now call this Method with a valid Sound file (WAV file) and it should play.
Notice the commented code above. If the sound file take a while to play, you may decide to uncomment this line so that the entire sound clip is played. This would be a blocking call though.
Until next time,
Rahul
Quote of the day:
It is not necessary to understand things in order to argue about them. - Pierre Beaumarchais