I tried to use MediaElement to play a sound, and use its event CurrentStateChanged, to view the various play states.
In particular, I need to see when it is stopped, so another source can be queued. But in the following code, the only events I see generated report: Opening, Playing, Paused. And then the sound is fully over. No Stopped ever appears.
What am I missing? I need to bind to it.
XAML
<MediaElement x:Name="mplayer" Source="Assets/test.wav" AutoPlay="True" CurrentStateChanged="MediaElement_CurrentStateChanged" >
</MediaElement>
CODE BEHIND
private void MediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)
{
Debug.WriteLine(mplayer.CurrentState.ToString());
}
p.s. if I detect the Paused condition, then command a mplayer.Stop(), a stop is generated. But not normally.