Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8.4 MPNowPlayingInfoCenter skip/prev disappeared

Tags:

ios

iphone

ios8.4

I'm working on a music playing app and in previous iOS versions the media player would show the play/pause as well as the skip and prev buttons. Now, with the 8.4 update, all that is shown is the play/pause. I'm updating the MPNowPlayingInfoCenter in the usual way:

NSDictionary* nowPlayingInfo = @{
    MPMediaItemPropertyTitle:[self.currentSong title],
    MPMediaItemPropertyArtist:[self.currentSong artist],
    MPMediaItemPropertyPlaybackDuration:[NSNumber numberWithDouble:(double) self.duration],
    MPNowPlayingInfoPropertyElapsedPlaybackTime: [NSNumber numberWithDouble:(double)self.currentPlaybackTime],
    MPNowPlayingInfoPropertyPlaybackRate: self.isPlaying ? @1.0 : @0.0,
    MPMediaItemPropertyArtwork: mediaPlayerArtwork,
    MPNowPlayingInfoPropertyPlaybackQueueIndex: [NSNumber numberWithInteger:playQueue.queuePosition],
    MPNowPlayingInfoPropertyPlaybackQueueCount: [NSNumber numberWithInteger:playQueue.queueIDs.count] };
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlayingInfo];

But the result is... enter image description here

and enter image description here

Thanks for any help!

like image 442
Jon E Avatar asked Jul 08 '15 21:07

Jon E


1 Answers

In order to get the next and prev buttons back you need to add:

[[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand addTarget:self action:@selector(remoteNextPrevTrackCommandReceived:)];
[[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand addTarget:self action:@selector(remoteNextPrevTrackCommandReceived:)];

I added this in AppDelegate's

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

If you're already receiving remote events the action method can be empty:

-(void) remoteNextPrevTrackCommandReceived:(id)event {}

like image 168
Jon E Avatar answered Oct 23 '22 01:10

Jon E