Get image from player to tile app

Jesús Mari Saso 21 Reputation points
2020-04-23T21:27:30.513+00:00

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

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-04-24T02:10:12.953+00:00

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful