MPMoviePlayerController current playing item details?

1.5k views Asked by At

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.

thanks in advance

2

There are 2 answers

2
Till On

MPMoviePlayerController does not support getting ID3-based metadata out of the played stream. You will have to use MPMusicPlayerController (local content) or possibly AVPlayer (streamed content) to get that accomplished. 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.

7
Ravi Kumar Karunanithi On

Addt this ur .h file

@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;
}
}