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

馋奶兔 提交于 2019-12-03 12:38:38
Lysann Schlegel

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.

OUTDATED:

I think the short answer is no. The documentation says this -

"You do not have direct control over which information is displayed, or its formatting. You set the values of the now playing info center dictionary according to the information you want to provide to the system. The system, or the connected accessory, handles the information’s display in a consistent manner for all apps."

I found if I did not set the nowPlayingInfo n MPNowPlayingInfoCenter then the changes I was trying to make away from the default lock screen player did not register. Be sure you are setting MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo at some point like below:

 var songInfo: NSMutableDictionary = [
        MPMediaItemPropertyTitle: "song title",
        MPMediaItemPropertyArtist: "artiest ",
    ]
    MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = songInfo as [NSObject : AnyObject]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!