Thursday, 15 August 2013

How can I play audio async using MediaElement?

How can I play audio async using MediaElement?

I believe what I'm looking to do is play audio asynchronously. I'm coding
an app for Windows 8 which requires that an audio file is played EVERYTIME
a button is pressed. The problem I'm running into is that, the file will
play, but if it has not finished playing and you hit the button, it will
not sound again.
XAML
<MediaElement x:Name="KickBasicAudio"
Source="Assets/Drums/Dance/KickBasic.wav"
AutoPlay="False" />
<Button Content="KICK" ClickMode="Press" Click="KickBasicPlay"/>
C#
private void KickBasicPlay(object sender, RoutedEventArgs e)
{
KickBasicAudio.Play();
}

No comments:

Post a Comment