Harish Singh
Harish Singh

Reputation: 765

How to get metadata from mp3 file URL coming from backend to show ArtWork Image?

I am facing a problem while showing artwork image from .mp3 file which is coming from back-end server. I am getting empty metadata from that URL.I am doing this way.

let urlString = "myMp3FileURL"
let serverURL = NSURL(string: urlString)!
if let asset = AVAsset.assetWithURL(serverURL) as? AVAsset {

    let metaData = asset.metaData() //Getting empty list 
}

Thanks in advance.

Upvotes: 0

Views: 532

Answers (1)

NoHalfBits
NoHalfBits

Reputation: 622

Investigate AVAsynchronousKeyValueLoading to be notified when the requested metaData property becomes available while the asset is loaded from the server. Especially with mp3s I won't trust AVAsset to block if some requested property is not yet available.

https://developer.apple.com/documentation/avfoundation/avasynchronouskeyvalueloading

Upvotes: 1

Related Questions