I would like Control Center (via MPNowPlayingInfoCenter) to show the forward 15 seconds / back 15 seconds controls that Apple shows with podcasts, like so:
The utter lack of documentation tells me that there's no obvious way to do this, but has anyone out there found any non-obvious way to force this without resorting to a private method?
I've already got my handling for the forward/back button set up to advance appropriately, I'd just like to use the more appropriate UI. Any help would be greatly appreciated.
OK so I had a bit of time on my hands and so I followed the breadcrumb.… This is what I found.
Include the MediaPlayer framework and get hold of the RemoteCommandCenter:
then if you wanted to set the skip controls as per Overcast you can do the following:
and in the event handlers do what you need to do to skip by the interval:
Note: The preferredIntervals property is an NSArray but I haven’t figured out how extra intervals can be utilised by the command center unless you do something with this yourself.
Things to note that I’ve found so far. When you do this you are taking control of all the controls so the default play and pause buttons won't show unless you do the same for them:
(there is also a togglePlayPauseCommand defined but I could’t get this to fire from the Command Centre - it does fire from headphones though.)
Other discoveries: The buttons are in fixed positions left / middle / right so you cant have (for example) a previousTrack and a skipBackward as they both occupy the left position.
There are seekForward / seekBackward commands that need a prevTrack and nextTrack command to be triggered. When you set up both then a single tap triggers next / previous and a press and hold triggers a begin seek and an end seek when you lift your finger.
There is also a feedback mechanism that I haven’t seen before (occupies left position)
This displays three horizontal bars and brings up an alert sheet - you can highlight these individually by setting the active property.
There is also a rating command defined - but I couldn't get this to show in the Command Center
and a playback rate change command - but again couldn’t get this to show in Command Center
There is also a block-based target action mechanism if you prefer
One final point to be aware of: If you have registered to receive remote events via [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; then some of these commands also trigger events in the - (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent handler. These are UIEvents though with type UIEventTypeRemoteControl and a subtype to distinguish the event. You can't mix and match these with MPRemoteCommandEvents in this method. There are hints that MPRemoteCommandEvents will replace the UIEvents at some point.
All of this based on trial and error so feel free to correct.
Gareth