I’m getting a very strange error. In my XAML I have two MediaElement tags are associated with 2 different sounds. I however, it doesn’t play the right one.
XAML
<MediaElement x:Name="Sound" Source="Sounds/fusrodah.wma" AutoPlay="False" MediaFailed="Sound_MediaFailed" />
<MediaElement x:Name="Sound1" Source="Sounds/yoltorshul.wma" AutoPlay="False" />
<MediaElement x:Name="Sound2" Source="Sounds/iizslennus.wma" AutoPlay="False" />
C#
private void shout_Click(object sender, RoutedEventArgs e)
{
this.Sound.Play();
}
By the code written here it should play the media for Sound (ie, ‘Sounds/fusrodah.wma’) instead it plays the sound for Sound2(Sounds/iizslennus.wma).
Also I observed that whatever that last MediaElement tag’s source is what gets played (ie if I added a Sound3, its the media for that that would get played.
I don’t understand, this is a very strange error. I’ve listened to the tracks multiple times to make sure I didn’t mix them up. I’ve checked their paths multiple times. Does anyone have any idea why it doesn’t play what it is specified to play?
You can only have one MediaElement on the page. That’s why it only plays the last MediaElement added.