2

为什么播放音乐时锁定屏幕和命令中心的控制按钮禁用?我使用 MPRemoteCommandCenter 通过远程控制访问。请帮助我,非常感谢。

顺便提一句

  1. 该应用程序没有被杀死。
  2. 我将 admob SDK 添加为我的应用插页式广告。

控制中心禁用控制按钮

在锁定屏幕上禁用控制按钮

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.1) {
    MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    commandCenter.playCommand.enabled = YES;
    [commandCenter.playCommand addTarget:self action:@selector(playAction:)];

    [commandCenter.pauseCommand addTarget:self action:@selector(pauseAction:)];

    commandCenter.previousTrackCommand.enabled = YES;
    [commandCenter.previousTrackCommand addTarget:self action:@selector(previousTrackAction:)];

    commandCenter.nextTrackCommand.enabled = YES;
    [commandCenter.nextTrackCommand addTarget:self action:@selector(nextTrackAction:)];

    commandCenter.togglePlayPauseCommand.enabled = YES;
    [commandCenter.togglePlayPauseCommand addTarget:self action:@selector(playOrPauseAction:)];
}
4

0 回答 0