views:

28

answers:

1

I am looking for a solution for a question that was already posted but did not answer correctly, thanks in advance.

http://stackoverflow.com/questions/1346886/show-first-frame-of-video-in-wpf-mediaelement

A: 

The solution in the other thread should work but you could approach it differently.

Basically, to avoid having to load the video just to grab the first frame you could generate a static image that is the frame you want to show. If you are encoding the video most encoding software will generate a thumbnail for you for this purpose. If not you can screen shot a frame and use that

Then display that image in a normal WPF image control when the movie is not playing. When the user plays the video use a trigger to hide the image and show the video.

This will give you the effect you want.

Downside: This static image will get out of sync with the video if your video file is updated (you would need to regenerate the thumbnail in this case)

Foovanadil
thanks, I was thinking of this but lots of work for such a simple scenario.
Dave Jones
yes and no. It is a little more work but it gives you some more flexibility (able to show a broken image if the video fails to load, show a image not actually in the video etc..) and saves you the performance hit o loading every video just to show a thumbnail.
Foovanadil