iPhone song lyrics access

我怕爱的太早我们不能终老 提交于 2019-11-29 10:24:55

问题


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?


回答1:


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];


来源:https://stackoverflow.com/questions/6357436/iphone-song-lyrics-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!