Seems simple enough, but I cannot figure out any way to determine what the state of a MediaElement is. There are various properties for some states (such as IsBuffering) but
For the WPF MediaElement, here is the solution/workaround I use:
bool IsPlaying()
{
var pos1 = wpfMediaElement.Position;
System.Threading.Thread.Sleep(1);
var pos2 = wpfMediaElement.Position;
return pos2 != pos1;
}
For Universal Windows 10 Platform (UWP)
:
if ( yourMediaElement.CurrentState.ToString() == "Playing" )
{
//nou yourMediaElement is playng
}
or below if you wana use an enum
instead:
if (yourMediaElement.CurrentState == MediaElementState.Playing)
{
//nou yourMediaElement is playng
}