Can I hide the rewind button in the iOS Lock Screen Music controls?

后端 未结 3 1546
闹比i
闹比i 2021-02-08 08:26

My app doesn’t support going back to previous tracks, and I’m wondering if I can tell the lock screen music controls to hide their rewind/previous track button. I use the

3条回答
  •  一生所求
    2021-02-08 08:45

    As of iOS 7.1 there is a way to customize the controls available in the lock screen and command center (and probably many other accessories): MPRemoteCommandCenter.

    Regarding your question you can do the following:

    [MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO;
    [MPRemoteCommandCenter sharedCommandCenter].skipBackwardCommand.enabled = NO;
    [MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = NO;
    
    // You must also register for any other command in order to take control
    // of the command center, or else disabling other commands does not work.
    // For example:
    [MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
    [[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)];
    

    Please see this Stack Overflow answer for more general information about MPRemoteCommandCenter.

提交回复
热议问题