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?
You also need
Then set an event on Load
In the Video1_Load method add the following:
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 won’t get any data rendered.
I think the MediaElement.ScrubbingEnabled Property is the key.
I tried the same approach without
ScrubbingEnabledbut 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 remember is that the way the MediaElement works, once you callPlay()you may not actuallyPause()on the first frame exactly, so you may want to reduce the volume on the stream before callingPlay()and reset after callingPause().