I'm building an iOS Music app that can integrate with Apple Carplay, i can play music on Carplay normally and can display some information of song such as title, album, artist name. However can not display album artwork.
This is bulk code for display media information on Carplay:
if let nowPlayingItem: PlaylistItem = self.nowPlayingItem {
let info: NSMutableDictionary = NSMutableDictionary()
info[MPMediaItemPropertyArtist] = nowPlayingItem.mediaItem?.artist?.name
info[MPMediaItemPropertyAlbumTitle] = nowPlayingItem.mediaItem?.album?.title
info[MPMediaItemPropertyTitle] = nowPlayingItem.mediaItem?.title
info[MPMediaItemPropertyPlaybackDuration] = nowPlayingItem.mediaItem?.playbackDuration
info[MPMediaItemPropertyArtwork] = nowPlayingItem.mediaItem?.artwork()
let sec: TimeInterval = CMTimeGetSeconds(time)
info[MPNowPlayingInfoPropertyElapsedPlaybackTime] = Int(sec)
MPNowPlayingInfoCenter.default().nowPlayingInfo = info as? [String: Any]
}
This is my current app:
And this is what i want :
So what i have to do ? Please help me to find solution for this.
You're likely testing on the simulator. While the following code is sometimes necessary to show the now playing screen at all, it is currently not possible to get the CarPlay simulator to figure out the player is actually playing:
I couldn't get the album artwork to show up on the now playing screen in the simulator. Do you have access to a physical car radio (I strongly recommend to test on one before submitting to the App Store)? I know it might not be very convincing but if your artwork shows up in the notification center player on the iPhone it will also show up in CarPlay (on a real device) since the now playing components are just proxied.