iPhone歌曲歌词访问 [英] iPhone song lyrics access

查看:109
本文介绍了iPhone歌曲歌词访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在iOS设备上获取歌曲的歌词,我在网络上找到的示例和stackoverflow显示获得歌曲的MPMediaItem(即使用[MPMediaQuery songsQuery]和MPMediaItemPropertyPersistentID作为谓词)和然后使用以下方法检索歌词:

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]

问题是,这只有在您首次在iPod音乐应用程序中打开歌曲并查看其中的歌词时才有效。即使您在下次同步时这样做,也可能会再次停止工作。

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?

推荐答案

解决:以下方法绕过问题,歌词总是出现。

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

这篇关于iPhone歌曲歌词访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆