0

我正在使用 MPMoviePlayerController 播放音频流 url,它工作正常,是他们获取当前播放曲目详细信息的任何方式..我的意思是歌曲标题、艺术家姓名等。

提前致谢

4

2 回答 2

2

添加这个你的 .h 文件

@property (nonatomic, retain) MPMusicPlayerController *musicPlayer;
@property (nonatomic, retain) IBOutlet UILabel *songLabel;
@property (nonatomic, retain) IBOutlet UILabel *artistLabel;
@property (nonatomic, retain) IBOutlet UILabel *albumLabel;


- (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:MPMediaItemPropertyArtist];
 self.albumLabel.text  = [currentItem valueForProperty:MPMediaItemPropertyAlbumTitle];    
 // Display album artwork. self.artworkImageView is a UIImageView.
 CGSize artworkImageViewSize = self.artworkImageView.bounds.size;
 MPMediaItemArtwork *artwork = [currentItem valueForProperty:MPMediaItemPropertyArtwork];
 if (artwork != nil) 
 {
      self.artworkImageView.image = [artwork imageWithSize:artworkImageViewSize];
 }   
else
{
        self.artworkImageView.image = nil;
}
}
于 2012-04-12T06:41:20.053 回答
1

MPMoviePlayerController不支持从播放的流中获取基于 ID3 的元数据。您将不得不使用MPMusicPlayerController(本地内容)或可能AVPlayer(流式内容)来实现这一目标。虽然我必须承认我不完全确定是否AVPlayer/AVPlayerItem真的能完成工作——我自己从未尝试过。

于 2012-04-13T01:56:21.177 回答