I am using the new SDK for Spotify in my iOS app . In this I am using the below code for playing song from Spotify.I am able to play the song. But I am unable to see the now playing item song info and unable to control the songs from the iOS Control Center. I need to update the song info to the Control center.
[SPTTrack trackWithURI:appDelegate.player.currentTrackURI
session:auth.session
callback:^(NSError *error, SPTTrack *track) {
self.trackTitle.text = track.name;
SPTPartialArtist *artist = [track.artists objectAtIndex:0];
self.trackArtist.text = artist.name;
appDelegate.currentPlayingSongName = track.name;
appDelegate.currentPlayingArtistName = artist.name;
//[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = [NSDictionary dictionaryWithObject:track.name forKey: MPMediaItemPropertyTitle];
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:@"Audio Title" forKey:MPMediaItemPropertyTitle];
[songInfo setObject:@"Audio Author" forKey:MPMediaItemPropertyArtist];
[songInfo setObject:@"Audio Album" forKey:MPMediaItemPropertyAlbumTitle];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
}];
Thank you for reading my question. Thanks in advance
I was yesterday looking for the same info when I found your post. I figured it out since then. But this is in swift. I am just starting to learn xcode and swift. So no idea how to translate this in objc. Hope this helps ;)