How do I determine if MediaElement is playing?

前端 未结 8 2225
闹比i
闹比i 2021-01-01 09:44

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

8条回答
  •  鱼传尺愫
    2021-01-01 10:42

    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
    }
    

提交回复
热议问题