如何在播放视频时禁用控制中心播放/暂停按钮?

时间:2016-09-26 12:09:29

标签: ios objective-c iphone xcode control-center

我正在使用AV播放器,在我的应用中播放一些视频,但如果我在播放任何视频时打开控制中心并尝试播放和暂停视频,那么它正在播放和暂停,但我不希望这样特征。我想禁用此功能。所以,我确实喜欢这个......

MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    remoteCommandCenter.playCommand.enabled = NO;
    remoteCommandCenter.pauseCommand.enabled = NO;
    remoteCommandCenter.previousTrackCommand.enabled = NO;
    remoteCommandCenter.nextTrackCommand.enabled = NO;

这不起作用,然后

 MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    remoteCommandCenter.playCommand.enabled = YES;
    [remoteCommandCenter.playCommand addTarget:self action:@selector(test)];
    remoteCommandCenter.pauseCommand.enabled = YES;
    [remoteCommandCenter.pauseCommand addTarget:self action:@selector(test)];
    remoteCommandCenter.previousTrackCommand.enabled = NO;
    remoteCommandCenter.nextTrackCommand.enabled = NO;

    - (void)test {

// Not doing anything
    }

然后我尝试了另一种方式,

MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    remoteCommandCenter.playCommand.enabled = NO;
    [remoteCommandCenter.playCommand addTarget:self action:@selector(test)];
    remoteCommandCenter.pauseCommand.enabled = NO;
    [remoteCommandCenter.pauseCommand addTarget:self action:@selector(test)];
    remoteCommandCenter.previousTrackCommand.enabled = NO;
    remoteCommandCenter.nextTrackCommand.enabled = NO;

    - (void)test {

// Not doing anything
    }

但是没有用......

如果我在测试方法中添加一个断点作为目标,它将获得回调但没有用处。仍然,播放和暂停按钮正在工作

有没有办法禁用这些按钮,我是否正确执行?

0 个答案:

没有答案
相关问题