【问题标题】:How to disable Control Centre play/pause buttons?如何禁用控制中心播放/暂停按钮?
【发布时间】:2017-02-02 08:15:15
【问题描述】:

我正在使用 AV Player,在我的应用程序中播放一些视频,但如果我打开控制中心并尝试播放和暂停视频,它正在播放和暂停,但我不想要那个功能。我想禁用此功能。因此,我确实喜欢这个...

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
    }

但是没有用..

如果我在作为目标添加的测试方法处放置一个断点,它会得到回调但没有用。尽管如此,播放和暂停按钮仍然有效

有什么方法可以禁用这些按钮,我做对了吗?

【问题讨论】:

  • 你找到解决办法了吗?
  • 没有 Karthikeyan..
  • 我也在同样的问题上苦苦挣扎
  • iam 也面临同样的问题。你找到解决方案了吗?@Wills-In

标签: ios objective-c media-player avplayer control-center


【解决方案1】:

首先,为:

remoteCommandCenter.pauseCommand.enabled = NO;
[remoteCommandCenter.pauseCommand addTarget:self action:@selector(test)];

即暂停这样的事情,因为应用程序崩溃了。

【讨论】:

    猜你喜欢
    • 2017-12-11
    • 1970-01-01
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多