I checked some of SO answers but it doesn't work for me!
I need to get lyrics for the current playing song.
I get an empty result if I simply try to get lyrics from a media item:
if var music = mediaItemCollection.items as? [MPMediaItem]{
music = Array(Set(music))
for (_, music) in music.enumerated(){
let songInfo: SongInfo = SongInfo(
albumTitle: music.albumTitle ?? "",
artistName: music.artist ?? "",
songTitle: music.title ?? "",
songId: Int(music.persistentID),
assetURL: music.assetURL!
)
print(music.lyrics)
songArr.append(songInfo)
}
}
I've tried to get lyrics through asset URL as suggested in SO answers, but it does not work.
let songAsset = AVURLAsset(url: music.assetURL!)
if let lyricsFromAsset = songAsset.lyrics {
print("Lyrics from asset: \(lyricsFromAsset)")
}
Can somebody help with getting lyrics for the current playing song from apple music?