0

I am getting the Current Song playing as an MPMediaItem and I can successfully retrieve the title, artist and song length. However when I try to get the lyrics nothing shows up in the text field that I am updating.

let currentSong: MPMediaItem = mediaItemCollection.items[0]

if let artwork: MPMediaItemArtwork = currentSong.value(forProperty: MPMediaItemPropertyArtwork) as? MPMediaItemArtwork {
    albumArtwork.image = artwork.image(at: CGSize(width: 120, height: 120))
    songTitle.text = currentSong.title
    songArtist.text = currentSong.artist
    songLength.text = currentSong.playbackDuration.stringFromTimeInterval()
    songLyrics.text = currentSong.lyrics

}

I want songLyrics.text to be equal to the lyrics of the song.

llrs
  • 3,308
  • 35
  • 68
Jack_Lynch
  • 15
  • 5
  • Are you sure that your song has the lyrics embedded in its metadata? It doesn't have to, that's why most of `MPMediaItem` properties are optionals. – mag_zbc Jan 04 '19 at 16:08
  • Do you know how to check if they have values or not? – Jack_Lynch Jan 05 '19 at 17:03
  • did you get any solution to this? – Yogesh Patel Feb 21 '21 at 09:10
  • @YogeshPatel Unfortuantely I pinned the project back then, however since then I've gained more programming experience, I would recommend just checking its type/value to see if it's null or length == 0. (Something along those lines) – Jack_Lynch Apr 07 '21 at 20:49

0 Answers0