ios – 如何在MPRemoteCommandCenter中的播放/暂停之间切换

我不知道如何切换播放和暂停按钮.我尝试过TogglePlayPauseCommand.但它没有用. 最佳答案 您是否可以发布代码,了解您是如何尝试实现TogglePlayPauseCommand的?我认为它会这样做:

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;
}
点赞