Most music players can be controlled by the Control Center of Apple or earphone.
1. Tell the app to begin receiving remote-control events.
add the code below into your AppDelegate.m file
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
2. Implementing the method
- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event
in AppDelegate.m file too.
You have pay attention to event's two proterties, that are type and subtype.