首页 > 解决方案 > nextTrackCommand 和 seekForwardCommand 都同时被调用

问题描述

似乎当我在播放某些东西(模拟器或设备)时按控制中心上的“下一步”时,两者nextTrackCommandseekForwardCommand被调用。

这两个功能都已启用,但只需点击“下一步”按钮即可调用这两个功能是没有意义的。

这是更多代码:

[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
    return MPRemoteCommandHandlerStatusSuccess;
}];

[[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
    NSLog(@"nextTrackCommand");
    return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand.enabled = YES;

[[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
    NSLog(@"seekForwardCommand");
    return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand.enabled = YES;

我已将下面链接到演示此问题的示例项目。

https://github.com/gerbil802/MPRemoteCommandCenterProblem

标签: iosmpremotecommandcenter

解决方案


推荐阅读