Skip to content

Commit

Permalink
Add more commands
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed May 19, 2019
1 parent e4c67fc commit cf3869a
Showing 1 changed file with 102 additions and 2 deletions.
104 changes: 102 additions & 2 deletions MediaManager/Platforms/Ios/Player/MediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,111 @@ protected override void Init()
});

var commandCenter = MPRemoteCommandCenter.Shared;

commandCenter.TogglePlayPauseCommand.Enabled = true;
commandCenter.TogglePlayPauseCommand.AddTarget(TogglePlayPauseCommand);
commandCenter.TogglePlayPauseCommand.AddTarget(PlayPauseCommand);

commandCenter.PlayCommand.Enabled = true;
commandCenter.PlayCommand.AddTarget(PlayCommand);

commandCenter.ChangeRepeatModeCommand.Enabled = true;
commandCenter.ChangeRepeatModeCommand.AddTarget(RepeatCommand);

commandCenter.ChangeShuffleModeCommand.Enabled = true;
commandCenter.ChangeShuffleModeCommand.AddTarget(ShuffleCommand);

commandCenter.NextTrackCommand.Enabled = true;
commandCenter.NextTrackCommand.AddTarget(NextCommand);

commandCenter.PauseCommand.Enabled = true;
commandCenter.PauseCommand.AddTarget(PauseCommand);

commandCenter.PreviousTrackCommand.Enabled = true;
commandCenter.PreviousTrackCommand.AddTarget(PreviousCommand);

commandCenter.SeekBackwardCommand.Enabled = true;
commandCenter.SeekBackwardCommand.AddTarget(SeekBackwardCommand);

commandCenter.SeekForwardCommand.Enabled = true;
commandCenter.SeekForwardCommand.AddTarget(SeekForwardCommand);

commandCenter.SkipBackwardCommand.Enabled = true;
commandCenter.SkipBackwardCommand.AddTarget(SkipBackwardCommand);

commandCenter.SkipForwardCommand.Enabled = true;
commandCenter.SkipForwardCommand.AddTarget(SkipForwardCommand);

commandCenter.StopCommand.Enabled = true;
commandCenter.StopCommand.AddTarget(StopCommand);
}

private MPRemoteCommandHandlerStatus SkipBackwardCommand(MPRemoteCommandEvent arg)
{
MediaManager.StepBackward();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus SkipForwardCommand(MPRemoteCommandEvent arg)
{
MediaManager.StepForward();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus StopCommand(MPRemoteCommandEvent arg)
{
MediaManager.Stop();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus SeekForwardCommand(MPRemoteCommandEvent arg)
{
MediaManager.StepForward();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus SeekBackwardCommand(MPRemoteCommandEvent arg)
{
MediaManager.StepBackward();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus PreviousCommand(MPRemoteCommandEvent arg)
{
MediaManager.PlayPrevious();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus PauseCommand(MPRemoteCommandEvent arg)
{
MediaManager.Pause();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus NextCommand(MPRemoteCommandEvent arg)
{
MediaManager.PlayNext();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus ShuffleCommand(MPRemoteCommandEvent arg)
{
MediaManager.ToggleShuffle();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus RepeatCommand(MPRemoteCommandEvent arg)
{
MediaManager.ToggleRepeat();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus PlayCommand(MPRemoteCommandEvent arg)
{
MediaManager.Play();
return MPRemoteCommandHandlerStatus.Success;
}

private MPRemoteCommandHandlerStatus TogglePlayPauseCommand(MPRemoteCommandEvent arg)
private MPRemoteCommandHandlerStatus PlayPauseCommand(MPRemoteCommandEvent arg)
{
MediaManager.PlayPause();
return MPRemoteCommandHandlerStatus.Success;
Expand Down

0 comments on commit cf3869a

Please sign in to comment.