I have the following code and is working for me but it can only currently show artist and song :
let mpic = MPNowPlayingInfoCenter.defaultCenter()
mpic.nowPlayingInfo = [MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName]
I tried also setting the picture with the following code but it isn't working :
mpic.nowPlayingInfo = [MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName,
MPMediaItemPropertyArtwork:songs[currentAudioIndex].songImage]
SongImage is of type UIImage.
Never mind I figured out.
If anyone want to learn you have to do the following
let mpic = MPNowPlayingInfoCenter.defaultCenter()
// initialize an instance of MPMediaItemArtWork with a UIImage
var albumArtWork = MPMediaItemArtwork(image: songs[currentAudioIndex].songImage)
// Then assign it to the MPNowPlayingInfoCenter
mpic.nowPlayingInfo = [
MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName,
MPMediaItemPropertyArtwork:albumArtWork
]
Hope this helps anyone who is also struggling with this.
Thanks
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