question

JessMariSaso-2127 avatar image
0 Votes"
JessMariSaso-2127 asked RichardZhang-MSFT answered

Get image from player to tile app

Hi,
I'm developing a music app and I want to load the image of thumbnail player has into tile app, but I don't find the path of image. I have tried to search on properties of file but I don't find information of it. So, Could you give me some advice in order to get the image of player on tile app?
Thank you

windows-uwp
5 |1600 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.

1 Answer

RichardZhang-MSFT avatar image
1 Vote"
RichardZhang-MSFT answered

Hello,​

Welcome to our Microsoft Q&A platform!

The thumbnail is part of the file, and does not have an independent file path, so if you need to display the thumbnail of the music file on the tile, then you need to save the thumbnail to the local and use the local path.

This is a way to read thumbnails and exist locally:

 private async Task<string> SaveThumbnailToLocal(string fileName, StorageItemThumbnail thumbnail)
 {
     var localFolder = ApplicationData.Current.LocalFolder;
     var tempFile = await localFolder.CreateFileAsync(fileName,CreationCollisionOption.OpenIfExists);
     using (var thumbStream = thumbnail.AsStreamForRead())
     using (var fileStream = await tempFile.OpenStreamForWriteAsync())
     {
         await thumbStream.CopyToAsync(fileStream);
     }
     return $"ms-appdata:///local/{fileName}";
 }

Use

 StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.MusicView);
 string imagePath = await SaveThumbnailToLocal("temp.png", thumbnail);
 // do other things

ms-appdata is a special scheme, it is used to read the files in the application local, roaming or temporary folders, which are related document.

Thanks.

5 |1600 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.