Neha Gupta
Neha Gupta

Reputation: 291

How to toggle between Play/Pause in MPRemoteCommandCenter

I dont know how to toggle the play and pause button. I have tried TogglePlayPauseCommand. But it is not working.

Upvotes: 4

Views: 1995

Answers (1)

Iain Smith
Iain Smith

Reputation: 9703

Would you be able to post your code on how you have tried to implement the TogglePlayPauseCommand? I think it would be done like so:

public override void ViewDidLoad()
{
    base.ViewDidLoad ();
    var commandCenter = MPRemoteCommandCenter.Shared;
    commandCenter.TogglePlayPauseCommand.AddTarget (ToggledPlayPauseButton);
}

public MPRemoteCommandHandlerStatus ToggledPlayPauseButton(MPRemoteCommandEvent commandEvent)
{
     Console.WriteLine ("Toggled");
    return MPRemoteCommandHandlerStatus.Success;
}

Upvotes: 2

Related Questions