Reputation: 160
Issue which i am facing is OS takes time to generate thumbnail, if i try to access the thumbnail it is throwing error. Any workaround for this? Can't specify Task.Delay as timings could be different for different phones. I want to show the thumbnail instantaneously.
Upvotes: 1
Views: 92
Reputation: 9289
Home it will help someone. The below code will generate thumb image for video file
var recordedFile =//get StorageFile
var clip = await MediaClip.CreateFromFileAsync(recordedFile);
var comp = new MediaComposition();
comp.Clips.Add(clip);
var thumbstream = await comp.GetThumbnailAsync(TimeSpan.Zero, 320, 240, VideoFramePrecision.NearestKeyFrame);
See this link to get more info about MediaComposition
class.
Upvotes: 0
Reputation: 2260
You can't really speed up processes that take a while to complete. You're at the mercy of the OS to provide you with the thumbnail when it can, but do make sure that you kick off the request as soon as you can.
Make sure all your processes are asynchronous, and the UI will remain responsive during this call. While it processes, you should be showing some sort of an activity indicator to the user, possibly in the form of a TextBlock
with the word "Loading..." near a ProgressRing
that has its IsActive
property set to true
.
Upvotes: 1