I am making a multi-platform SwiftUI app that loads the song artwork from an .mp3 file
let playerItem = AVPlayerItem(url: fileURL)
let metadataList = playerItem.asset.metadata
for item in metadataList {
guard let key = item.commonKey, let value = item.value else {
continue
}
switch key {
case .commonKeyArtwork where value is Data :
let songArtwork = UIImage(data: value as! Data)!
default:
continue
}
}
I can also get data by using
let interpretedMP3 = AVAsset(url: fileURL)
and the metadata from that.
This all works fine for ios using UIImage(data: value as! Data)! but macos doesn't support uiimage so how am I supposed to make an image from this data?