MPRemoteCommandCenter calls the handler block several times and calls unnecessary calls for selection methods.
Here is the code snippet:
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter]; [commandCenter.nextTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) { NSLog(@"NEXTTTTTT"); return MPRemoteCommandHandlerStatusSuccess; }]; [commandCenter.previousTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) { NSLog(@"PREVIOUSSS"); return MPRemoteCommandHandlerStatusSuccess; }];
When the user presses the next or previous button from the dock of the music player, when the screen is locked, he calls several times to call the above blocks.
ios iphone ios9 music-player mpmusicplayercontroller
Dhaval H. Nena
source share