I generate thumbnail,
but sometimes for video files, it returns placeholder thumbnail which I don't want to save and want to retry to generate again.
To do so, I have to know how to identify programmatically without for me to looking at it if it's placeholder.
This is placeholder thumbnail returned for video in my comp. It seems windows didn't generate the thumbnail yet. But, how do I know?
Below is good thumbnail which I wish to get. When I retry, windows generates the following.
using (StorageItemThumbnail thumbnail = await StorageFile.GetThumbnailAsync(ThumbnailMode.SingleItem, 250)) //Do not use PictureVeiw which show only partial cropped picture thumbnail.
{
await bitmapImg.SetSourceAsync(thumbnail); //complete generate Thumbnail image.
//---------- Save thumbnail image
if (App.OrganizerOption.ThumbnailFolder != null) //just double check
{
//get softwareBitmap with decoder
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(thumbnail.CloneStream());
using (SoftwareBitmap softwareBitmap = await decoder.GetSoftwareBitmapAsync())
{
StorageFile file_Save = await App.OrganizerOption.ThumbnailFolder.CreateFileAsync(ThumbnailFileName, CreationCollisionOption.ReplaceExisting);
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(Windows.Graphics.Imaging.BitmapEncoder.JpegEncoderId, await file_Save.OpenAsync(FileAccessMode.ReadWrite));
encoder.SetSoftwareBitmap(softwareBitmap);
await encoder.FlushAsync();
}
}
}