Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom album art on lockscreen of iOS devices

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

like image 245
David Avatar asked Mar 27 '14 18:03

David


People also ask

How do I get the album artwork on Spotify on my iPhone lock screen?

Just click on the album art thumbnail in the music player on the Lock Screen, and it'll expand as the screenshot above shows.

How do I add album art to my IPAD?

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.

Can you add album art on iPhone?

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.

How do I make an Apple music background?

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.


1 Answers

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.

like image 155
Nicolas Vignolo Avatar answered Oct 31 '22 00:10

Nicolas Vignolo