iosxamarinxamarin.iosmovieplayer

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.


Solution

  • 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;
    }