When trying to grab and display song covers/artworks with MPMediaItemPropertyArtwork
, they fail to display in my UIImageView
. Additionally, with the other MPMediaItems
showing the Artist Name and Song Name, they do not update when the song is changed.
This is my .h file:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *songtitle;
@property (weak, nonatomic) IBOutlet UILabel *songartist;
@property (weak, nonatomic) IBOutlet UILabel *nowplaying;
@property (weak, nonatomic) IBOutlet UIImageView *songalbumart;
@end
This is part of my .m file that has the MPMusicPlayerController
content:
MPMusicPlayerController *player = [MPMusicPlayerController systemMusicPlayer];
MPMediaItem *item = [player nowPlayingItem];
NSString *songtitlestring = [item valueForProperty:MPMediaItemPropertyTitle];
NSString *songartiststring = [item valueForProperty:MPMediaItemPropertyArtist];
NSString *nowplayingstring = [NSString stringWithFormat:@"#NowPlaying %@ by %@, via @TweetPlaying", songtitlestring, songartiststring];
self.songalbumart = [item valueForProperty:MPMediaItemPropertyArtwork];
self.songtitle.text = songtitlestring;
self.songartist.text = songartiststring;
self.nowplaying.text = nowplayingstring;
Anyone know how to resolve these issues of:
- MPMediaItemPropertyArtwork not displaying (
IBOutlet
is connected!) - MPMediaItems of the UILabels to display Artist Name and Song Name not updating when song is changed by user
I am developing for iOS 8 and am there using MPMusicPlayerController's
systemMusicPlayer
as iPodMusicPlayer
is depreciated.
Any help would be appreciated!
Edit: So I have to use MPMusicPlayerControllerPlaybackStateDidChangeNotification
, can anyone provide an example for my situation?