MPRemoteCommandCenter how to show all controls/commands

43 views Asked by At

I want to show skip forward, skip backward, previous track, next track on the locked screen. But seems skip forward/backward will just override previous/next track. That is only skip forward and skip backward controls will appear on the locked screen. I tried reordering and it is the same effect.

- (void)setupRemoteTransportControls {
    // Get the shared MPRemoteCommandCenter
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    MPRemoteCommandCenter* commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    
    // Add handler for Play Command
    [commandCenter.playCommand setEnabled:YES];
    [commandCenter.playCommand addTarget:self action:@selector(playVideo)];
    //
    [commandCenter.pauseCommand setEnabled:YES];
    [commandCenter.pauseCommand addTarget:self action:@selector(pauseVideo)];
    
    //try put skip first
    //[commandCenter.skipBackwardCommand setEnabled:YES];
    //[commandCenter.skipBackwardCommand addTarget:self action:@selector(skipBackward)];
    
    //[commandCenter.skipForwardCommand setEnabled:YES];
    //[commandCenter.skipForwardCommand addTarget:self action:@selector(skipForward)];

    [commandCenter.previousTrackCommand setEnabled:YES];
    [commandCenter.previousTrackCommand addTarget:self action:@selector(prevTrack)];
    
    [commandCenter.nextTrackCommand setEnabled:YES];
    [commandCenter.nextTrackCommand addTarget:self action:@selector(nextTrack)];
    
    [commandCenter.skipBackwardCommand setEnabled:YES];
    [commandCenter.skipBackwardCommand addTarget:self action:@selector(skipBackward)];
    
    [commandCenter.skipForwardCommand setEnabled:YES];
    [commandCenter.skipForwardCommand addTarget:self action:@selector(skipForward)];
    
    [commandCenter.changePlaybackPositionCommand setEnabled:true];
    [commandCenter.changePlaybackPositionCommand addTarget:self action:@selector(changedThumbSliderOnLockScreen:)];
    
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}

0

There are 0 answers