Uwp how to detect if the thumbnail is NOT real one (or placeholder thumbnail) from windows?

SmilingMoon 981 Reputation points
2021-03-12T20:16:42.92+00:00

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?
77355-2021-03-12-12-13-22-window.png

Below is good thumbnail which I wish to get. When I retry, windows generates the following.
77350-2021-03-12-12-14-57-window.png

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();  
                        }  
  
                    }  
                }  
Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,856 Reputation points
    2021-03-15T06:37:06.637+00:00

    Hello, Welcome to Micorosoft Q&A,

    Uwp how to detect if the thumbnail is NOT real one (or placeholder thumbnail) from windows?

    Currently, there is no such api could detect if the thumnail is real or not, But for your requirement, You could use ThumbnailMode.VideosView to get a thumbnail image to preview a video file.

    StorageItemThumbnail thumbnail = await   file.GetThumbnailAsync(ThumbnailMode.VideosView, 250)  
    

    For more please refer this document.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments