视频显示在WPF MediaElement的第一帧 [英] Show first frame of video in WPF MediaElement

查看:682
本文介绍了视频显示在WPF MediaElement的第一帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序与我用它来运行视频中的MediaElement。我不想让视频自动播放加载的时候,所以我设置LoadedBehavior为手动。

I have a WPF-application with a MediaElement which I use to run a video. I don't want the video to autoplay when loaded, so I set the LoadedBehavior to Manual.

<MediaElement LoadedBehavior="Manual" 
              Source="foo.wmv" 
              MediaOpened="videoElement_MediaOpened" />

不过,欲加载的时候元件来显示视频的第一帧。是否有这样做的任何神奇的方法是什么?

However; I want the element to show the first frame of the video when loaded. Is there any magic way of doing this?

推荐答案

您还需要

ScrubbingEnabled="True"

然后在加载设置事件

Then set an event on Load

Loaded="Video1_Loaded"

在Video1_Load方法中添加以下内容:

In the Video1_Load method add the following:

Video1.Play();
Video1.Pause();

无视频内容的呈现剧中方法被调用之前。所以,即使你设置的位置的第1帧,你不会得到任何数据呈现的。

None of the video content is rendered before the play method is called. So even if you set the position past the first frame you wont get any data rendered.

我觉得<一href="http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.scrubbingenabled.aspx">MediaElement.ScrubbingEnabled属性是关键。

获取或设置一个值,该值指示   是否会MediaElement的更新   为寻求操作,同时帧   暂停。这是一个依赖项属性。

Gets or sets a value that indicates whether the MediaElement will update frames for seek operations while paused. This is a dependency property.

我想没有ScrubbingEnabled同样的方法,但发现的第一帧将不会渲染。不知道这只是我使用这个硬件。其他项目rember是,MediaElement的工作,顺便当你调用播放(),你可能不实际暂停()在第一帧完全,所以你可能需要调用播放之前,以减少对数据流的数量和呼叫后重置暂停。

I tried the same approach without ScrubbingEnabled but found that the first frame wouldn't render. Not sure if it's just the hardware I am using for this. The other item to rember is that the way the MediaElement works, once you call Play() you may not actually Pause() on the first frame exactly, so you may want to reduce the volume on the stream before calling Play and reset after calling Pause.

这篇关于视频显示在WPF MediaElement的第一帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆