I am builting an iOS app that streams shoutcast audio.
I want to display a custom image on the device lockscreen (no matter the song, I want the same image to be displayed).
The code bellow shows me the current title on the lockscreen, but does not display the album art like the image just bellow.
Is possible first (I think, Mixcloud achieves it) ? If yes, what is wrong with this ? Source here.
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
UIImage * albumImage = [UIImage imageNamed: @"icon_HD.png"];
MPMediaItemArtwork * albumArt = [[MPMediaItemArtwork alloc] initWithImage:albumImage];
[songInfo setObject:titre.text forKey:MPMediaItemPropertyTitle];
[songInfo setObject:artiste.text forKey:MPMediaItemPropertyArtist];
[songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
https://lh6.googleusercontent.com/-yV8VbLatlxg/UoD7Pq-Hv1I/AAAAAAAALVg/UEwKUp00k2U/s1600/iOS-7-lock-screen-music-controls.png
Just click on the album art thumbnail in the music player on the Lock Screen, and it'll expand as the screenshot above shows.
Right-click on the album cover and navigate to Album Info. In the newly opened window, go to the Artwork tab, and click Add Artwork. After you've chosen the artwork from your PC, it will be displayed in the song info menu. To make changes to your iPhone, navigate to the iPhone icon in the top left corner of the window.
Create an image file of the album cover. View your music in iTunes by Album. Select the album then ->Get Info->Add Artwork and select the image file.
In the workflow, scroll down a bit until you find a card called Music with the action "Get songs in [Playlist's Name]." Tap on the current playlist and choose a different one to create a wallpaper from that one. Once you're finished, tap "Done," then rerun the shortcut.
This is the code i use on my app. Works fine on iOS7
UIImage *image = [UIImage imageNamed:@"myImage.png"];
MPMediaItemArtwork *albumArtwork = [[MPMediaItemArtwork alloc] initWithImage:image];
NSDictionary *info = @{ MPMediaItemPropertyTitle: @"Song Name",
MPMediaItemPropertyArtist: @"Artist Name",
MPMediaItemPropertyAlbumTitle: @"Album Name",
MPMediaItemPropertyPlaybackDuration: 1.0,
MPNowPlayingInfoPropertyElapsedPlaybackTime: 1.0,
MPMediaItemPropertyArtwork: albumArtwork };
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = info;
Let me know if work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With