Question

I am working on songs playing in MPMusicPlayerController, now I want to get current Playing Song Data (ex : some.mp3)

Please help me, thanks in advance

Was it helpful?

Solution 2

you can ask the MPMusicPlayerController for the currently playing song

MPMediaItem  *songItem = [controller nowPlayingItem];

then to extract the file (as in the mp3) there are 2 options. Look at the top 2 answers.

OTHER TIPS

try this one

@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;
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top