Spotify on iOS has a very interesting Control Center integration. Notice the hamburger button below.
The same thing is on the lock screen!
How do they do those? Is there an API in MPMediaCenter or something?
Spotify on iOS has a very interesting Control Center integration. Notice the hamburger button below.
The same thing is on the lock screen!
How do they do those? Is there an API in MPMediaCenter or something?
Yes, there is an API for that
Looking at the instructions found in the apple docs regarding remote control events you get two classes
MPRemoteCommand
andMPRemoteCommandCenter
highlighted. Looking up MPRemoteCommandCenter will show you there are a multitude of commands likelikeCommand
ordislikeCommand
you can add handlers for. Adding handlers to those commands causes them beeing displayed in the control center.Below is some all-in-one code achieving pretty much exactly the same results shown on your screenshots:
In addition to writing the code you need to
AVFoundation
to your project#import <AVFoundation/AVFoundation.h>
and#import <MediaPlayer/MediaPlayer.h>
"Audio and AirPlay"
in the app settings.