IOS 8.x Swift MPRemoteCommandCenter - Disabling Audio Playback Controls

I am currently experiencing either a mistake or a misunderstanding of the Apple documentation.

Some background. I am using AVPlayer to start playing audio. I use AVPlayer because it provides more precise control over the positioning of the playback (falling to certain points in the song).

When I implement the code below, MPRemoteCommandCenter displays only one button (play / pause button), and all other buttons (back and forward) are missing.

  MPRemoteCommandCenter.sharedCommandCenter().playCommand.addTarget(self, action: "remoteCommandMute")
  MPRemoteCommandCenter.sharedCommandCenter().pauseCommand.addTarget(self, action: "remoteCommandMute")

Then I can switch whether it is disabled or not. According to Apple's documentation, however, you should be able to switch the included property on, and it should completely hide the buttons without adding a target to them (at least from my understanding). Here is the link to the documentation

If I do not add the .addTarget code to any of the buttons and just follow the instructions from apple to disable the specified buttons, this will not work.

    MPRemoteCommandCenter.sharedCommandCenter().previousTrackCommand.enabled = false
    MPRemoteCommandCenter.sharedCommandCenter().nextTrackCommand.enabled = false
    MPRemoteCommandCenter.sharedCommandCenter().playCommand.enabled = false
    MPRemoteCommandCenter.sharedCommandCenter().pauseCommand.enabled = false

Based on this behavior, I would expect that disabling all three buttons, in turn, would make them hidden, but it is not at all that actually disabling them does not affect them. You can still click them, and they behave as if this code is completely absent. However, if (as stated above) I add .addTarget to the button, it will become disabled if I set the .enabled flag to false.

, /, , , , Apple. , , ( ). , .

, , , , , .

+4
1

, , , . " " , . , Command.addTarget / . , playCommand.enabled false, greyed .

+3

All Articles