gpt4 book ai didi

iphone - 如何从 iPod 库歌曲中获取歌曲的歌词

转载 作者:行者123 更新时间:2023-12-03 21:18:49 26 4
gpt4 key购买 nike

我正在 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];


}

请帮忙。谢谢

最佳答案

NSURL* songURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL] 
AVAsset* songAsset = [AVURLAsset URLAssetWithURL:songURL options:nil];
NSString* lyrics = [songAsset lyrics];

关于iphone - 如何从 iPod 库歌曲中获取歌曲的歌词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6923449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com