WPF: Preview of MediaElement video (with a large number of files)
I can successfully display the first frame of a MediaElement in my ListBox (using this method).
But when I get a large number of files (more than 20), it takes a long time before anything shows up.I considered having the source point to just an image of the video, but there's not a good way to get an image of a MediaElement frame.
Anot开发者_如何学运维her thought was to use the thumbs.db file, but Windows doesn't always generate one of those, and I don't know how to that anyways. I also considered just loading the MediaElements that are visible in my ListBox, and as the user scrolls I'd load more, but I'm not sure on how to do this either.Does anybody know of some way to get the image to display quickly when dealing with a large number of MediaElements?
In case anybody else comes across this, here's what I ended up doing:
I replaced the MediaElement
s with Image
s. In my MediaItem
's constructor, I save a thumbnail to a specified folder if it does not already exist. Using this code allows it to be asynchronous. Then all I had to do was to add an EventHandler
to my MediaItem
to let the UI know when to refresh the Image
once the thumbnail was saved. (I also restricted the ThreadPool
.)
精彩评论