Reputation:
I'm trying to get the lyrics for a song on an iOS device and the examples I've found on the web and stackoverflow show getting the song's MPMediaItem (i.e. using a [MPMediaQuery songsQuery] with MPMediaItemPropertyPersistentID as a predicate) and then retrieving the lyrics using:
[mediaItem valueForProperty:MPMediaItemPropertyLyrics]
The problem is that this only works if you first open the song in the iPod music app and view the lyric there. Even if you do that the next time you sync it may stop working again.
How can we get reliable access to lyrics?
Upvotes: 3
Views: 2257
Reputation:
Solved: The following approach gets around the problem and song lyrics always show up.
NSURL* songURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL]
AVAsset* songAsset = [AVURLAsset URLAssetWithURL:songURL options:nil];
NSString* lyrics = [songAsset lyrics];
Upvotes: 15