0

I'm using AV Player, to play some videos in my apps, But if I open Control Centre while playing any video and try to play and pause the video, it is playing and pausing, But I don't want that feature. I want to disable this functionality.So for this, I did like this...

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

This didn't work, then

 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
    }

Then Another way I tried,

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
    }

But there is no use..

If I put a breakpoint at test method that I added as a target, It is getting the callback but no use. Still, play and pause buttons are working

Is there any way to disable to these buttons, Am I doing it correctly or not ?

0 Answers0