Search code examples
iosobjective-cmpnowplayinginfocenter

How to add seek buttons on iOS lock screen?


How to setup MPRemoteCommandCenter/MPNowPlayingInfoCenter to add seek buttons? Result that I want to achieve is on the screenshot. Seek buttons should look like I have already added this code:

[[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
    [weakSelf rewindForward];

    return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand.enabled = YES;

[[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
    [weakSelf rewindBackward];

    return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = YES;

Solution

  • You would also need to set preferredIntervals as described in https://stackoverflow.com/a/24818340/1514970.