question

EywaOnTheWay avatar image
0 Votes"
EywaOnTheWay asked ·

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

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();
                         }
    
                     }
                 }


windows-uwp
· 3
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Have you tried get thumbnail with ThumbnailMode.VideosView?

0 Votes 0 ·

Thank you for your comment!!
I use VideosView or Pictures view only for folder, NOT a single file as ms doc recommends.


0 Votes 0 ·

Please check this document, it suggest use
ThumbnailMode.VideosView to get a thumbnail image to preview a video file

0 Votes 0 ·

1 Answer

NicoZhu-MSFT avatar image
0 Votes"
NicoZhu-MSFT answered ·

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.