Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnAudioQuery.queryArtwork(album.id, ArtworkType.ALBUM) do not produce an artwork (iOS 17.2.1) #143

Open
usarthurchoi opened this issue Feb 17, 2024 · 0 comments

Comments

@usarthurchoi
Copy link

Uint8List? artwork =
await _audioQuery.queryArtwork(album.id, ArtworkType.ALBUM);
if (artwork != null) {
artworks[album.id] = artwork;
}

Result was that artwork was null. The album has an artwork definitely. From the following unit test written in Swift, I was able to get the artwork without issues.
==>
func getAlbumArtwork(album: MPMediaItemCollection) -> UIImage? {
guard let representativeItem = album.representativeItem,
let artwork = representativeItem.value(forProperty: MPMediaItemPropertyArtwork) as? MPMediaItemArtwork else {
return nil
}

    // You can specify the size of the artwork image you need
    let imageSize = CGSize(width: 100, height: 100) // Example size
    return artwork.image(at: imageSize)
}

<==

Maybe the problem may originate from not using MPMediaItemCollection.representativeItem for an album.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant