I have an requirement that to handle headphone play/pause button events in foreground. How ever I am able to handle the same scenario in background using the below code
There is another way to implement player control from headphones. use MPRemoteCommandCenter tooglePlayPauseCommand. Apple documentation
MPRemoteCommandCenter
[[MPRemoteCommandCenter sharedCommandCenter].togglePlayPauseCommand addTarget:self action:@selector(onTooglePlayPause)];