如何在 MPRemoteCommandCenter 中切换 Play/Pause
How to toggle between Play/Pause in MPRemoteCommandCenter
我不知道如何切换播放和暂停按钮。我试过 TogglePlayPauseCommand。但它不起作用。
您能否 post 关于您如何尝试实现 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;
}
我不知道如何切换播放和暂停按钮。我试过 TogglePlayPauseCommand。但它不起作用。
您能否 post 关于您如何尝试实现 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;
}