[Solved] Album art of mp3 music file [duplicate]


You could use StorageFile.GetThumbnailAsync method to do this. If you want to get more info, please refer to the Scenario2 of official sample.

XAML code:

<Grid>        
    <StackPanel>
         <Button Content="Load Album art" Click="Button_Click"/>
         <Image x:Name="ImageControl"/>
      </StackPanel>
</Grid>

Code behind:

private async void Button_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.SuggestedStartLocation = PickerLocationId.Downloads;
            openPicker.FileTypeFilter.Add(".mp3");
            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                const ThumbnailMode thumbnailMode = ThumbnailMode.MusicView;
                const uint size = 100;
                using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(thumbnailMode, size))
                {
                    if (thumbnail != null && thumbnail.Type == ThumbnailType.Image)
                    {
                        var bitmapImage = new BitmapImage();
                        bitmapImage.SetSource(thumbnail);
                        ImageControl.Source = bitmapImage;
                    }
                    
                }
            }
        }

1

solved Album art of mp3 music file [duplicate]