简体   繁体   English

MPMoviePlayerController当前播放项目的详细信息?

[英]MPMoviePlayerController current playing item details?

i am playing a audio stream url using MPMoviePlayerController, it works fine, is their any way to get the details of current playing track ..i mean song title, artist name etc. 我正在使用MPMoviePlayerController播放音频流url,效果很好,是他们获取当前播放曲目详细信息的任何方式。我的意思是歌曲标题,艺术家姓名等。

thanks in advance 提前致谢

Addt this ur .h file 添加此ur .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;
}
}

MPMoviePlayerController does not support getting ID3-based metadata out of the played stream. MPMoviePlayerController不支持从播放的流中获取基于ID3的元数据。 You will have to use MPMusicPlayerController (local content) or possibly AVPlayer (streamed content) to get that accomplished. 您将必须使用MPMusicPlayerController (本地内容)或可能的AVPlayer (流内容)来完成该任务。 Though I must admit that I am not entirely sure if AVPlayer / AVPlayerItem will actually get the job done - I have never tried it myself. 尽管我必须承认,我不确定AVPlayer / AVPlayerItem是否能真正完成工作-我从未亲自尝试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM