Hide MPRemoteCommand seekforward and seekbackward

653 Views Asked by At

I'm developing a simple radio app for my school and because it's a stream, I figured we don't need seekforward and seekrewind. I saw that you can change what those buttons are, but I haven't been able to completely remove it from the command center/lock screen. Is this possible or am I stuck with non-working, useless buttons?

1

There are 1 best solutions below

0
On

I'm not sure, if my answer will help you at all, as I don't know, if your using AVPlayer for your app. I use AV Player for an app and set up CommandCenter programatically.

For example:

func updateCommandCenter() {
  let commandCenter = MPRemoteCommandCenter.sharedCommandCenter()

  commandCenter.playCommand.addTarget(self, action:   #selector(MusicPlayerVC.playCurrentItem))
  commandCenter.pauseCommand.addTarget(self, action: #selector(MusicPlayerVC.pauseCurrentItem))
  commandCenter.togglePlayPauseCommand.addTarget(self, action: #selector(MusicPlayerVC.playPauseButtonPressed(_:)))

//    commandCenter.skipForwardCommand.preferredIntervals = [15]
//    commandCenter.skipForwardCommand.addTarget(self, action: #selector(MusicPlayerVC.forward(_:)))

  commandCenter.bookmarkCommand.addTarget(self, action: #selector(MusicPlayerVC.save(_:)))
}

I just commented out the skipForard and it disappeared from the home screen. So if you let it away, it should not be shown.

Hope I could help you.

Screenshot:

enter image description here