OC语法
- (void)setUpCommandCenter {
NSLog(@"锁屏setUpCommandCenter");
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.playCommand removeTarget:self];
[commandCenter.pauseCommand removeTarget:self];
//禁用pre,next
MPRemoteCommand *previousTrackCommand = commandCenter.previousTrackCommand;
previousTrackCommand.enabled = NO;
MPRemoteCommand *nextTrackCommand = commandCenter.nextTrackCommand;
nextTrackCommand.enabled = NO;
// 锁屏播放
MPRemoteCommand *playCommand = commandCenter.playCommand;
playCommand.enabled = YES;
[playCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
//
return MPRemoteCommandHandlerStatusSuccess;
}];
MPRemoteCommand *pauseCommand = commandCenter.pauseCommand;
pauseCommand.enabled = YES;
[pauseCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(M

本文详细介绍了如何使用Objective-C和Swift实现媒体播放控制,包括锁屏控制、耳机控制等,通过设置MPRemoteCommandCenter来实现播放、暂停、上一曲、下一曲等功能。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



