如何确定 MediaElement 是否正在播放? [英] How do I determine if MediaElement is playing?
问题描述
看起来很简单,但我想不出任何方法来确定 MediaElement 的状态.某些状态(例如 IsBuffering)有各种属性,但我找不到播放、暂停等状态的任何属性.Silverlight 似乎有一个 CurrentState 属性可以显示所有这些.
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 I can't find any for states such as Play, Pause, etc. Silverlight seems to have a CurrentState property that shows all these.
目前我确定视频是否应该播放的方式是观察各种事件和一个计时器,检查是否正在取得任何进展.
Currently the way I'm determining whether a video is supposed to be playing is watching for various events and a timer that checks to see if any progress is being made.
我是 MediaElement 和 WPF 的新手(我实际上只在 WinForms 应用程序中使用 MediaElement).有什么我遗漏的吗?
I'm new to MediaElement and WPF (I'm actually only using MediaElement in a WinForms app). Is there something I am missing?
推荐答案
您没有遗漏任何东西.您几乎必须手动跟踪媒体是否正在播放.很遗憾,因为正如您所提到的,在 Silverlight 中这很容易.对我来说似乎是一个重大疏忽.
You aren't missing anything. You pretty much have to manually keep track of whether or not the media is playing. It's a pity, since it is so easy in Silverlight, as you mention. Seems like a major oversight to me.
这篇关于如何确定 MediaElement 是否正在播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!