我的应用程序不支持返回到以前的曲目,我想知道是否可以告诉锁定屏幕音乐控件隐藏其倒带/上一个曲目按钮。我用MPNowPlayingInfoCenter
将该信息传达到锁定屏幕。
很简单的问题,能做到吗?例如,只显示播放/暂停和快进?
从 iOS 7.1 开始,有一种方法可以自定义锁定屏幕和命令中心(可能还有许多其他配件)中可用的控件:MPRemoteCommandCenter
.
针对您的问题,您可以进行以下操作:
[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)];
请参阅此 Stack Overflow 答案,了解有关 MPRemoteCommandCenter 的更多一般信息 https://stackoverflow.com/questions/20591156/is-there-a-public-way-to-force-mpnowplayinginfocenter-to-show-podcast-controls.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)