有没有办法检查何时到达设定的媒体元素位置?
当我在媒体元素中设置位置时,是否有任何事件或事物需要检查以查看它何时到达该位置?
我尝试检查缓冲,因为我认为它会这样做,但没有。我也尝试过获得该位置,但原因之一返回了我刚刚设置的值,即使搜索尚未完成。
When I set the position in a mediaelement is there any event or thing to check to see when it has reached that position?
I have tried to check for buffering as I figured it would do that but no. I have also tried get the position but that one of cause returns what I just set even though the seek is not yet done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以检查(MediaElement.Position 属性)http: //msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.position.aspx
You can check (MediaElement.Position Property) http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.position.aspx
不幸的是,没有任何事件可以支持这一点。如果您的目标是从 x 位置播放文件到 y 位置,则可以使用 MediaTimeline,从中创建一个时钟并将时钟添加到 MediaElement。但是,如果您需要将某些内容与播放同步,唯一的选择是使用计时器来一次又一次检查位置。
Unfortunately, there is no event to support that. If your aim is to play the file from x position to y position, you can use MediaTimeline, create a clock from it and add the clock to MediaElement. If however, you need to synchronise something with your playback, the only option is to use a timer to check for position again and again.
我正在使用:
一旦位置发生变化并且视频已渲染,这似乎就会触发。
I'm using:
That seems to fire once the position has changed, and the video has been rendered.
对于那些寻找
MediaPlayerElement
而不是 MediaElement(如 Microsoft 文档建议使用)的人,您可以通过订阅来完成此操作:然后,在处理程序中,检查
sender.Position
为了新的职位。For those that came looking for
MediaPlayerElement
instead of MediaElement (as Microsoft's docs recommend using), you can do this by subscribing to:Then, in the handler, check
sender.Position
for the new position.