Shiny .NET v4 is here with BLE Windows Support, Improved GPS, & More! Check It Out
Album Art
The IMediaLibrary.GetAlbumArtPathAsync method retrieves album artwork for a track and returns it as a file path that can be used directly as an image source.
Basic Usage
Section titled “Basic Usage”var artPath = await _library.GetAlbumArtPathAsync(track.Id);
if (artPath != null){ // Use in MAUI var imageSource = ImageSource.FromFile(artPath);}The method returns null if no artwork is available for the track.
Using in XAML
Section titled “Using in XAML”You can bind album art in your view model and use it as an ImageSource:
// In your ViewModelpublic async Task LoadAlbumArt(string trackId){ var path = await _library.GetAlbumArtPathAsync(trackId); AlbumArtSource = path != null ? ImageSource.FromFile(path) : null;}<!-- In your XAML --><Image Source="{Binding AlbumArtSource}" WidthRequest="300" HeightRequest="300" Aspect="AspectFill" />Platform Behavior
Section titled “Platform Behavior”Android
Section titled “Android”Returns the content URI for the album art from MediaStore (content://media/external/audio/albumart/{albumId}). This URI can be used directly with MAUI’s image loading.
iOS does not expose album art as a URI. Instead, GetAlbumArtPathAsync:
- Retrieves the
MPMediaItem.Artworkimage object - Renders it at 600x600 pixels
- Encodes it as JPEG (85% quality)
- Saves it to the app’s caches directory (
Library/Caches/albumart/{trackId}.jpg) - Returns the cached file path
Subsequent calls for the same track return the cached file without re-rendering.