【问题标题】:How to Get lyrics of song from ipod library songs如何从 ipod 库歌曲中获取歌曲的歌词
【发布时间】:2011-08-03 08:11:48
【问题描述】:

我正在 iphone 应用程序中访问 ipod 库并显示专辑的标题、歌词和插图。我还想显示歌曲的歌词。我已经在 iTunes 中添加了歌词并与设备同步。但是我的代码没有显示歌词..

Example from here 获取歌词的代码是:-

- (void)handleNowPlayingItemChanged:(id)notification {
    // Ask the music player for the current song.
    MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;

    // Display the artist, album, and song name for the now-playing media item.
    // These are all UILabels.
    self.songLabel.text   = [currentItem valueForProperty:MPMediaItemPropertyTitle];
    self.artistLabel.text = [currentItem valueForProperty:MPMediaItemPropertyAlbumArtist];
    self.albumLabel.text  = [[currentItem valueForProperty:MPMediaItemPropertyLyrics]retain];    


}

请帮忙。谢谢

【问题讨论】:

标签: iphone ipod mpmediaitem


【解决方案1】:
NSURL* songURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL] 
AVAsset* songAsset = [AVURLAsset URLAssetWithURL:songURL options:nil]; 
NSString* lyrics = [songAsset lyrics];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多