How can you extract the overall stream title from AVPlayer?

Viewed 524

I'm using AVPlayer and AVPlayerItem in Swift to play internet radio streams.

Observing the "timedMetadata" gives me the track currently playing, however I never seem to get a handle of the radio title

See this example using VLC, I can obtain the "Now playing" part easily with timedMetadata, however I never receive the overall title of the radio "Title".

What am I missing, should I be observing something else to access the stream's/shoutcast/icecast information?

enter image description here

1 Answers

Try this:

let title = AVMetadataItem.metadataItems(from: urlAsset.commonMetadata, withKey: AVMetadataKey.commonKeyTitle, keySpace: AVMetadataKeySpace.common).first?.value as? String
print(title)

This works for media I have with metadata in the title (set using the Apple Music app). If this doesn't work for your media, please post it somewhere online along with your current code.

Related